void testBasic();
void testMass();
+ void testTemprature();
};
extern IntlTest *createUnitsTest() {
TESTCASE_AUTO_BEGIN;
TESTCASE_AUTO(testBasic);
TESTCASE_AUTO(testMass);
+ TESTCASE_AUTO(testTemprature);
TESTCASE_AUTO_END;
}
void UnitsTest::testMass() {
IcuTestErrorCode status(*this, "Units testMass");
- ;
+
// Test Cases
struct TestCase
{
}
}
+void UnitsTest::testTemprature() {
+ IcuTestErrorCode status(*this, "Units testTemprature");
+ // Test Cases
+ struct TestCase
+ {
+ const char16_t* source;
+ const char16_t* target;
+ const double inputValue;
+ const double expectedValue;
+ } testCases[]
+ {
+ {u"celsius", u"fahrenheit" , 0.0 , 32.0 },
+ {u"celsius", u"fahrenheit" , 10.0 , 50.0 },
+ {u"fahrenheit", u"celsius" , 32.0 , 0.0 },
+ {u"fahrenheit", u"celsius" , 89.6 , 32 },
+ {u"kelvin", u"fahrenheit" , 0.0 , -459.67 },
+ {u"kelvin", u"fahrenheit" , 300 , 80.33 },
+ {u"kelvin", u"celsius" , 0.0 , -273.15 },
+ {u"kelvin", u"celsius" , 300.0 , 26.85 },
+ };
+
+ for (const auto& testCase : testCases)
+ {
+ assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue), testCase.expectedValue);
+ }
+}
+
#endif /* #if !UCONFIG_NO_FORMATTING */