]> granicus.if.org Git - icu/commitdiff
Add IntlTest::assertNotEquals() for int32_t.
authorHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Wed, 29 Apr 2020 19:55:13 +0000 (21:55 +0200)
committerHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Wed, 29 Apr 2020 19:55:13 +0000 (21:55 +0200)
icu4c/source/test/intltest/intltest.cpp
icu4c/source/test/intltest/intltest.h
icu4c/source/test/intltest/unitstest.cpp

index 15cd2d30776e6a544a77057b7dfeda44a9ddc84b..8a68fc584daae96f7aa3b2491933ce8ce9ce78f0 100644 (file)
@@ -2155,6 +2155,23 @@ UBool IntlTest::assertEquals(const char* message,
     return TRUE;
 }
 
+UBool IntlTest::assertNotEquals(const char* message,
+                                int32_t expectedNot,
+                                int32_t actual) {
+    if (expectedNot == actual) {
+        errln((UnicodeString)("FAIL: ") + message + "; got " + actual + "=0x" + toHex(actual) +
+              "; expected != " + expectedNot);
+        return FALSE;
+    }
+#ifdef VERBOSE_ASSERTIONS
+    else {
+        logln((UnicodeString)("Ok: ") + message + "; got " + actual + "=0x" + toHex(actual) +
+              " != " + expectedNot);
+    }
+#endif
+    return TRUE;
+}
+
 static char ASSERT_BUF[256];
 
 static const char* extractToAssertBuf(const UnicodeString& message) {
@@ -2224,6 +2241,11 @@ UBool IntlTest::assertEquals(const UnicodeString& message,
                              const std::vector<std::string>& actual) {
     return assertEquals(extractToAssertBuf(message), expected, actual);
 }
+UBool IntlTest::assertNotEquals(const UnicodeString &message,
+                                int32_t expectedNot,
+                                int32_t actual) {
+    return assertNotEquals(extractToAssertBuf(message), expectedNot, actual);
+}
 
 #if !UCONFIG_NO_FORMATTING
 UBool IntlTest::assertEquals(const UnicodeString& message,
index 027ebaa45e3e173d7368ce8d2abdb4ba107f7ef5..b0e2524780497deedd4be6205f4a77665686d0b1 100644 (file)
@@ -309,6 +309,7 @@ public:
     UBool assertEquals(const UnicodeString& message, const Formattable& expected,
                        const Formattable& actual);
 #endif
+    UBool assertNotEquals(const char* message, int32_t expectedNot, int32_t actual);
     UBool assertTrue(const UnicodeString& message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE);
     UBool assertFalse(const UnicodeString& message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE);
     UBool assertSuccess(const UnicodeString& message, UErrorCode ec);
@@ -323,6 +324,7 @@ public:
     UBool assertEquals(const UnicodeString& message, const UnicodeSet& expected, const UnicodeSet& actual);
     UBool assertEquals(const UnicodeString& message,
         const std::vector<std::string>& expected, const std::vector<std::string>& actual);
+    UBool assertNotEquals(const UnicodeString& message, int32_t expectedNot, int32_t actual);
 
     virtual void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL ); // overide !
 
index adedd0f581f91df041055c53d1316dea2f850889..aea53050a088dd29e6017e054bf295962de5c90f 100644 (file)
@@ -280,7 +280,7 @@ void unitsTestDataLineFn(void *context, char *fields[][2], int32_t fieldCount, U
         .append(" -> ", status)
         .append(targetUnit.getIdentifier(), status);
     if (status.errIfFailureAndReset("msg construction")) { return; }
-    unitsTest->assertTrue(msg.data(), convertibility != UNCONVERTIBLE);
+    unitsTest->assertNotEquals(msg.data(), UNCONVERTIBLE, convertibility);
 
     // TODO(hugovdm,younies): the following code can be uncommented (and
     // fixed) once merged with a UnitConverter branch: