From bdbc03c642f92c976ddeb91f9b4c29f74fd4c0fa Mon Sep 17 00:00:00 2001 From: Younies Date: Fri, 17 Jan 2020 12:40:32 +0100 Subject: [PATCH] Add Tests for Area --- icu4c/source/test/intltest/unitstest.cpp | 28 ++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/icu4c/source/test/intltest/unitstest.cpp b/icu4c/source/test/intltest/unitstest.cpp index 59f4176d422..2d692c23b03 100644 --- a/icu4c/source/test/intltest/unitstest.cpp +++ b/icu4c/source/test/intltest/unitstest.cpp @@ -17,9 +17,10 @@ public: void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = NULL); void testBasic(); + void testSiPrefixes(); void testMass(); void testTemperature(); - void testSiPrefixes(); + void testArea(); }; extern IntlTest *createUnitsTest() @@ -35,9 +36,10 @@ void UnitsTest::runIndexedTest(int32_t index, UBool exec, const char *&name, cha } TESTCASE_AUTO_BEGIN; TESTCASE_AUTO(testBasic); + TESTCASE_AUTO(testSiPrefixes); TESTCASE_AUTO(testMass); TESTCASE_AUTO(testTemperature); - TESTCASE_AUTO(testSiPrefixes); + TESTCASE_AUTO(testArea); TESTCASE_AUTO_END; } @@ -151,4 +153,26 @@ void UnitsTest::testTemperature() } } +void UnitsTest::testArea() +{ + IcuTestErrorCode status(*this, "Units Area"); + + // Test Cases + struct TestCase + { + const char16_t *source; + const char16_t *target; + const double inputValue; + const double expectedValue; + } testCases[]{ + {u"square-meter", u"square-yard", 10.0, 11.9599}, + {u"hectare", u"square-yard", 1.0, 11959.9}, + {u"square-mile", u"square-foot", 0.0001, 2787.84}}; + + for (const auto &testCase : testCases) + { + assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue), testCase.expectedValue); + } +} + #endif /* #if !UCONFIG_NO_FORMATTING */ -- 2.40.0