]> granicus.if.org Git - icu/commitdiff
ICU-12153 uspoof_setRestrictionLevel also must enable restriction level checking.
authorAndy Heninger <andy.heninger@gmail.com>
Tue, 7 Jun 2016 17:40:12 +0000 (17:40 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Tue, 7 Jun 2016 17:40:12 +0000 (17:40 +0000)
X-SVN-Rev: 38805

icu4c/source/test/intltest/itspoof.cpp
icu4c/source/test/intltest/itspoof.h

index 42869a738ceafe5038c54541c5c3187979802446..0a37ff79ed440d018ac22ffdf1867f00bf663ef2 100644 (file)
 
 void IntlTestSpoof::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
 {
-    if (exec) logln("TestSuite spoof: ");
-    switch (index) {
-        case 0:
-            name = "TestSpoofAPI"; 
-            if (exec) {
-                testSpoofAPI();
-            }
-            break;
-        case 1:
-            name = "TestSkeleton"; 
-            if (exec) {
-                testSkeleton();
-            }
-            break;
-        case 2:
-            name = "TestAreConfusable";
-            if (exec) {
-                testAreConfusable();
-            }
-            break;
-        case 3:
-            name = "TestInvisible";
-            if (exec) {
-                testInvisible();
-            }
-            break;
-        case 4:
-            name = "testConfData";
-            if (exec) {
-                testConfData();
-            }
-            break;
-        case 5:
-            name = "testBug8654";
-            if (exec) {
-                testBug8654();
-            }
-            break;
-        case 6:
-            name = "testIdentifierInfo";
-            if (exec) {
-                testIdentifierInfo();
-            }
-            break;
-        case 7:
-            name = "testScriptSet";
-            if (exec) {
-                testScriptSet();
-            }
-            break;
-        case 8:
-            name = "testRestrictionLevel";
-            if (exec) {
-                testRestrictionLevel();
-            }
-            break;
-       case 9:
-            name = "testMixedNumbers";
-            if (exec) {
-                testMixedNumbers();
-            }
-            break;
-
-
-        default: name=""; break;
+    if (exec) {
+        logln("TestSuite spoof: ");
     }
+    TESTCASE_AUTO_BEGIN;
+    TESTCASE_AUTO(testSpoofAPI);
+    TESTCASE_AUTO(testSkeleton);
+    TESTCASE_AUTO(testAreConfusable);
+    TESTCASE_AUTO(testInvisible);
+    TESTCASE_AUTO(testConfData);
+    TESTCASE_AUTO(testBug8654);
+    TESTCASE_AUTO(testIdentifierInfo);
+    TESTCASE_AUTO(testScriptSet);
+    TESTCASE_AUTO(testRestrictionLevel);
+    TESTCASE_AUTO(testMixedNumbers);
+    TESTCASE_AUTO(testBug12153);
+    TESTCASE_AUTO_END;
 }
 
 void IntlTestSpoof::testSpoofAPI() {
@@ -768,4 +718,23 @@ void IntlTestSpoof::testMixedNumbers() {
     }
 }
 
+// Bug #12153 - uspoof_setRestrictionLevel() should enable restriction level testing.
+// 
+void IntlTestSpoof::testBug12153() {
+    UErrorCode status = U_ZERO_ERROR;
+    LocalUSpoofCheckerPointer sc(uspoof_open(&status));
+    TEST_ASSERT_SUCCESS(status);
+    int32_t checks = uspoof_getChecks(sc.getAlias(), &status);
+    TEST_ASSERT((checks & USPOOF_RESTRICTION_LEVEL) != 0);
+    checks &= ~USPOOF_RESTRICTION_LEVEL;
+    uspoof_setChecks(sc.getAlias(), checks, &status);
+    checks = uspoof_getChecks(sc.getAlias(), &status);
+    TEST_ASSERT((checks & USPOOF_RESTRICTION_LEVEL) == 0);
+
+    uspoof_setRestrictionLevel(sc.getAlias(), USPOOF_MODERATELY_RESTRICTIVE);
+    checks = uspoof_getChecks(sc.getAlias(), &status);
+    TEST_ASSERT((checks & USPOOF_RESTRICTION_LEVEL) != 0);
+    TEST_ASSERT_SUCCESS(status);
+}
+
 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS && !UCONFIG_NO_NORMALIZATION && !UCONFIG_NO_FILE_IO */
index a92c2ef48b2be53b9037c0e7d2c0f4e2d1ed45c6..829e597f0943a7387b6f94705b18618909c264b3 100644 (file)
@@ -44,6 +44,8 @@ public:
 
     void testMixedNumbers();
 
+    void testBug12153();
+
     // Internal function to run a single skeleton test case.
     void  checkSkeleton(const USpoofChecker *sc, uint32_t flags, 
                         const char *input, const char *expected, int32_t lineNum);