]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/ucdtest.cpp
ICU-62107.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / ucdtest.cpp
index 73dd74e9f19409eff212e489b7f19deeb3606427..8381cf8c3fe108a00b85eae46cbe8c9217ed1e10 100644 (file)
@@ -62,6 +62,8 @@ void UnicodeTest::runIndexedTest( int32_t index, UBool exec, const char* &name,
     TESTCASE_AUTO(TestScriptMetadata);
     TESTCASE_AUTO(TestBidiPairedBracketType);
     TESTCASE_AUTO(TestEmojiProperties);
+    TESTCASE_AUTO(TestDefaultScriptExtensions);
+    TESTCASE_AUTO(TestInvalidCodePointFolding);
     TESTCASE_AUTO_END;
 }
 
@@ -529,8 +531,46 @@ void UnicodeTest::TestEmojiProperties() {
                u_hasBinaryProperty(0x1F64B, UCHAR_EMOJI_MODIFIER_BASE));
     assertTrue("asterisk is Emoji_Component",
                u_hasBinaryProperty(0x2A, UCHAR_EMOJI_COMPONENT));
+    assertTrue("copyright is Extended_Pictographic",
+               u_hasBinaryProperty(0xA9, UCHAR_EXTENDED_PICTOGRAPHIC));
+#if U_PLATFORM_IS_DARWIN_BASED
     assertTrue("TAG char is Emoji_Component",
                u_hasBinaryProperty(0xE0061, UCHAR_EMOJI_COMPONENT)); // Apple addition
     assertTrue("ZWJ char is Emoji_Component",
                u_hasBinaryProperty(0x200D, UCHAR_EMOJI_COMPONENT)); // Apple addition
+#endif
+}
+
+void UnicodeTest::TestDefaultScriptExtensions() {
+    // Block 3000..303F CJK Symbols and Punctuation defaults to scx=Bopo Hang Hani Hira Kana Yiii
+    // but some of its characters revert to scx=<script> which is usually Common.
+    IcuTestErrorCode errorCode(*this, "TestDefaultScriptExtensions()");
+    UScriptCode scx[20];
+    scx[0] = USCRIPT_INVALID_CODE;
+    assertEquals("U+3000 num scx", 1,  // IDEOGRAPHIC SPACE
+                 uscript_getScriptExtensions(0x3000, scx, UPRV_LENGTHOF(scx), errorCode));
+    assertEquals("U+3000 num scx[0]", USCRIPT_COMMON, scx[0]);
+    scx[0] = USCRIPT_INVALID_CODE;
+    assertEquals("U+3012 num scx", 1,  // POSTAL MARK
+                 uscript_getScriptExtensions(0x3012, scx, UPRV_LENGTHOF(scx), errorCode));
+    assertEquals("U+3012 num scx[0]", USCRIPT_COMMON, scx[0]);
+}
+
+void UnicodeTest::TestInvalidCodePointFolding(void) {
+    // Test behavior when an invalid code point is passed to u_foldCase
+    static const UChar32 invalidCodePoints[] = {
+            0xD800, // lead surrogate
+            0xDFFF, // trail surrogate
+            0xFDD0, // noncharacter
+            0xFFFF, // noncharacter
+            0x110000, // out of range
+            -1 // negative
+    };
+    for (int32_t i=0; i<UPRV_LENGTHOF(invalidCodePoints); ++i) {
+        UChar32 cp = invalidCodePoints[i];
+        assertEquals("Invalid code points should be echoed back",
+                cp, u_foldCase(cp, U_FOLD_CASE_DEFAULT));
+        assertEquals("Invalid code points should be echoed back",
+                cp, u_foldCase(cp, U_FOLD_CASE_EXCLUDE_SPECIAL_I));
+    }
 }