]> granicus.if.org Git - icu/commitdiff
Remove testGetConversionRateInfo.
authorHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Thu, 16 Apr 2020 23:49:29 +0000 (01:49 +0200)
committerHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Thu, 16 Apr 2020 23:49:29 +0000 (01:49 +0200)
icu4c/source/test/intltest/unitsdatatest.cpp

index 44d67031ed1b7f94f9d0402a71e031acf28d7011..817082212a7721c31a035e82acc10bc8b563cbd6 100644 (file)
@@ -13,7 +13,6 @@ class UnitsDataTest : public IntlTest {
     void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = NULL);
 
     void testGetAllConversionRates();
-    void testGetConversionRateInfo();
 };
 
 extern IntlTest *createUnitsDataTest() { return new UnitsDataTest(); }
@@ -22,7 +21,6 @@ void UnitsDataTest::runIndexedTest(int32_t index, UBool exec, const char *&name,
     if (exec) { logln("TestSuite UnitsDataTest: "); }
     TESTCASE_AUTO_BEGIN;
     TESTCASE_AUTO(testGetAllConversionRates);
-    TESTCASE_AUTO(testGetConversionRateInfo);
     TESTCASE_AUTO_END;
 }
 
@@ -42,89 +40,4 @@ void UnitsDataTest::testGetAllConversionRates() {
     }
 }
 
-// TODO(hugovdm): drop this test case, maybe even before ever merging it into
-// units-staging. Not immediately deleting it to prove backward compatibility:
-void UnitsDataTest::testGetConversionRateInfo() {
-    const int MAX_NUM_RATES = 5;
-    struct {
-        // The source unit passed to getConversionRateInfo.
-        const char *sourceUnit;
-        // The target unit passed to getConversionRateInfo.
-        const char *targetUnit;
-        // Expected: units whose conversion rates are expected in the results.
-        const char *expectedOutputs[MAX_NUM_RATES];
-    } testCases[]{
-        {"meter", "kilometer", {"meter", NULL, NULL, NULL, NULL}},
-        {"liter", "gallon", {"liter", "gallon", NULL, NULL, NULL}},
-        {"watt", "horsepower", {"watt", "horsepower", NULL, NULL, NULL}},
-        {"mile-per-hour", "dekameter-per-hour", {"mile", "hour", "meter", NULL, NULL}},
-
-        // Sequence
-        {"stone-and-pound", "ton", {"pound", "stone", "ton", NULL, NULL}},
-
-        // Compound
-        {"centimeter-per-square-milligram",
-         "inch-per-square-ounce",
-         {"meter", "gram", "inch", "ounce", NULL}},
-        {"therm-us",
-         "kilogram-square-meter-per-square-second",
-         {"therm-us", "kilogram", "meter", "second", NULL}},
-
-        // "Reciprocal" example: consumption and consumption-inverse
-        {"liter-per-100-kilometer",
-         "mile-per-gallon",
-         {"liter", "100-kilometer", "mile", "gallon", NULL}},
-    };
-    for (const auto &t : testCases) {
-        logln("---testing: source=\"%s\", target=\"%s\"", t.sourceUnit, t.targetUnit);
-        IcuTestErrorCode status(*this, "testGetConversionRateInfo");
-
-        MaybeStackVector<MeasureUnit> units;
-        MeasureUnit *item = units.emplaceBack(MeasureUnit::forIdentifier(t.sourceUnit, status));
-        if (!item) {
-            status.set(U_MEMORY_ALLOCATION_ERROR);
-            return;
-        }
-        item = units.emplaceBack(MeasureUnit::forIdentifier(t.targetUnit, status));
-        if (!item) {
-            status.set(U_MEMORY_ALLOCATION_ERROR);
-            return;
-        }
-
-        MaybeStackVector<ConversionRateInfo> conversionInfo = getConversionRatesInfo(units, status);
-        if (status.errIfFailureAndReset("getConversionRatesInfo({<%s>, <%s>}, ...)", t.sourceUnit,
-                                        t.targetUnit)) {
-            continue;
-        }
-
-        int countExpected;
-        for (countExpected = 0; countExpected < MAX_NUM_RATES; countExpected++) {
-            auto expected = t.expectedOutputs[countExpected];
-            if (expected == NULL) break;
-            // Check if this conversion rate was expected
-            bool found = false;
-            for (int i = 0; i < conversionInfo.length(); i++) {
-                auto cri = conversionInfo[i];
-                if (strcmp(expected, cri->sourceUnit.data()) == 0) {
-                    found = true;
-                    break;
-                }
-            }
-            assertTrue(UnicodeString("<") + expected + "> expected", found);
-        }
-        // We're now fetching all units, not just the needed ones, so this is no
-        // longer a valid test:
-        // assertEquals("number of conversion rates", countExpected, conversionInfo.length());
-
-        // // Convenience output for debugging
-        // for (int i = 0; i < conversionInfo.length(); i++) {
-        //     ConversionRateInfo *cri = conversionInfo[i];
-        //     logln("* conversionInfo %d: source=\"%s\", baseUnit=\"%s\", factor=\"%s\", "
-        //           "offset=\"%s\"",
-        //           i, cri->sourceUnit.data(), cri->baseUnit.data(), cri->factor.data(),
-        //           cri->offset.data());
-        // }
-    }
-}
-
 #endif /* #if !UCONFIG_NO_FORMATTING */