]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/cintltst/cintltst.c
ICU-64260.0.1.tar.gz
[apple/icu.git] / icuSources / test / cintltst / cintltst.c
index 1448e0633eff96c81d5fba21b6c560f480bf6743..aaa187f6bdb14c22c5fb68c17e677f8d5c9fb8c3 100644 (file)
@@ -1,6 +1,8 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1997-2013, International Business Machines Corporation and
+ * Copyright (c) 1997-2015, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -73,6 +75,10 @@ void ctest_setICU_DATA(void);
 static int gOrigArgc;
 static const char* const * gOrigArgv;
 
+#ifdef UNISTR_COUNT_FINAL_STRING_LENGTHS
+U_CAPI void unistr_printLengths();
+#endif
+
 int main(int argc, const char* const argv[])
 {
     int nerrors = 0;
@@ -233,6 +239,10 @@ int main(int argc, const char* const argv[])
 
     }  /* End of loop that repeats the entire test, if requested.  (Normally doesn't loop)  */
 
+#ifdef UNISTR_COUNT_FINAL_STRING_LENGTHS
+    unistr_printLengths();
+#endif
+
     endTime = uprv_getRawUTCtime();
     diffTime = (int32_t)(endTime - startTime);
     printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
@@ -699,4 +709,38 @@ U_CFUNC UBool assertEquals(const char* message, const char* expected,
     return TRUE;
 }
 
+U_CFUNC UBool assertUEquals(const char* message, const UChar* expected,
+                            const UChar* actual) {
+    for (int32_t i=0;; i++) {
+        if (expected[i] != actual[i]) {
+            log_err("FAIL: %s; got \"%s\"; expected \"%s\"\n",
+                    message, austrdup(actual), austrdup(expected));
+            return FALSE;
+        }
+        UChar curr = expected[i];
+        U_ASSERT(curr == actual[i]);
+        if (curr == 0) {
+            break;
+        }
+    }
+#ifdef VERBOSE_ASSERTIONS
+    log_verbose("Ok: %s; got \"%s\"\n", message, austrdup(actual));
+#endif
+    return TRUE;
+}
+
+U_CFUNC UBool assertIntEquals(const char* message, int64_t expected, int64_t actual) {
+    if (expected != actual) {
+        log_err("FAIL: %s; got \"%d\"; expected \"%d\"\n",
+                message, actual, expected);
+        return FALSE;
+    }
+#ifdef VERBOSE_ASSERTIONS
+    else {
+        log_verbose("Ok: %s; got \"%d\"\n", message, actual);
+    }
+#endif
+    return TRUE;
+}
+
 #endif