mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
Make test more interesting
This commit is contained in:
parent
25af8b5e92
commit
533b334ac1
1 changed files with 10 additions and 9 deletions
|
@ -3862,26 +3862,27 @@ void NumberFormatterApiTest::roundingPriorityCoverageTest() {
|
|||
IcuTestErrorCode status(*this, "roundingPriorityCoverageTest");
|
||||
struct TestCase {
|
||||
double input;
|
||||
const char16_t* expectedRelaxed0113;
|
||||
const char16_t* expectedStrict0113;
|
||||
const char16_t* expectedRelaxed0123;
|
||||
const char16_t* expectedStrict0123;
|
||||
const char16_t* expectedRelaxed1133;
|
||||
const char16_t* expectedStrict1133;
|
||||
} cases[] = {
|
||||
{ 0.9999, u"1", u"1", u"1.00", u"1.0" },
|
||||
{ 0.1000, u"0.10", u"0.1", u"0.100", u"0.1" },
|
||||
{ 0.9999, u"1.0", u"1", u"1.00", u"1.0" },
|
||||
{ 9.9999, u"10", u"10", u"10.0", u"10.0" },
|
||||
{ 99.999, u"100", u"100", u"100.0", u"100" },
|
||||
{ 999.99, u"1000", u"1000", u"1000.0", u"1000" },
|
||||
|
||||
{ 0, u"0", u"0", u"0.00", u"0.0" },
|
||||
{ 0, u"0.0", u"0", u"0.00", u"0.0" },
|
||||
|
||||
{ 9.876, u"9.88", u"9.9", u"9.88", u"9.9" },
|
||||
{ 9.001, u"9", u"9", u"9.00", u"9.0" },
|
||||
{ 9.001, u"9.0", u"9", u"9.00", u"9.0" },
|
||||
};
|
||||
for (const auto& cas : cases) {
|
||||
auto precisionRelaxed0113 = Precision::minMaxFraction(0, 1)
|
||||
.withSignificantDigits(1, 3, UNUM_ROUNDING_PRIORITY_RELAXED);
|
||||
.withSignificantDigits(2, 3, UNUM_ROUNDING_PRIORITY_RELAXED);
|
||||
auto precisionStrict0113 = Precision::minMaxFraction(0, 1)
|
||||
.withSignificantDigits(1, 3, UNUM_ROUNDING_PRIORITY_STRICT);
|
||||
.withSignificantDigits(2, 3, UNUM_ROUNDING_PRIORITY_STRICT);
|
||||
auto precisionRelaxed1133 = Precision::minMaxFraction(1, 1)
|
||||
.withSignificantDigits(3, 3, UNUM_ROUNDING_PRIORITY_RELAXED);
|
||||
auto precisionStrict1133 = Precision::minMaxFraction(1, 1)
|
||||
|
@ -3905,10 +3906,10 @@ void NumberFormatterApiTest::roundingPriorityCoverageTest() {
|
|||
);
|
||||
};
|
||||
|
||||
check(u" Relaxed 0113", cas.expectedRelaxed0113, precisionRelaxed0113);
|
||||
check(u" Relaxed 0123", cas.expectedRelaxed0123, precisionRelaxed0113);
|
||||
if (status.errIfFailureAndReset()) continue;
|
||||
|
||||
check(u" Strict 0113", cas.expectedStrict0113, precisionStrict0113);
|
||||
check(u" Strict 0123", cas.expectedStrict0123, precisionStrict0113);
|
||||
if (status.errIfFailureAndReset()) continue;
|
||||
|
||||
check(u" Relaxed 1133", cas.expectedRelaxed1133, precisionRelaxed1133);
|
||||
|
|
Loading…
Add table
Reference in a new issue