From 5c446f1b622dff18db0cc46dfaf894c994d36016 Mon Sep 17 00:00:00 2001 From: wh0 Date: Sun, 15 Feb 2015 19:56:32 -0800 Subject: [PATCH 1/2] adjust UnicodeSupport.mergePairs logic when we reach the end of one array, copy the rest of the other and return --- .../java/org/teavm/classlib/impl/unicode/UnicodeSupport.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/impl/unicode/UnicodeSupport.java b/teavm-classlib/src/main/java/org/teavm/classlib/impl/unicode/UnicodeSupport.java index 225d6d2ae..296b99b0c 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/impl/unicode/UnicodeSupport.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/impl/unicode/UnicodeSupport.java @@ -144,12 +144,12 @@ public class UnicodeSupport { int j = 0; int t = 0; while (true) { - if (i == a.length) { + if (j == b.length) { while (i < a.length) { result[t++] = a[i++]; } break; - } else if (j == b.length) { + } else if (i == a.length) { while (j < b.length) { result[t++] = b[j++]; } From ed001cf25d6737303cd1eb30afdeed0a19dfd5a8 Mon Sep 17 00:00:00 2001 From: wh0 Date: Tue, 17 Feb 2015 13:50:57 -0800 Subject: [PATCH 2/2] add test for mergePairs --- .../impl/unicode/UnicodeSupportTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 teavm-classlib/src/test/java/org/teavm/classlib/impl/unicode/UnicodeSupportTest.java diff --git a/teavm-classlib/src/test/java/org/teavm/classlib/impl/unicode/UnicodeSupportTest.java b/teavm-classlib/src/test/java/org/teavm/classlib/impl/unicode/UnicodeSupportTest.java new file mode 100644 index 000000000..802e0e123 --- /dev/null +++ b/teavm-classlib/src/test/java/org/teavm/classlib/impl/unicode/UnicodeSupportTest.java @@ -0,0 +1,20 @@ +package org.teavm.classlib.impl.unicode; + +import static org.junit.Assert.assertFalse; + +public class UnicodeSupportTest { + + private static boolean pairsEqual(final int[] pairs, final int index1, final int index2) { + return pairs[index1] == pairs[index2] && pairs[index1 + 1] == pairs[index2 + 1]; + } + + @Test + public void test_getDigitValues() { + final int[] digitValues = UnicodeSupport.getDigitValues(); + if (digitValues.length >= 4) { + // there are no duplicates, so the last two pairs should not be identical + assertFalse(pairsEqual(digitValues, digitValues.length - 4, digitValues.length - 2)); + } + } + +}