diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2019-03-11 11:16:28 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2019-03-11 11:16:28 -0700 |
commit | c5521738b0ef033bf7b28ffba1885a6d23a8ebca (patch) | |
tree | d1b63cdd08900858da6b0795f4696b2cfa9df452 | |
parent | a4d9cc461174336c1af64a82a96efcb2a8bd62a0 (diff) | |
parent | c6aa8e95a64b1c6e0d945febe8f1b0480ed7361e (diff) | |
download | icu-c5521738b0ef033bf7b28ffba1885a6d23a8ebca.tar.gz |
DO NOT MERGE - Merge PPRL.190305.001 into masterandroid-q-preview-1android-o-mr1-iot-release-1.0.10
Bug: 127812889
Change-Id: I0d2081468576af5285eec5fb38a12d8fe58634f8
-rw-r--r-- | android_icu4j/src/main/tests/android/icu/dev/test/translit/UnicodeMapTest.java | 30 | ||||
-rw-r--r-- | icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java | 30 |
2 files changed, 26 insertions, 34 deletions
diff --git a/android_icu4j/src/main/tests/android/icu/dev/test/translit/UnicodeMapTest.java b/android_icu4j/src/main/tests/android/icu/dev/test/translit/UnicodeMapTest.java index 89e9d9535..ba55ee909 100644 --- a/android_icu4j/src/main/tests/android/icu/dev/test/translit/UnicodeMapTest.java +++ b/android_icu4j/src/main/tests/android/icu/dev/test/translit/UnicodeMapTest.java @@ -346,33 +346,28 @@ public class UnicodeMapTest extends TestFmwk { checkNext(map1, map2, LIMIT); } + private static final int SET_LIMIT = 0x10FFFF; private static final int propEnum = UProperty.GENERAL_CATEGORY; @Test public void TestUnicodeMapGeneralCategory() { logln("Setting General Category"); - UnicodeMap<String> map1 = new UnicodeMap(); - Map<Integer, String> map2 = new HashMap<Integer, String>(); - //Map<Integer, String> map3 = new TreeMap<Integer, String>(); - map1 = new UnicodeMap<String>(); - map2 = new TreeMap<Integer,String>(); - for (int cp = 0;;) { + // Android patch begin. b/79168307 Reduce the heap memory needed for the test + splitTestUnicodeMapGeneralCategory(0, SET_LIMIT / 2); + splitTestUnicodeMapGeneralCategory(SET_LIMIT / 2 + 1, SET_LIMIT); + // Android patch end. b/79168307 Reduce the heap memory needed for the test + } + + // Android patch begin. b/79168307 Reduce the heap memory needed for the test + private void splitTestUnicodeMapGeneralCategory(int startCodePoint, int endCodePoint) { + UnicodeMap<String> map1 = new UnicodeMap<String>(); + Map<Integer, String> map2 = new TreeMap<Integer,String>(); + for (int cp = startCodePoint; cp <= endCodePoint; ++cp) { int enumValue = UCharacter.getIntPropertyValue(cp, propEnum); //if (enumValue <= 0) continue; // for smaller set String value = UCharacter.getPropertyValueName(propEnum,enumValue, UProperty.NameChoice.LONG); map1.put(cp, value); map2.put(cp, value); - cp++; - // Unicode is huge, skip over large parts of it. - if (cp == 0x08FF) { // General Scripts Area. - cp = 0xD700; // Hangul Syllables Area. - } else if (cp == 0x100FF) { // General Scripts Area. - cp = 0x1F000; // Symbols Area. - } else if (cp == 0x200FF) { // CJK Unified Ideographs Extensions. - cp = 0x10FF00; // Supplementary Private Use Area-B. - } else if (cp == 0x10FFFF) { // The end of Unicode. - break; - } } checkNext(map1, map2, Integer.MAX_VALUE); @@ -395,6 +390,7 @@ public class UnicodeMapTest extends TestFmwk { } } } + // Android patch end. b/79168307 Reduce the heap memory needed for the test @Test public void TestAUnicodeMap2() { diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java index 00383048d..34346d1fd 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java @@ -343,33 +343,28 @@ public class UnicodeMapTest extends TestFmwk { checkNext(map1, map2, LIMIT); } + private static final int SET_LIMIT = 0x10FFFF; private static final int propEnum = UProperty.GENERAL_CATEGORY; @Test public void TestUnicodeMapGeneralCategory() { logln("Setting General Category"); - UnicodeMap<String> map1 = new UnicodeMap(); - Map<Integer, String> map2 = new HashMap<Integer, String>(); - //Map<Integer, String> map3 = new TreeMap<Integer, String>(); - map1 = new UnicodeMap<String>(); - map2 = new TreeMap<Integer,String>(); - for (int cp = 0;;) { + // Android patch begin. b/79168307 Reduce the heap memory needed for the test + splitTestUnicodeMapGeneralCategory(0, SET_LIMIT / 2); + splitTestUnicodeMapGeneralCategory(SET_LIMIT / 2 + 1, SET_LIMIT); + // Android patch end. b/79168307 Reduce the heap memory needed for the test + } + + // Android patch begin. b/79168307 Reduce the heap memory needed for the test + private void splitTestUnicodeMapGeneralCategory(int startCodePoint, int endCodePoint) { + UnicodeMap<String> map1 = new UnicodeMap<String>(); + Map<Integer, String> map2 = new TreeMap<Integer,String>(); + for (int cp = startCodePoint; cp <= endCodePoint; ++cp) { int enumValue = UCharacter.getIntPropertyValue(cp, propEnum); //if (enumValue <= 0) continue; // for smaller set String value = UCharacter.getPropertyValueName(propEnum,enumValue, UProperty.NameChoice.LONG); map1.put(cp, value); map2.put(cp, value); - cp++; - // Unicode is huge, skip over large parts of it. - if (cp == 0x08FF) { // General Scripts Area. - cp = 0xD700; // Hangul Syllables Area. - } else if (cp == 0x100FF) { // General Scripts Area. - cp = 0x1F000; // Symbols Area. - } else if (cp == 0x200FF) { // CJK Unified Ideographs Extensions. - cp = 0x10FF00; // Supplementary Private Use Area-B. - } else if (cp == 0x10FFFF) { // The end of Unicode. - break; - } } checkNext(map1, map2, Integer.MAX_VALUE); @@ -392,6 +387,7 @@ public class UnicodeMapTest extends TestFmwk { } } } + // Android patch end. b/79168307 Reduce the heap memory needed for the test @Test public void TestAUnicodeMap2() { |