From b8aabec51fbbab5c02c4c49f25f37e5084b583a9 Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Tue, 7 Jun 2016 17:40:12 +0000 Subject: [PATCH] ICU-12153 uspoof_setRestrictionLevel also must enable restriction level checking. X-SVN-Rev: 38805 --- icu4c/source/test/intltest/itspoof.cpp | 99 +++++++++----------------- icu4c/source/test/intltest/itspoof.h | 2 + 2 files changed, 36 insertions(+), 65 deletions(-) diff --git a/icu4c/source/test/intltest/itspoof.cpp b/icu4c/source/test/intltest/itspoof.cpp index 42869a738ce..0a37ff79ed4 100644 --- a/icu4c/source/test/intltest/itspoof.cpp +++ b/icu4c/source/test/intltest/itspoof.cpp @@ -69,72 +69,22 @@ 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 */ diff --git a/icu4c/source/test/intltest/itspoof.h b/icu4c/source/test/intltest/itspoof.h index a92c2ef48b2..829e597f094 100644 --- a/icu4c/source/test/intltest/itspoof.h +++ b/icu4c/source/test/intltest/itspoof.h @@ -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); -- 2.40.0