From 7c375673a8088c3ed7d631f4338332071b92543c Mon Sep 17 00:00:00 2001 From: Younies Mahmoud Date: Sat, 28 Mar 2020 11:39:27 +0100 Subject: [PATCH] enable test cases --- icu4c/source/test/intltest/unitstest.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/icu4c/source/test/intltest/unitstest.cpp b/icu4c/source/test/intltest/unitstest.cpp index b5a5e83f0a5..a8b13e22388 100644 --- a/icu4c/source/test/intltest/unitstest.cpp +++ b/icu4c/source/test/intltest/unitstest.cpp @@ -77,13 +77,13 @@ void UnitsTest::verifyTestCase(const UnitConversionTestCase &testCase) { MeasureUnit sourceUnit = MeasureUnit::forIdentifier(testCase.source, status); MeasureUnit targetUnit = MeasureUnit::forIdentifier(testCase.target, status); - // TODO(younies): enable this again + MeasureUnit baseUnit; + auto unitsInfos = getConversionRatesInfo(sourceUnit, targetUnit, &baseUnit, status); + UnitConverter converter(sourceUnit, targetUnit, unitsInfos, status); - // UnitConverter converter(sourceUnit, targetUnit, status); + double actual = converter.convert(testCase.inputValue); - // double actual = converter.convert(testCase.inputValue); - - // assertEqualsNear("test Conversion", testCase.expectedValue, actual, 0.0001); + assertEqualsNear("test Conversion", testCase.expectedValue, actual, 0.0001); } void UnitsTest::testBasic() { @@ -95,17 +95,7 @@ void UnitsTest::testBasic() { }; for (const auto &testCase : testCases) { - UErrorCode status = U_ZERO_ERROR; - MeasureUnit sourceUnit = MeasureUnit::forIdentifier(testCase.source, status); - MeasureUnit targetUnit = MeasureUnit::forIdentifier(testCase.target, status); - - // TODO(younies): enable this again - - // UnitConverter converter(sourceUnit, targetUnit, status); - - // double actual = converter.convert(testCase.inputValue); - - // assertEqualsNear("test Conversion", testCase.expectedValue, actual, 0.0001); + verifyTestCase(testCase); } } @@ -468,7 +458,7 @@ void unitPreferencesTestDataLineFn(void *context, char *fields[][2], int32_t fie * Parses the format used by unitPreferencesTest.txt, calling lineFn for each * line. * - * This is a modified version of u_parseDelimitedFile, customised for + * This is a modified version of u_parseDelimitedFile, customized for * unitPreferencesTest.txt, due to it having a variable number of fields per * line. */ -- 2.40.0