]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/letest/letest.cpp
ICU-511.32.tar.gz
[apple/icu.git] / icuSources / test / letest / letest.cpp
index e73d9b82cb03d740917ad16ec0de38467ca43d87..8e4523a8d2042c4f9339426a20ddaf810759b5f4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 1999-2006, International Business Machines
+ *   Copyright (C) 1999-2013, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
@@ -23,6 +23,9 @@
 #include "layout/LEScripts.h"
 #include "layout/LayoutEngine.h"
 
+#include "layout/ParagraphLayout.h"
+#include "layout/RunArrays.h"
+
 #include "PortableFontInstance.h"
 #include "SimpleFontInstance.h"
 
@@ -40,6 +43,14 @@ U_NAMESPACE_USE
 #define CH_COMMA 0x002C
 
 U_CDECL_BEGIN
+
+static void U_CALLCONV ScriptTest(void)
+{
+    if ((int)scriptCodeCount != (int)USCRIPT_CODE_LIMIT) {
+        log_err("ScriptCodes::scriptCodeCount = %d, but UScriptCode::USCRIPT_CODE_LIMIT = %d\n", scriptCodeCount, USCRIPT_CODE_LIMIT);
+    }
+}
+
 static void U_CALLCONV ParamTest(void)
 {
     LEErrorCode status = LE_NO_ERROR;
@@ -374,13 +385,27 @@ static void checkFontVersion(PortableFontInstance *fontInstance, const char *tes
     if (fontChecksum != testChecksum) {
         const char *fontVersionString = fontInstance->getNameString(NAME_VERSION_STRING,
             PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH);
+        const LEUnicode *uFontVersionString = NULL;
+
+            // The standard recommends that the Macintosh Roman/English name string be present, but
+            // if it's not, try the Microsoft Unicode/English string.
+            if (fontVersionString == NULL) {
+                uFontVersionString = fontInstance->getUnicodeNameString(NAME_VERSION_STRING,
+                    PLATFORM_MICROSOFT, MICROSOFT_UNICODE_BMP, MICROSOFT_ENGLISH);
+            }
 
         log_info("Test %s: this may not be the same font used to generate the test data.\n", testID);
-        log_info("Your font's version string is \"%s\"\n", fontVersionString);
+
+        if (uFontVersionString != NULL) {
+            log_info("Your font's version string is \"%S\"\n", uFontVersionString);
+            fontInstance->deleteNameString(uFontVersionString);
+        } else {
+            log_info("Your font's version string is \"%s\"\n", fontVersionString);
+            fontInstance->deleteNameString(fontVersionString);
+        }
+
         log_info("The expected version string is \"%s\"\n", testVersionString);
         log_info("If you see errors, they may be due to the version of the font you're using.\n");
-
-        fontInstance->deleteNameString(fontVersionString);
     }
 }
 
@@ -388,7 +413,7 @@ static void checkFontVersion(PortableFontInstance *fontInstance, const char *tes
 const char *getSourceTestData() {
     const char *srcDataDir = NULL;
 #ifdef U_TOPSRCDIR
-    srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
+    srcDataDir =  U_TOPSRCDIR  U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
 #else
     srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
     FILE *f = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"rbbitst.txt", "r");
@@ -657,7 +682,7 @@ static void U_CALLCONV DataDrivenTest(void)
             expected.glyphCount = glyphCount;
 
             if (glyphCount < charCount || indexCount != glyphCount || positionCount < glyphCount * 2 + 2) {
-                log_err("Test %s: inconsistent input data: charCount = %d, glyphCount = %d, glyphCount = %d, indexCount = %d, positionCount = %d\n",
+                log_err("Test %s: inconsistent input data: charCount = %d, glyphCount = %d, indexCount = %d, positionCount = %d\n",
                     id, charCount, glyphCount, indexCount, positionCount);
                 goto free_expected;
             };
@@ -707,12 +732,244 @@ free_c_strings:
 }
 U_CDECL_END
 
-static void addAllTests(TestNode** root)
+U_CDECL_BEGIN
+/*
+ * From ticket:5923:
+ *
+ * Build a paragraph that contains a mixture of left to right and right to left text.
+ * Break it into multiple lines and make sure that the glyphToCharMap for run in each
+ * line is correct.
+ *
+ * Note: it might be a good idea to also check the glyphs and positions for each run,
+ * that we get the expected number of runs per line and that the line breaks are where
+ * we expect them to be. Really, it would be a good idea to make a whole test suite
+ * for ParagraphLayout.
+ */
+static void U_CALLCONV GlyphToCharTest(void)
+{
+    LEErrorCode status = LE_NO_ERROR;
+    LEFontInstance *font;
+    FontRuns fontRuns(0);
+    ParagraphLayout *paragraphLayout;
+    const ParagraphLayout::Line *line;
+    /*
+     * This is the same text that's in <icu>/source/samples/layout/Sample.txt
+     */
+    LEUnicode chars[] = {
+        /*BOM*/ 0x0054, 0x0068, 0x0065, 0x0020, 0x004c, 0x0061, 0x0079, 
+        0x006f, 0x0075, 0x0074, 0x0045, 0x006e, 0x0067, 0x0069, 0x006e, 
+        0x0065, 0x0020, 0x0064, 0x006f, 0x0065, 0x0073, 0x0020, 0x0061, 
+        0x006c, 0x006c, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0077, 
+        0x006f, 0x0072, 0x006b, 0x0020, 0x006e, 0x0065, 0x0063, 0x0065, 
+        0x0073, 0x0073, 0x0061, 0x0072, 0x0079, 0x0020, 0x0074, 0x006f, 
+        0x0020, 0x0064, 0x0069, 0x0073, 0x0070, 0x006c, 0x0061, 0x0079, 
+        0x0020, 0x0055, 0x006e, 0x0069, 0x0063, 0x006f, 0x0064, 0x0065, 
+        0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x0020, 0x0077, 0x0072, 
+        0x0069, 0x0074, 0x0074, 0x0065, 0x006e, 0x0020, 0x0069, 0x006e, 
+        0x0020, 0x006c, 0x0061, 0x006e, 0x0067, 0x0075, 0x0061, 0x0067, 
+        0x0065, 0x0073, 0x0020, 0x0077, 0x0069, 0x0074, 0x0068, 0x0020, 
+        0x0063, 0x006f, 0x006d, 0x0070, 0x006c, 0x0065, 0x0078, 0x0020, 
+        0x0077, 0x0072, 0x0069, 0x0074, 0x0069, 0x006e, 0x0067, 0x0020, 
+        0x0073, 0x0079, 0x0073, 0x0074, 0x0065, 0x006d, 0x0073, 0x0020, 
+        0x0073, 0x0075, 0x0063, 0x0068, 0x0020, 0x0061, 0x0073, 0x0020, 
+        0x0048, 0x0069, 0x006e, 0x0064, 0x0069, 0x0020, 0x0028, 0x0939, 
+        0x093f, 0x0928, 0x094d, 0x0926, 0x0940, 0x0029, 0x0020, 0x0054, 
+        0x0068, 0x0061, 0x0069, 0x0020, 0x0028, 0x0e44, 0x0e17, 0x0e22, 
+        0x0029, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0041, 0x0072, 
+        0x0061, 0x0062, 0x0069, 0x0063, 0x0020, 0x0028, 0x0627, 0x0644, 
+        0x0639, 0x0631, 0x0628, 0x064a, 0x0629, 0x0029, 0x002e, 0x0020, 
+        0x0048, 0x0065, 0x0072, 0x0065, 0x0027, 0x0073, 0x0020, 0x0061, 
+        0x0020, 0x0073, 0x0061, 0x006d, 0x0070, 0x006c, 0x0065, 0x0020, 
+        0x006f, 0x0066, 0x0020, 0x0073, 0x006f, 0x006d, 0x0065, 0x0020, 
+        0x0074, 0x0065, 0x0078, 0x0074, 0x0020, 0x0077, 0x0072, 0x0069, 
+        0x0074, 0x0074, 0x0065, 0x006e, 0x0020, 0x0069, 0x006e, 0x0020, 
+        0x0053, 0x0061, 0x006e, 0x0073, 0x006b, 0x0072, 0x0069, 0x0074, 
+        0x003a, 0x0020, 0x0936, 0x094d, 0x0930, 0x0940, 0x092e, 0x0926, 
+        0x094d, 0x0020, 0x092d, 0x0917, 0x0935, 0x0926, 0x094d, 0x0917, 
+        0x0940, 0x0924, 0x093e, 0x0020, 0x0905, 0x0927, 0x094d, 0x092f, 
+        0x093e, 0x092f, 0x0020, 0x0905, 0x0930, 0x094d, 0x091c, 0x0941, 
+        0x0928, 0x0020, 0x0935, 0x093f, 0x0937, 0x093e, 0x0926, 0x0020, 
+        0x092f, 0x094b, 0x0917, 0x0020, 0x0927, 0x0943, 0x0924, 0x0930, 
+        0x093e, 0x0937, 0x094d, 0x091f, 0x094d, 0x0930, 0x0020, 0x0909, 
+        0x0935, 0x093e, 0x091a, 0x0964, 0x0020, 0x0927, 0x0930, 0x094d, 
+        0x092e, 0x0915, 0x094d, 0x0937, 0x0947, 0x0924, 0x094d, 0x0930, 
+        0x0947, 0x0020, 0x0915, 0x0941, 0x0930, 0x0941, 0x0915, 0x094d, 
+        0x0937, 0x0947, 0x0924, 0x094d, 0x0930, 0x0947, 0x0020, 0x0938, 
+        0x092e, 0x0935, 0x0947, 0x0924, 0x093e, 0x0020, 0x092f, 0x0941, 
+        0x092f, 0x0941, 0x0924, 0x094d, 0x0938, 0x0935, 0x0903, 0x0020, 
+        0x092e, 0x093e, 0x092e, 0x0915, 0x093e, 0x0903, 0x0020, 0x092a, 
+        0x093e, 0x0923, 0x094d, 0x0921, 0x0935, 0x093e, 0x0936, 0x094d, 
+        0x091a, 0x0948, 0x0935, 0x0020, 0x0915, 0x093f, 0x092e, 0x0915, 
+        0x0941, 0x0930, 0x094d, 0x0935, 0x0924, 0x0020, 0x0938, 0x0902, 
+        0x091c, 0x092f, 0x0020, 0x0048, 0x0065, 0x0072, 0x0065, 0x0027, 
+        0x0073, 0x0020, 0x0061, 0x0020, 0x0073, 0x0061, 0x006d, 0x0070, 
+        0x006c, 0x0065, 0x0020, 0x006f, 0x0066, 0x0020, 0x0073, 0x006f, 
+        0x006d, 0x0065, 0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x0020, 
+        0x0077, 0x0072, 0x0069, 0x0074, 0x0074, 0x0065, 0x006e, 0x0020, 
+        0x0069, 0x006e, 0x0020, 0x0041, 0x0072, 0x0061, 0x0062, 0x0069, 
+        0x0063, 0x003a, 0x0020, 0x0623, 0x0633, 0x0627, 0x0633, 0x064b, 
+        0x0627, 0x060c, 0x0020, 0x062a, 0x062a, 0x0639, 0x0627, 0x0645, 
+        0x0644, 0x0020, 0x0627, 0x0644, 0x062d, 0x0648, 0x0627, 0x0633, 
+        0x064a, 0x0628, 0x0020, 0x0641, 0x0642, 0x0637, 0x0020, 0x0645, 
+        0x0639, 0x0020, 0x0627, 0x0644, 0x0623, 0x0631, 0x0642, 0x0627, 
+        0x0645, 0x060c, 0x0020, 0x0648, 0x062a, 0x0642, 0x0648, 0x0645, 
+        0x0020, 0x0628, 0x062a, 0x062e, 0x0632, 0x064a, 0x0646, 0x0020, 
+        0x0627, 0x0644, 0x0623, 0x062d, 0x0631, 0x0641, 0x0020, 0x0648, 
+        0x0627, 0x0644, 0x0645, 0x062d, 0x0627, 0x0631, 0x0641, 0x0020, 
+        0x0627, 0x0644, 0x0623, 0x062e, 0x0631, 0x0649, 0x0020, 0x0628, 
+        0x0639, 0x062f, 0x0020, 0x0623, 0x0646, 0x0020, 0x062a, 0x064f, 
+        0x0639, 0x0637, 0x064a, 0x0020, 0x0631, 0x0642, 0x0645, 0x0627, 
+        0x0020, 0x0645, 0x0639, 0x064a, 0x0646, 0x0627, 0x0020, 0x0644, 
+        0x0643, 0x0644, 0x0020, 0x0648, 0x0627, 0x062d, 0x062f, 0x0020, 
+        0x0645, 0x0646, 0x0647, 0x0627, 0x002e, 0x0020, 0x0648, 0x0642, 
+        0x0628, 0x0644, 0x0020, 0x0627, 0x062e, 0x062a, 0x0631, 0x0627, 
+        0x0639, 0x0020, 0x0022, 0x064a, 0x0648, 0x0646, 0x0650, 0x0643, 
+        0x0648, 0x062f, 0x0022, 0x060c, 0x0020, 0x0643, 0x0627, 0x0646, 
+        0x0020, 0x0647, 0x0646, 0x0627, 0x0643, 0x0020, 0x0645, 0x0626, 
+        0x0627, 0x062a, 0x0020, 0x0627, 0x0644, 0x0623, 0x0646, 0x0638, 
+        0x0645, 0x0629, 0x0020, 0x0644, 0x0644, 0x062a, 0x0634, 0x0641, 
+        0x064a, 0x0631, 0x0020, 0x0648, 0x062a, 0x062e, 0x0635, 0x064a, 
+        0x0635, 0x0020, 0x0647, 0x0630, 0x0647, 0x0020, 0x0627, 0x0644, 
+        0x0623, 0x0631, 0x0642, 0x0627, 0x0645, 0x0020, 0x0644, 0x0644, 
+        0x0645, 0x062d, 0x0627, 0x0631, 0x0641, 0x060c, 0x0020, 0x0648, 
+        0x0644, 0x0645, 0x0020, 0x064a, 0x0648, 0x062c, 0x062f, 0x0020, 
+        0x0646, 0x0638, 0x0627, 0x0645, 0x0020, 0x062a, 0x0634, 0x0641, 
+        0x064a, 0x0631, 0x0020, 0x0648, 0x0627, 0x062d, 0x062f, 0x0020, 
+        0x064a, 0x062d, 0x062a, 0x0648, 0x064a, 0x0020, 0x0639, 0x0644, 
+        0x0649, 0x0020, 0x062c, 0x0645, 0x064a, 0x0639, 0x0020, 0x0627, 
+        0x0644, 0x0645, 0x062d, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627, 
+        0x0644, 0x0636, 0x0631, 0x0648, 0x0631, 0x064a, 0x0629, 0x0020, 
+        0x0061, 0x006e, 0x0064, 0x0020, 0x0068, 0x0065, 0x0072, 0x0065, 
+        0x0027, 0x0073, 0x0020, 0x0061, 0x0020, 0x0073, 0x0061, 0x006d, 
+        0x0070, 0x006c, 0x0065, 0x0020, 0x006f, 0x0066, 0x0020, 0x0073, 
+        0x006f, 0x006d, 0x0065, 0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 
+        0x0020, 0x0077, 0x0072, 0x0069, 0x0074, 0x0074, 0x0065, 0x006e, 
+        0x0020, 0x0069, 0x006e, 0x0020, 0x0054, 0x0068, 0x0061, 0x0069, 
+        0x003a, 0x0020, 0x0e1a, 0x0e17, 0x0e17, 0x0e35, 0x0e48, 0x0e51, 
+        0x0e1e, 0x0e32, 0x0e22, 0x0e38, 0x0e44, 0x0e0b, 0x0e42, 0x0e04, 
+        0x0e25, 0x0e19, 0x0e42, 0x0e14, 0x0e42, 0x0e23, 0x0e18, 0x0e35, 
+        0x0e2d, 0x0e32, 0x0e28, 0x0e31, 0x0e22, 0x0e2d, 0x0e22, 0x0e39, 
+        0x0e48, 0x0e17, 0x0e48, 0x0e32, 0x0e21, 0x0e01, 0x0e25, 0x0e32, 
+        0x0e07, 0x0e17, 0x0e38, 0x0e48, 0x0e07, 0x0e43, 0x0e2b, 0x0e0d, 
+        0x0e48, 0x0e43, 0x0e19, 0x0e41, 0x0e04, 0x0e19, 0x0e0b, 0x0e31, 
+        0x0e2a, 0x0e01, 0x0e31, 0x0e1a, 0x0e25, 0x0e38, 0x0e07, 0x0e40, 
+        0x0e2e, 0x0e19, 0x0e23, 0x0e35, 0x0e0a, 0x0e32, 0x0e27, 0x0e44, 
+        0x0e23, 0x0e48, 0x0e41, 0x0e25, 0x0e30, 0x0e1b, 0x0e49, 0x0e32, 
+        0x0e40, 0x0e2d, 0x0e47, 0x0e21, 0x0e20, 0x0e23, 0x0e23, 0x0e22, 
+        0x0e32, 0x0e0a, 0x0e32, 0x0e27, 0x0e44, 0x0e23, 0x0e48, 0x0e1a, 
+        0x0e49, 0x0e32, 0x0e19, 0x0e02, 0x0e2d, 0x0e07, 0x0e1e, 0x0e27, 
+        0x0e01, 0x0e40, 0x0e02, 0x0e32, 0x0e2b, 0x0e25, 0x0e31, 0x0e07, 
+        0x0e40, 0x0e25, 0x0e47, 0x0e01, 0x0e40, 0x0e1e, 0x0e23, 0x0e32, 
+        0x0e30, 0x0e44, 0x0e21, 0x0e49, 0x0e2a, 0x0e23, 0x0e49, 0x0e32, 
+        0x0e07, 0x0e1a, 0x0e49, 0x0e32, 0x0e19, 0x0e15, 0x0e49, 0x0e2d, 
+        0x0e07, 0x0e02, 0x0e19, 0x0e21, 0x0e32, 0x0e14, 0x0e49, 0x0e27, 
+        0x0e22, 0x0e40, 0x0e01, 0x0e27, 0x0e35, 0x0e22, 0x0e19, 0x0e40, 
+        0x0e1b, 0x0e47, 0x0e19, 0x0e23, 0x0e30, 0x0e22, 0x0e30, 0x0e17, 
+        0x0e32, 0x0e07, 0x0e2b, 0x0e25, 0x0e32, 0x0e22, 0x0e44, 0x0e21, 
+        0x0e25, 0x0e4c
+    };
+    le_int32 charCount = LE_ARRAY_SIZE(chars);
+    le_int32 charIndex = 0, lineNumber = 1;
+    const float lineWidth = 600;
+
+    font = new SimpleFontInstance(12, status);
+
+    if (LE_FAILURE(status)) {
+        goto finish;
+    }
+
+    fontRuns.add(font, charCount);
+
+    paragraphLayout = new ParagraphLayout(chars, charCount, &fontRuns, NULL, NULL, NULL, 0, FALSE, status);
+
+    if (LE_FAILURE(status)) {
+        goto close_font;
+    }
+
+    paragraphLayout->reflow();
+    while ((line = paragraphLayout->nextLine(lineWidth)) != NULL) {
+        le_int32 runCount = line->countRuns();
+
+        for(le_int32 run = 0; run < runCount; run += 1) {
+            const ParagraphLayout::VisualRun *visualRun = line->getVisualRun(run);
+            le_int32 glyphCount = visualRun->getGlyphCount();
+            const le_int32 *glyphToCharMap = visualRun->getGlyphToCharMap();
+
+            if (visualRun->getDirection() == UBIDI_RTL) {
+                /*
+                 * For a right to left run, make sure that the character indices
+                 * increase from the right most glyph to the left most glyph. If
+                 * there are any one to many glyph substitutions, we might get several
+                 * glyphs in a row with the same character index.
+                 */
+                for(le_int32 i = glyphCount - 1; i >= 0; i -= 1) {
+                    le_int32 ix = glyphToCharMap[i];
+
+                    if (ix != charIndex) {
+                        if (ix != charIndex - 1) {
+                            log_err("Bad glyph to char index for glyph %d on line %d: expected %d, got %d\n",
+                                i, lineNumber, charIndex, ix);
+                            goto close_paragraph; // once there's one error, we can't count on anything else...
+                        }
+                    } else {
+                        charIndex += 1;
+                    }
+                }
+            } else {
+                /*
+                 * We can't just check the order of the character indices
+                 * for left to right runs because Indic text might have been
+                 * reordered. What we can do is find the minimum and maximum
+                 * character indices in the run and make sure that the minimum
+                 * is equal to charIndex and then advance charIndex to the maximum.
+                 */
+                le_int32 minIndex = 0x7FFFFFFF, maxIndex = -1;
+
+                for(le_int32 i = 0; i < glyphCount; i += 1) {
+                    le_int32 ix = glyphToCharMap[i];
+
+                    if (ix > maxIndex) {
+                        maxIndex = ix;
+                    }
+
+                    if (ix < minIndex) {
+                        minIndex = ix;
+                    }
+                }
+
+                if (minIndex != charIndex) {
+                    log_err("Bad minIndex for run %d on line %d: expected %d, got %d\n",
+                        run, lineNumber, charIndex, minIndex);
+                    goto close_paragraph; // once there's one error, we can't count on anything else...
+                }
+
+                charIndex = maxIndex + 1;
+            }
+        }
+
+        lineNumber += 1;
+    }
+close_paragraph:
+    delete paragraphLayout;
+
+close_font:
+    delete font;
+
+finish:
+    return;
+}
+U_CDECL_END
+
+static void addAllTests(TestNode **root)
 {
-    addTest(root, &ParamTest,      "api/ParameterTest");
-    addTest(root, &FactoryTest,    "api/FactoryTest");
-    addTest(root, &AccessTest,     "layout/AccessTest");
-    addTest(root, &DataDrivenTest, "layout/DataDrivenTest");
+    addTest(root, &ScriptTest,      "api/ScriptTest");
+    addTest(root, &ParamTest,       "api/ParameterTest");
+    addTest(root, &FactoryTest,     "api/FactoryTest");
+    addTest(root, &AccessTest,      "layout/AccessTest");
+    addTest(root, &DataDrivenTest,  "layout/DataDrivenTest");
+    addTest(root, &GlyphToCharTest, "paragraph/GlyphToCharTest");
+
+    addCTests(root);
 }
 
 /* returns the path to icu/source/data/out */
@@ -734,7 +991,7 @@ static const char *ctest_dataOutDir()
     */
 #if defined (U_TOPBUILDDIR)
     {
-        dataOutDir = U_TOPBUILDDIR "data"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
+        dataOutDir = U_TOPBUILDDIR "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
     }
 #else
 
@@ -811,6 +1068,11 @@ int main(int argc, char* argv[])
 
     startTime = uprv_getUTCtime();
 
+    if (!initArgs(argc, argv, NULL, NULL)) {
+        /* Error already displayed. */
+        return -1;
+    }
+
     /* Check whether ICU will initialize without forcing the build data directory into
     *  the ICU_DATA path.  Success here means either the data dll contains data, or that
     *  this test program was run with ICU_DATA set externally.  Failure of this check
@@ -829,7 +1091,11 @@ int main(int argc, char* argv[])
     u_cleanup();
     errorCode = U_ZERO_ERROR;
 
-    /* Initialize ICU */
+    if (!initArgs(argc, argv, NULL, NULL)) {
+        /* Error already displayed. */
+        return -1;
+    }
+/* Initialize ICU */
     ctest_setICU_DATA();    /* u_setDataDirectory() must happen Before u_init() */
     u_init(&errorCode);
 
@@ -842,7 +1108,7 @@ int main(int argc, char* argv[])
     }
 
     addAllTests(&root);
-    nerrors = processArgs(root, argc, argv);
+    nerrors = runTestRequest(root, argc, argv);
 
     cleanUpTestTree(root);
     u_cleanup();