ICU-1005 increase code coverage for NumberFormat
X-SVN-Rev: 7140
This commit is contained in:
parent
68be9ea66e
commit
004feb34d1
@ -40,6 +40,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
|
||||
CASE(10,TestPatterns2);
|
||||
CASE(11,TestSecondaryGrouping);
|
||||
CASE(12,TestSurrogateSupport);
|
||||
CASE(13,TestAPI);
|
||||
|
||||
default: name = ""; break;
|
||||
}
|
||||
@ -47,6 +48,40 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
// Test API (increase code coverage)
|
||||
void
|
||||
NumberFormatTest::TestAPI(void)
|
||||
{
|
||||
logln("Test API");
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
NumberFormat *test = NumberFormat::createInstance("root", status);
|
||||
if(U_FAILURE(status)) {
|
||||
errln("unable to create format object");
|
||||
}
|
||||
if(test != NULL) {
|
||||
test->setMinimumIntegerDigits(10);
|
||||
test->setMaximumIntegerDigits(2);
|
||||
|
||||
test->setMinimumFractionDigits(10);
|
||||
test->setMaximumFractionDigits(2);
|
||||
|
||||
UnicodeString result;
|
||||
FieldPosition pos;
|
||||
Formattable bla("Paja Patak"); // Donald Duck for non Serbian speakers
|
||||
test->format(bla, result, pos, status);
|
||||
if(U_SUCCESS(status)) {
|
||||
errln("Yuck... Formatted a duck... As a number!");
|
||||
} else {
|
||||
status = U_ZERO_ERROR;
|
||||
}
|
||||
|
||||
delete test;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Test various patterns
|
||||
void
|
||||
NumberFormatTest::TestPatterns(void)
|
||||
@ -633,6 +668,18 @@ void NumberFormatTest::TestScientific(void) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Test the constructor for default locale. We have to
|
||||
// manually set the default locale, as there is no
|
||||
// guarantee that the default locale has the same
|
||||
// scientific format.
|
||||
Locale def = Locale::getDefault();
|
||||
Locale::setDefault(Locale::US, status);
|
||||
expect(NumberFormat::createScientificInstance(status),
|
||||
12345.678901,
|
||||
"1.2345678901E4", status);
|
||||
Locale::setDefault(def, status);
|
||||
|
||||
expect(new DecimalFormat("#E0", US, status),
|
||||
12345.0,
|
||||
"1.2345E4", status);
|
||||
|
@ -18,7 +18,11 @@ class NumberFormatTest: public CalendarTimeZoneTest {
|
||||
// IntlTest override
|
||||
void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
|
||||
public:
|
||||
/*
|
||||
/**
|
||||
* Test APIs (to increase code coverage)
|
||||
*/
|
||||
virtual void TestAPI(void);
|
||||
/**
|
||||
* Test the handling of quotes
|
||||
**/
|
||||
virtual void TestQuotes(void);
|
||||
|
Loading…
Reference in New Issue
Block a user