ICU-21366 testConverter: allow some double-precision error for 0.0
authorHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Fri, 6 Nov 2020 17:55:21 +0000 (17:55 +0000)
committerHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Wed, 11 Nov 2020 17:31:18 +0000 (18:31 +0100)
See #1443

icu4c/source/test/intltest/units_test.cpp

index c0230703b966723a5954c4bd442bfe77279c734e..c88116ae3ce7c6847e2963cbdc209b4be84b4f6b 100644 (file)
@@ -247,9 +247,12 @@ void UnitsTest::testConverter() {
             continue;
         }
 
+        double maxDelta = 1e-6 * uprv_fabs(testCase.expectedValue);
+        if (testCase.expectedValue == 0) {
+            maxDelta = 1e-12;
+        }
         assertEqualsNear(UnicodeString("testConverter: ") + testCase.source + " to " + testCase.target,
-                         testCase.expectedValue, converter.convert(testCase.inputValue),
-                         0.0001 * uprv_fabs(testCase.expectedValue));
+                         testCase.expectedValue, converter.convert(testCase.inputValue), maxDelta);
     }
 }