]> granicus.if.org Git - icu/commitdiff
ICU-12549 Test coverage for SpoofChecker. Actually removing IdentifierInfo class.
authorShane Carr <shane@unicode.org>
Wed, 14 Sep 2016 22:05:04 +0000 (22:05 +0000)
committerShane Carr <shane@unicode.org>
Wed, 14 Sep 2016 22:05:04 +0000 (22:05 +0000)
X-SVN-Rev: 39225

icu4j/coverage-exclusion.txt
icu4j/main/tests/core/src/com/ibm/icu/dev/test/text/SpoofCheckerTest.java

index 751ace6a03947e4f8fda94f39dde60ab0b316dbb..56dd437418a418d7a9e9361d656a1ef2509274b4 100644 (file)
@@ -949,13 +949,9 @@ com/ibm/icu/text/SimpleDateFormat#subFormat:(CIILjava/text/FieldPosition;Lcom/ib
 com/ibm/icu/text/SimpleDateFormat#subParse:(Ljava/lang/String;ICIZZ[ZLcom/ibm/icu/util/Calendar;)I
 com/ibm/icu/text/SimpleDateFormat$ContextValue#valueOf:(Ljava/lang/String;)Lcom/ibm/icu/text/SimpleDateFormat$ContextValue;
 com/ibm/icu/text/SimpleDateFormat$ContextValue#values:()[Lcom/ibm/icu/text/SimpleDateFormat$ContextValue;
-com/ibm/icu/text/SpoofChecker#getRestrictionLevel:()Lcom/ibm/icu/text/SpoofChecker$RestrictionLevel;
-com/ibm/icu/text/SpoofChecker#hashCode:()I
-com/ibm/icu/text/SpoofChecker$Builder#<init>:(Lcom/ibm/icu/text/SpoofChecker;)V
-com/ibm/icu/text/SpoofChecker$Builder$WSConfusableDataBuilder#<init>:()V
-com/ibm/icu/text/SpoofChecker$ScriptSet#output:(Ljava/io/DataOutputStream;)V
-com/ibm/icu/text/SpoofChecker$ScriptSet#resetAll:()V
-com/ibm/icu/text/SpoofChecker$ScriptSet#Union:(Lcom/ibm/icu/text/SpoofChecker$ScriptSet;)V
+com/ibm/icu/text/SpoofChecker$Builder#<init>:(Lcom/ibm/icu/text/SpoofChecker;)Vcom/ibm/icu/text/SpoofChecker$ConfusableDataUtils#<init>:()V
+com/ibm/icu/text/SpoofChecker$ConfusableDataUtils#<init>:()V
+com/ibm/icu/text/SpoofChecker$RestrictionLevel#valueOf:(Ljava/lang/String;)Lcom/ibm/icu/text/SpoofChecker$RestrictionLevel;
 com/ibm/icu/text/SpoofChecker$SpoofData$DefaultData#<init>:()V
 com/ibm/icu/text/StringCharacterIterator#equals:(Ljava/lang/Object;)Z
 com/ibm/icu/text/StringCharacterIterator#first:()C
@@ -1127,3 +1123,4 @@ com/ibm/icu/util/UResourceBundle$RootType#valueOf:(Ljava/lang/String;)Lcom/ibm/i
 com/ibm/icu/util/VersionInfo#getVersionString:(II)Ljava/lang/String;
 com/ibm/icu/util/VersionInfo#main:([Ljava/lang/String;)V
 com/ibm/icu/util/VTimeZone#observesDaylightTime:()Z
+
index f42c8c5469c9a10bb68688a1903dba47a2d917f4..9c58ba3666b605e2f301896e29b3f4f22c2c3883 100644 (file)
@@ -12,7 +12,11 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.Reader;
 import java.io.StringReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.text.ParseException;
+import java.util.BitSet;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.Locale;
@@ -26,6 +30,7 @@ import com.ibm.icu.dev.test.TestFmwk;
 import com.ibm.icu.dev.test.TestUtil;
 import com.ibm.icu.dev.test.TestUtil.JavaVendor;
 import com.ibm.icu.impl.Utility;
+import com.ibm.icu.lang.UScript;
 import com.ibm.icu.text.Normalizer2;
 import com.ibm.icu.text.SpoofChecker;
 import com.ibm.icu.text.SpoofChecker.CheckResult;
@@ -585,6 +590,10 @@ public class SpoofCheckerTest extends TestFmwk {
                 boolean expectedFailure = expectedLevel.compareTo(levelSetInSpoofChecker) > 0;
                 assertEquals("Testing spoof restriction level for '" + testString + "', " + levelSetInSpoofChecker,
                         expectedFailure, actualValue);
+
+                // Coverage for getRestrictionLevel
+                assertEquals("Restriction level on built SpoofChecker should be same as on builder",
+                        levelSetInSpoofChecker, sc.getRestrictionLevel());
             }
         }
     }
@@ -775,4 +784,49 @@ public class SpoofCheckerTest extends TestFmwk {
         }
     }
 
+    @Test
+    public void testScriptSet() {
+        try {
+            Class ScriptSet = Class.forName("com.ibm.icu.text.SpoofChecker$ScriptSet");
+            Constructor ctor = ScriptSet.getDeclaredConstructor();
+            ctor.setAccessible(true);
+            BitSet ss = (BitSet) ctor.newInstance();
+
+            ss.set(UScript.MYANMAR);
+            assertEquals("ScriptSet toString with Myanmar", "<ScriptSet { Mymr }>", ss.toString());
+            ss.set(UScript.BENGALI);
+            ss.set(UScript.LATIN);
+            assertEquals("ScriptSet toString with Myanmar, Latin, and Bengali", "<ScriptSet { Beng Latn Mymr }>", ss.toString());
+
+            Method and = ScriptSet.getDeclaredMethod("and", Integer.TYPE);
+            and.setAccessible(true);
+            and.invoke(ss, UScript.BENGALI);
+            assertEquals("ScriptSet toString with Bengali only", "<ScriptSet { Beng }>", ss.toString());
+
+            Method setAll = ScriptSet.getDeclaredMethod("setAll");
+            setAll.setAccessible(true);
+            setAll.invoke(ss);
+            assertEquals("ScriptSet toString with all scripts", "<ScriptSet { * }>", ss.toString());
+
+            Method isFull = ScriptSet.getDeclaredMethod("isFull");
+            isFull.setAccessible(true);
+            boolean result = (Boolean) isFull.invoke(ss);
+            assertEquals("ScriptSet should evaluate as full", true, result);
+
+        } catch (ClassNotFoundException e) {
+            fail("Failed while testing ScriptSet: " + e.getClass() + ": " + e.getMessage());
+        } catch (InstantiationException e) {
+            fail("Failed while testing ScriptSet: " + e.getClass() + ": " + e.getMessage());
+        } catch (IllegalAccessException e) {
+            fail("Failed while testing ScriptSet: " + e.getClass() + ": " + e.getMessage());
+        } catch (SecurityException e) {
+            fail("Failed while testing ScriptSet: " + e.getClass() + ": " + e.getMessage());
+        } catch (NoSuchMethodException e) {
+            fail("Failed while testing ScriptSet: " + e.getClass() + ": " + e.getMessage());
+        } catch (IllegalArgumentException e) {
+            fail("Failed while testing ScriptSet: " + e.getClass() + ": " + e.getMessage());
+        } catch (InvocationTargetException e) {
+            fail("Failed while testing ScriptSet: " + e.getClass() + ": " + e.getMessage());
+        }
+    }
 }