Index: icu4c/source/test/intltest/ucdtest.cpp |
=================================================================== |
--- icu4c/source/test/intltest/ucdtest.cpp (revision 40724) |
+++ icu4c/source/test/intltest/ucdtest.cpp (working copy) |
@@ -63,6 +63,7 @@ |
TESTCASE_AUTO(TestBidiPairedBracketType); |
TESTCASE_AUTO(TestEmojiProperties); |
TESTCASE_AUTO(TestDefaultScriptExtensions); |
+ TESTCASE_AUTO(TestInvalidCodePointFolding); |
TESTCASE_AUTO_END; |
} |
@@ -546,3 +547,21 @@ |
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 (auto cp : invalidCodePoints) { |
+ 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)); |
+ } |
+} |