本文整理汇总了C++中NumberFormat::setMaximumIntegerDigits方法的典型用法代码示例。如果您正苦于以下问题:C++ NumberFormat::setMaximumIntegerDigits方法的具体用法?C++ NumberFormat::setMaximumIntegerDigits怎么用?C++ NumberFormat::setMaximumIntegerDigits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NumberFormat
的用法示例。
在下文中一共展示了NumberFormat::setMaximumIntegerDigits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testAPI
//.........这里部分代码省略.........
}
// ======= Test parse()
if (fr != NULL)
{
logln("Testing parse()");
double d = -10456.0037;
UnicodeString text("-10,456.0037");
Formattable result1, result2, result3;
ParsePosition pos(0), pos01(0);
fr->parseObject(text, result1, pos);
if(result1.getType() != Formattable::kDouble && result1.getDouble() != d) {
errln("ERROR: Roundtrip failed (via parse()) for " + text);
}
logln(text + " parsed into " + (int32_t) result1.getDouble());
fr->parse(text, result2, pos01);
if(result2.getType() != Formattable::kDouble && result2.getDouble() != d) {
errln("ERROR: Roundtrip failed (via parse()) for " + text);
}
logln(text + " parsed into " + (int32_t) result2.getDouble());
status = U_ZERO_ERROR;
fr->parse(text, result3, status);
if(U_FAILURE(status)) {
errln("ERROR: parse() failed");
}
if(result3.getType() != Formattable::kDouble && result3.getDouble() != d) {
errln("ERROR: Roundtrip failed (via parse()) for " + text);
}
logln(text + " parsed into " + (int32_t) result3.getDouble());
}
// ======= Test getters and setters
if (fr != NULL && def != NULL)
{
logln("Testing getters and setters");
int32_t count = 0;
const Locale *locales = NumberFormat::getAvailableLocales(count);
logln((UnicodeString) "Got " + count + " locales" );
for(int32_t i = 0; i < count; i++) {
UnicodeString name(locales[i].getName(),"");
logln(name);
}
fr->setParseIntegerOnly( def->isParseIntegerOnly() );
if(fr->isParseIntegerOnly() != def->isParseIntegerOnly() ) {
errln("ERROR: setParseIntegerOnly() failed");
}
fr->setGroupingUsed( def->isGroupingUsed() );
if(fr->isGroupingUsed() != def->isGroupingUsed() ) {
errln("ERROR: setGroupingUsed() failed");
}
fr->setMaximumIntegerDigits( def->getMaximumIntegerDigits() );
if(fr->getMaximumIntegerDigits() != def->getMaximumIntegerDigits() ) {
errln("ERROR: setMaximumIntegerDigits() failed");
}
fr->setMinimumIntegerDigits( def->getMinimumIntegerDigits() );
if(fr->getMinimumIntegerDigits() != def->getMinimumIntegerDigits() ) {
errln("ERROR: setMinimumIntegerDigits() failed");
}
fr->setMaximumFractionDigits( def->getMaximumFractionDigits() );
if(fr->getMaximumFractionDigits() != def->getMaximumFractionDigits() ) {
errln("ERROR: setMaximumFractionDigits() failed");
}
fr->setMinimumFractionDigits( def->getMinimumFractionDigits() );
if(fr->getMinimumFractionDigits() != def->getMinimumFractionDigits() ) {
errln("ERROR: setMinimumFractionDigits() failed");
}
}
// ======= Test getStaticClassID()
logln("Testing getStaticClassID()");
status = U_ZERO_ERROR;
NumberFormat *test = new DecimalFormat(status);
if(U_FAILURE(status)) {
errln("ERROR: Couldn't create a NumberFormat");
}
if(test->getDynamicClassID() != DecimalFormat::getStaticClassID()) {
errln("ERROR: getDynamicClassID() didn't return the expected value");
}
delete test;
delete def;
delete fr;
delete cur;
delete cur_fr;
delete per;
delete per_fr;
}