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