-//##header\r
-//#if defined(FOUNDATION10) || defined(J2SE13)\r
-//#else\r
-/*\r
- *******************************************************************************\r
- * Copyright (C) 1996-2009, International Business Machines Corporation and *\r
- * others. All Rights Reserved. *\r
- *******************************************************************************\r
- */\r
-package com.ibm.icu.dev.test.translit;\r
-\r
-import com.ibm.icu.dev.test.*;\r
-import com.ibm.icu.dev.test.util.UnicodeMap;\r
-import com.ibm.icu.impl.Utility;\r
-import java.util.*;\r
-\r
-/**\r
- * @test\r
- * @summary General test of UnicodeSet\r
- */\r
-public class UnicodeMapTest extends TestFmwk {\r
- \r
- static final int MODIFY_TEST_LIMIT = 32;\r
- static final int MODIFY_TEST_ITERATIONS = 100000;\r
- \r
- public static void main(String[] args) throws Exception {\r
- new UnicodeMapTest().run(args);\r
- }\r
- \r
- public void TestModify() {\r
- Random random = new Random(0);\r
- UnicodeMap unicodeMap = new UnicodeMap();\r
- HashMap hashMap = new HashMap();\r
- String[] values = {null, "the", "quick", "brown", "fox"};\r
- for (int count = 1; count <= MODIFY_TEST_ITERATIONS; ++count) {\r
- String value = values[random.nextInt(values.length)];\r
- int start = random.nextInt(MODIFY_TEST_LIMIT); // test limited range\r
- int end = random.nextInt(MODIFY_TEST_LIMIT);\r
- if (start > end) {\r
- int temp = start;\r
- start = end;\r
- end = temp;\r
- }\r
- int modCount = count & 0xFF;\r
- if (modCount == 0 && isVerbose()) {\r
- logln("***"+count);\r
- logln(unicodeMap.toString());\r
- }\r
- unicodeMap.putAll(start, end, value);\r
- if (modCount == 1 && isVerbose()) {\r
- logln(">>>\t" + Utility.hex(start) + ".." + Utility.hex(end) + "\t" + value);\r
- logln(unicodeMap.toString());\r
- }\r
- for (int i = start; i <= end; ++i) {\r
- hashMap.put(new Integer(i), value);\r
- }\r
- if (!hasSameValues(unicodeMap, hashMap)) {\r
- errln("Failed at " + count);\r
- }\r
- }\r
- }\r
-\r
- private boolean hasSameValues(UnicodeMap unicodeMap, HashMap hashMap) {\r
- for (int i = 0; i < MODIFY_TEST_LIMIT; ++i) {\r
- Object unicodeMapValue = unicodeMap.getValue(i);\r
- Object hashMapValue = hashMap.get(new Integer(i));\r
- if (unicodeMapValue != hashMapValue) {\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-}\r
-//#endif\r
+//##header J2SE15
+//#if defined(FOUNDATION10) || defined(J2SE13)
+//#else
+/*
+ *******************************************************************************
+ * Copyright (C) 1996-2009, International Business Machines Corporation and *
+ * others. All Rights Reserved. *
+ *******************************************************************************
+ */
+package com.ibm.icu.dev.test.translit;
+
+import com.ibm.icu.dev.test.*;
+import com.ibm.icu.dev.test.util.UnicodeMap;
+import com.ibm.icu.impl.Utility;
+import java.util.*;
+
+/**
+ * @test
+ * @summary General test of UnicodeSet
+ */
+public class UnicodeMapTest extends TestFmwk {
+
+ static final int MODIFY_TEST_LIMIT = 32;
+ static final int MODIFY_TEST_ITERATIONS = 100000;
+
+ public static void main(String[] args) throws Exception {
+ new UnicodeMapTest().run(args);
+ }
+
+ public void TestModify() {
+ Random random = new Random(0);
+ UnicodeMap unicodeMap = new UnicodeMap();
+ HashMap hashMap = new HashMap();
+ String[] values = {null, "the", "quick", "brown", "fox"};
+ for (int count = 1; count <= MODIFY_TEST_ITERATIONS; ++count) {
+ String value = values[random.nextInt(values.length)];
+ int start = random.nextInt(MODIFY_TEST_LIMIT); // test limited range
+ int end = random.nextInt(MODIFY_TEST_LIMIT);
+ if (start > end) {
+ int temp = start;
+ start = end;
+ end = temp;
+ }
+ int modCount = count & 0xFF;
+ if (modCount == 0 && isVerbose()) {
+ logln("***"+count);
+ logln(unicodeMap.toString());
+ }
+ unicodeMap.putAll(start, end, value);
+ if (modCount == 1 && isVerbose()) {
+ logln(">>>\t" + Utility.hex(start) + ".." + Utility.hex(end) + "\t" + value);
+ logln(unicodeMap.toString());
+ }
+ for (int i = start; i <= end; ++i) {
+ hashMap.put(new Integer(i), value);
+ }
+ if (!hasSameValues(unicodeMap, hashMap)) {
+ errln("Failed at " + count);
+ }
+ }
+ }
+
+ private boolean hasSameValues(UnicodeMap unicodeMap, HashMap hashMap) {
+ for (int i = 0; i < MODIFY_TEST_LIMIT; ++i) {
+ Object unicodeMapValue = unicodeMap.getValue(i);
+ Object hashMapValue = hashMap.get(new Integer(i));
+ if (unicodeMapValue != hashMapValue) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
+//#endif