-
-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICU-22781 Uncomment and enable constant denominator tests #3385
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1192,6 +1192,7 @@ void UnitsTest::testUnitsConstantsDenomenator() { | |
} testCases[]{ | ||
{"meter-per-1000", 1000}, | ||
{"liter-per-1000-kiloliter", 1000}, | ||
{"meter-per-100-kilometer", 100}, // Failing: ICU-23045 | ||
{"liter-per-kilometer", 0}, | ||
{"second-per-1000-minute", 1000}, | ||
{"gram-per-1000-kilogram", 1000}, | ||
|
@@ -1205,6 +1206,7 @@ void UnitsTest::testUnitsConstantsDenomenator() { | |
{"portion-per-7", 7}, | ||
{"portion-per-8", 8}, | ||
{"portion-per-9", 9}, | ||
|
||
// Test for constant denominators that are powers of 10 | ||
{"portion-per-10", 10}, | ||
{"portion-per-100", 100}, | ||
|
@@ -1214,16 +1216,18 @@ void UnitsTest::testUnitsConstantsDenomenator() { | |
{"portion-per-1000000", 1000000}, | ||
{"portion-per-10000000", 10000000}, | ||
{"portion-per-100000000", 100000000}, | ||
// ICU-22781: {"portion-per-1000000000", 1000000000}, | ||
// ICU-22781: {"portion-per-10000000000", 10000000000}, | ||
// ICU-22781: {"portion-per-100000000000", 100000000000}, | ||
// ICU-22781: {"portion-per-1000000000000", 1000000000000}, | ||
// ICU-22781: {"portion-per-10000000000000", 10000000000000}, | ||
// ICU-22781: {"portion-per-100000000000000", 100000000000000}, | ||
// ICU-22781: {"portion-per-1000000000000000", 1000000000000000}, | ||
// ICU-22781: {"portion-per-10000000000000000", 10000000000000000}, | ||
// ICU-22781: {"portion-per-100000000000000000", 100000000000000000}, | ||
// ICU-22781: {"portion-per-1000000000000000000", 1000000000000000000}, | ||
{"portion-per-1000000000", 1000000000}, // Failing: ICU-23045 | ||
{"portion-per-10000000000", 10000000000}, | ||
{"portion-per-100000000000", 100000000000}, | ||
{"portion-per-1000000000000", 1000000000000}, | ||
{"portion-per-10000000000000", 10000000000000}, | ||
{"portion-per-100000000000000", 100000000000000}, | ||
{"portion-per-1000000000000000", 1000000000000000}, | ||
{"portion-per-10000000000000000", 10000000000000000}, | ||
{"portion-per-100000000000000000", 100000000000000000}, | ||
{"portion-per-1000000000000000000", 1000000000000000000}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same issue as in the other PRs: If these are all expected to fail and are being covered by An alternative approach would be to add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done now :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is line 1219 the only one that's failing? If so, we're good here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is the only one that is failing. |
||
{"portion-per-1e3-kilometer", 1000}, | ||
|
||
// Test for constant denominators that are represented as scientific notation | ||
// numbers. | ||
{"portion-per-1e1", 10}, | ||
|
@@ -1238,32 +1242,33 @@ void UnitsTest::testUnitsConstantsDenomenator() { | |
{"portion-per-1E5", 100000}, | ||
{"portion-per-1e6", 1000000}, | ||
{"portion-per-1E6", 1000000}, | ||
// ICU-22781: {"portion-per-1e10", 10000000000}, | ||
// ICU-22781: {"portion-per-1E10", 10000000000}, | ||
// ICU-22781: {"portion-per-1e18", 1000000000000000000}, | ||
// ICU-22781: {"portion-per-1E18", 1000000000000000000}, | ||
{"portion-per-1e9", 1000000000}, // Failing: ICU-23045 | ||
{"portion-per-1E9", 1000000000}, // Failing: ICU-23045 | ||
{"portion-per-1e10", 10000000000}, | ||
{"portion-per-1E10", 10000000000}, | ||
{"portion-per-1e18", 1000000000000000000}, | ||
{"portion-per-1E18", 1000000000000000000}, | ||
|
||
// Test for constant denominators that are randomly selected. | ||
// ICU-22781: {"liter-per-12345-kilometer", 12345}, | ||
// ICU-22781: {"per-1000-kilometer", 1000}, | ||
// ICU-22781: {"liter-per-1000-kiloliter", 1000}, | ||
{"liter-per-12345-kilometer", 12345}, | ||
{"per-1000-kilometer", 1000}, | ||
{"liter-per-1000-kiloliter", 1000}, | ||
|
||
// Test for constant denominators that give 0. | ||
{"meter", 0}, | ||
{"meter-per-second", 0}, | ||
{"meter-per-square-second", 0}, | ||
// NOTE: The following constant denominator should be 0. However, since | ||
// `100-kilometer` is treated as a unit in CLDR, | ||
// the unit does not have a constant denominator. | ||
// This issue should be addressed in CLDR. | ||
{"meter-per-100-kilometer", 0}, | ||
// NOTE: the following CLDR identifier should be invalid, but because | ||
// `100-kilometer` is considered a unit in CLDR, | ||
// one `100` will be considered as a unit constant denominator and the other | ||
// `100` will be considered part of the unit. | ||
// This issue should be addressed in CLDR. | ||
{"meter-per-100-100-kilometer", 100}, | ||
}; | ||
|
||
for (const auto &testCase : testCases) { | ||
if (uprv_strcmp(testCase.source, "portion-per-1000000000") == 0 || | ||
uprv_strcmp(testCase.source, "portion-per-1e9") == 0 || | ||
uprv_strcmp(testCase.source, "portion-per-1E9") == 0 || | ||
uprv_strcmp(testCase.source, "meter-per-100-kilometer") == 0) { | ||
logKnownIssue("ICU-23045", "Incorrect constant denominator for certain unit identifiers"); | ||
continue; | ||
} | ||
|
||
MeasureUnit unit = MeasureUnit::forIdentifier(testCase.source, status); | ||
if (status.errIfFailureAndReset("forIdentifier(\"%s\")", testCase.source)) { | ||
continue; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These cases don't exist in the Java tests.
Is there a good reason to have them?
Are they testing something interesting, that is not well covered by other cases?
They they should also be in Java.
If they don't actually exercise anything interesting, we should not have them in C/C++ either.
In general the tests in C++ and Java should be the same, unless there are very good reasons (for example Java testing for all kind of types that don't exist in C++)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now , c++ and java are identical, sorry for this small confusion.