当前位置: 首页>>代码示例>>C++>>正文


C++ ChoiceFormat::getClosures方法代码示例

本文整理汇总了C++中ChoiceFormat::getClosures方法的典型用法代码示例。如果您正苦于以下问题:C++ ChoiceFormat::getClosures方法的具体用法?C++ ChoiceFormat::getClosures怎么用?C++ ChoiceFormat::getClosures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ChoiceFormat的用法示例。


在下文中一共展示了ChoiceFormat::getClosures方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fpos

void
TestChoiceFormat::TestSimpleExample( void )
{
    double limits[] = {1,2,3,4,5,6,7};
    UnicodeString monthNames[] = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
    ChoiceFormat* form = new ChoiceFormat(limits, monthNames, 7);
    ParsePosition parse_pos;
    // TODO Fix this ParsePosition stuff...
    UnicodeString str;
    UnicodeString res1, res2;
    UErrorCode status;
    FieldPosition fpos(FieldPosition::DONT_CARE);
    Formattable f;
    int32_t ix;
    //for (double i = 0.0; i <= 8.0; ++i) {
    for (ix = 0; ix <= 8; ++ix) {
        double i = ix; //nos
        status = U_ZERO_ERROR;
        fpos = 0;
        str = "";
        res1 = form->format(i, str, fpos, status );
        if (!chkstatus( status, "***  test_simple_example format" )) {
            delete form;
            return;
        }
        //form->parse(res1, f, parse_pos);
        res2 = " ??? ";
        it_logln(UnicodeString("") + ix + UnicodeString(" -> ") + res1 + UnicodeString(" -> ") + res2);
    }
    //Testing ==operator
    const double filelimits[] = {0,1,2};
    const UnicodeString filepart[] = {"are no files","is one file","are {2} files"};
    ChoiceFormat* formnew=new ChoiceFormat(filelimits, filepart, 3); 
    ChoiceFormat* formequal=new ChoiceFormat(limits, monthNames, 7); 
    if(*formnew == *form){
        errln("ERROR: ==operator failed\n");
    }
    if(!(*form == *formequal)){
        errln("ERROR: ==operator failed\n");
    }
    delete formequal; 
    delete formnew; 

    //Testing getLimits()
    int32_t count=0;
    const double *gotLimits=form->getLimits(count);
#if 1  // ICU 4.8 deprecates and disables the ChoiceFormat getters.
    if(count != 0 || gotLimits != NULL) {
        errln("getLimits() returns something, should be disabled");
    }
    const UnicodeString *gotFormats=form->getFormats(count);
    if(count != 0 || gotFormats != NULL) {
        errln("getFormats() returns something, should be disabled");
    }
    const UBool *gotClosures=form->getClosures(count);
    if(count != 0 || gotClosures != NULL) {
        errln("getClosures() returns something, should be disabled");
    }
#else
    if(count != 7){
        errln("getLimits didn't update the count correctly\n");
    }
    for(ix=0; ix<count; ix++){
        if(gotLimits[ix] != limits[ix]){
            errln((UnicodeString)"getLimits didn't get the limits correctly.  Expected " + limits[ix] + " Got " + gotLimits[ix]);
        }
    }
    //Testing getFormats()
    count=0;
    const UnicodeString *gotFormats=form->getFormats(count);
    if(count != 7){
        errln("getFormats didn't update the count correctly\n");
    }
    for(ix=0; ix<count; ix++){
        if(gotFormats[ix] != monthNames[ix]){
            errln((UnicodeString)"getFormats didn't get the Formats correctly.  Expected " + monthNames[ix] + " Got " + gotFormats[ix]);
        }
    }
#endif

    delete form;
}
开发者ID:winlibs,项目名称:icu4c,代码行数:82,代码来源:tchcfmt.cpp


注:本文中的ChoiceFormat::getClosures方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。