From 3e9165477ee24ef4d42c38e5b2235e28321a5c47 Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Tue, 18 Jul 2000 18:21:27 +0000 Subject: [PATCH] Add test for zero-index combining char problem X-SVN-Rev: 1930 --- .../icu/dev/test/normalizer/BasicTest.java | 61 ++++++++++++++++--- .../com/ibm/test/normalizer/BasicTest.java | 61 ++++++++++++++++--- 2 files changed, 102 insertions(+), 20 deletions(-) diff --git a/icu4j/src/com/ibm/icu/dev/test/normalizer/BasicTest.java b/icu4j/src/com/ibm/icu/dev/test/normalizer/BasicTest.java index 8695fadfe3..9aacb84ad3 100755 --- a/icu4j/src/com/ibm/icu/dev/test/normalizer/BasicTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/normalizer/BasicTest.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/normalizer/BasicTest.java,v $ - * $Date: 2000/07/13 21:33:57 $ - * $Revision: 1.4 $ + * $Date: 2000/07/18 18:21:27 $ + * $Revision: 1.5 $ * ***************************************************************************************** */ @@ -58,6 +58,8 @@ public class BasicTest extends TestFmwk { { "\uFF76\uFF9E", "\uFF76\uFF9E", "\uFF76\uFF9E" }, // hw_ka + hw_ten { "\u30AB\uFF9E", "\u30AB\uFF9E", "\u30AB\uFF9E" }, // ka + hw_ten { "\uFF76\u3099", "\uFF76\u3099", "\uFF76\u3099" }, // hw_ka + ten + + { "A\u0300\u0316", "A\u0316\u0300", "\u00C0\u0316" }, }; String[][] compatTests = { @@ -300,6 +302,39 @@ public class BasicTest extends TestFmwk { // } } + public void TestComposeCompat() { + String[] DATA = { + // Expect col1 x COMPOSE_COMPAT => col2 + // Expect col2 x DECOMP => col3 + "A\u0316\u0300", "\u00C0\u0316", "A\u0316\u0300", + "A\u0300\u0316", "\u00C0\u0316", "A\u0316\u0300", + "\u00C0\u0316", "\u00C0\u0316", "A\u0316\u0300", + "A\u0300", "\u00C0", "A\u0300", + "A\u0327\u0300", "\u00C0\u0327", "A\u0327\u0300", + "c\u0321\u0327", "c\u0321\u0327", "c\u0321\u0327", + }; + + for (int i=0; i " + hex(b)); + } else { + errln("FAIL: " + hex(a) + " x COMPOSE_COMPAT => " + hex(b) + + ", expect " + hex(exp)); + } + a = Normalizer.normalize(b, Normalizer.DECOMP, 0); + exp = DATA[i+2]; + if (a.equals(exp)) { + logln("Ok: " + hex(b) + " x DECOMP => " + hex(a)); + } else { + errln("FAIL: " + hex(b) + " x DECOMP => " + hex(a) + + ", expect " + hex(exp)); + } + } + } + //------------------------------------------------------------------------ // Internal utilities // @@ -321,7 +356,10 @@ public class BasicTest extends TestFmwk { } if (!forward.toString().equals(reverse.toString())) { - errln("Forward/reverse mismatch for input " + hex(input) + errln("FAIL: Forward/reverse mismatch for input " + hex(input) + + ", forward: " + hex(forward) + ", backward: " + hex(reverse)); + } else if (isVerbose()) { + logln("Ok: Forward/reverse for input " + hex(input) + ", forward: " + hex(forward) + ", backward: " + hex(reverse)); } } @@ -345,8 +383,11 @@ public class BasicTest extends TestFmwk { } if (!forward.toString().equals(reverse.toString())) { - errln("Forward/reverse mismatch for input " + hex(tests[i][0]) + errln("FAIL: Forward/reverse mismatch for input " + hex(tests[i][0]) + ", forward: " + hex(forward) + ", backward: " + hex(reverse)); + } else if (isVerbose()) { + logln("Ok: Forward/reverse for input " + hex(tests[i][0]) + + ", forward: " + hex(forward) + ", backward: " + hex(reverse)); } } } @@ -363,7 +404,7 @@ public class BasicTest extends TestFmwk { String output = Normalizer.normalize(input, mode, options); if (!output.equals(expect)) { - errln("ERROR: case " + i + errln("FAIL: case " + i + " expected '" + expect + "' (" + hex(expect) + ")" + " but got '" + output + "' (" + hex(output) + ")" ); } @@ -380,30 +421,30 @@ public class BasicTest extends TestFmwk { logln("Normalizing '" + input + "' (" + hex(input) + ")" ); iter.setText(input); - assertEqual(expect, iter, "ERROR: case " + i + " "); + assertEqual(expect, iter, "case " + i + " "); } } - private void assertEqual(String expected, Normalizer iter, String errPrefix) + private void assertEqual(String expected, Normalizer iter, String msg) { int index = 0; for (char ch = iter.first(); ch != iter.DONE; ch = iter.next()) { if (index >= expected.length()) { - errln(errPrefix + "Unexpected character '" + ch + "' (" + hex(ch) + ")" + errln("FAIL: " + msg + "Unexpected character '" + ch + "' (" + hex(ch) + ")" + " at index " + index); break; } char want = expected.charAt(index); if (ch != want) { - errln(errPrefix + "got '" + ch + "' (" + hex(ch) + ")" + errln("FAIL: " + msg + "got '" + ch + "' (" + hex(ch) + ")" + " but expected '" + want + "' (" + hex(want) + ")" + " at index " + index); } index++; } if (index < expected.length()) { - errln(errPrefix + "Only got " + index + " chars, expected " + expected.length()); + errln("FAIL: " + msg + "Only got " + index + " chars, expected " + expected.length()); } } } diff --git a/icu4j/src/com/ibm/test/normalizer/BasicTest.java b/icu4j/src/com/ibm/test/normalizer/BasicTest.java index e7d379e7de..c82e617512 100755 --- a/icu4j/src/com/ibm/test/normalizer/BasicTest.java +++ b/icu4j/src/com/ibm/test/normalizer/BasicTest.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/test/normalizer/Attic/BasicTest.java,v $ - * $Date: 2000/07/13 21:33:57 $ - * $Revision: 1.4 $ + * $Date: 2000/07/18 18:21:27 $ + * $Revision: 1.5 $ * ***************************************************************************************** */ @@ -58,6 +58,8 @@ public class BasicTest extends TestFmwk { { "\uFF76\uFF9E", "\uFF76\uFF9E", "\uFF76\uFF9E" }, // hw_ka + hw_ten { "\u30AB\uFF9E", "\u30AB\uFF9E", "\u30AB\uFF9E" }, // ka + hw_ten { "\uFF76\u3099", "\uFF76\u3099", "\uFF76\u3099" }, // hw_ka + ten + + { "A\u0300\u0316", "A\u0316\u0300", "\u00C0\u0316" }, }; String[][] compatTests = { @@ -300,6 +302,39 @@ public class BasicTest extends TestFmwk { // } } + public void TestComposeCompat() { + String[] DATA = { + // Expect col1 x COMPOSE_COMPAT => col2 + // Expect col2 x DECOMP => col3 + "A\u0316\u0300", "\u00C0\u0316", "A\u0316\u0300", + "A\u0300\u0316", "\u00C0\u0316", "A\u0316\u0300", + "\u00C0\u0316", "\u00C0\u0316", "A\u0316\u0300", + "A\u0300", "\u00C0", "A\u0300", + "A\u0327\u0300", "\u00C0\u0327", "A\u0327\u0300", + "c\u0321\u0327", "c\u0321\u0327", "c\u0321\u0327", + }; + + for (int i=0; i " + hex(b)); + } else { + errln("FAIL: " + hex(a) + " x COMPOSE_COMPAT => " + hex(b) + + ", expect " + hex(exp)); + } + a = Normalizer.normalize(b, Normalizer.DECOMP, 0); + exp = DATA[i+2]; + if (a.equals(exp)) { + logln("Ok: " + hex(b) + " x DECOMP => " + hex(a)); + } else { + errln("FAIL: " + hex(b) + " x DECOMP => " + hex(a) + + ", expect " + hex(exp)); + } + } + } + //------------------------------------------------------------------------ // Internal utilities // @@ -321,7 +356,10 @@ public class BasicTest extends TestFmwk { } if (!forward.toString().equals(reverse.toString())) { - errln("Forward/reverse mismatch for input " + hex(input) + errln("FAIL: Forward/reverse mismatch for input " + hex(input) + + ", forward: " + hex(forward) + ", backward: " + hex(reverse)); + } else if (isVerbose()) { + logln("Ok: Forward/reverse for input " + hex(input) + ", forward: " + hex(forward) + ", backward: " + hex(reverse)); } } @@ -345,8 +383,11 @@ public class BasicTest extends TestFmwk { } if (!forward.toString().equals(reverse.toString())) { - errln("Forward/reverse mismatch for input " + hex(tests[i][0]) + errln("FAIL: Forward/reverse mismatch for input " + hex(tests[i][0]) + ", forward: " + hex(forward) + ", backward: " + hex(reverse)); + } else if (isVerbose()) { + logln("Ok: Forward/reverse for input " + hex(tests[i][0]) + + ", forward: " + hex(forward) + ", backward: " + hex(reverse)); } } } @@ -363,7 +404,7 @@ public class BasicTest extends TestFmwk { String output = Normalizer.normalize(input, mode, options); if (!output.equals(expect)) { - errln("ERROR: case " + i + errln("FAIL: case " + i + " expected '" + expect + "' (" + hex(expect) + ")" + " but got '" + output + "' (" + hex(output) + ")" ); } @@ -380,30 +421,30 @@ public class BasicTest extends TestFmwk { logln("Normalizing '" + input + "' (" + hex(input) + ")" ); iter.setText(input); - assertEqual(expect, iter, "ERROR: case " + i + " "); + assertEqual(expect, iter, "case " + i + " "); } } - private void assertEqual(String expected, Normalizer iter, String errPrefix) + private void assertEqual(String expected, Normalizer iter, String msg) { int index = 0; for (char ch = iter.first(); ch != iter.DONE; ch = iter.next()) { if (index >= expected.length()) { - errln(errPrefix + "Unexpected character '" + ch + "' (" + hex(ch) + ")" + errln("FAIL: " + msg + "Unexpected character '" + ch + "' (" + hex(ch) + ")" + " at index " + index); break; } char want = expected.charAt(index); if (ch != want) { - errln(errPrefix + "got '" + ch + "' (" + hex(ch) + ")" + errln("FAIL: " + msg + "got '" + ch + "' (" + hex(ch) + ")" + " but expected '" + want + "' (" + hex(want) + ")" + " at index " + index); } index++; } if (index < expected.length()) { - errln(errPrefix + "Only got " + index + " chars, expected " + expected.length()); + errln("FAIL: " + msg + "Only got " + index + " chars, expected " + expected.length()); } } }