X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b331163bffd790ced0e88b73f44f86d49ccc48a5..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/test/intltest/usettest.cpp?ds=sidebyside diff --git a/icuSources/test/intltest/usettest.cpp b/icuSources/test/intltest/usettest.cpp index 3f1713d3..6dbf9255 100644 --- a/icuSources/test/intltest/usettest.cpp +++ b/icuSources/test/intltest/usettest.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************** -* Copyright (C) 1999-2014 International Business Machines Corporation and +* Copyright (C) 1999-2016 International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************** * Date Name Description @@ -22,6 +22,7 @@ #include "unicode/parsepos.h" #include "unicode/symtable.h" #include "unicode/uversion.h" +#include "cmemory.h" #include "hash.h" #define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \ @@ -90,6 +91,7 @@ UnicodeSetTest::runIndexedTest(int32_t index, UBool exec, CASE(21,TestFreezable); CASE(22,TestSpan); CASE(23,TestStringSpan); + CASE(24,TestUCAUnsafeBackwards); default: name = ""; break; } } @@ -689,7 +691,7 @@ void UnicodeSetTest::TestAPI() { if (set != exp) { errln("FAIL: retain('s')"); return; } uint16_t buf[32]; - int32_t slen = set.serialize(buf, sizeof(buf)/sizeof(buf[0]), status); + int32_t slen = set.serialize(buf, UPRV_LENGTHOF(buf), status); if (U_FAILURE(status)) { errln("FAIL: serialize"); return; } if (slen != 3 || buf[0] != 2 || buf[1] != 0x73 || buf[2] != 0x74) { errln("FAIL: serialize"); @@ -1056,7 +1058,7 @@ void UnicodeSetTest::TestPropertySet() { "\\uFDF2" }; - static const int32_t DATA_LEN = sizeof(DATA)/sizeof(DATA[0]); + static const int32_t DATA_LEN = UPRV_LENGTHOF(DATA); for (int32_t i=0; ic:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\driverspecs.h(142): error C2008: '$' : unexpected in macro definition + * .. so, we skip this test on Windows. + * + * the cause is that intltest builds with /Za which disables language extensions - which means + * windows header files can't be used. + */ +#if !UCONFIG_NO_COLLATION && !U_PLATFORM_HAS_WIN32_API +#include "collationroot.h" +#include "collationtailoring.h" +#endif + +void UnicodeSetTest::TestUCAUnsafeBackwards() { +#if U_PLATFORM_HAS_WIN32_API + infoln("Skipping TestUCAUnsafeBackwards() - can't include collationroot.h on Windows without language extensions!"); +#elif !UCONFIG_NO_COLLATION + UErrorCode errorCode = U_ZERO_ERROR; + + // Get the unsafeBackwardsSet + const CollationCacheEntry *rootEntry = CollationRoot::getRootCacheEntry(errorCode); + if(U_FAILURE(errorCode)) { + dataerrln("FAIL: %s getting root cache entry", u_errorName(errorCode)); + return; + } + //const UVersionInfo &version = rootEntry->tailoring->version; + const UnicodeSet *unsafeBackwardSet = rootEntry->tailoring->unsafeBackwardSet; + + checkSerializeRoundTrip(*unsafeBackwardSet, errorCode); + + if(!logKnownIssue("11891","UnicodeSet fails to round trip on CollationRoot...unsafeBackwards set")) { + // simple test case + // TODO(ticket #11891): Simplify this test function to this simple case. Rename it appropriately. + // TODO(ticket #11891): Port test to Java. Is this a bug there, too? + UnicodeSet surrogates; + surrogates.add(0xd83a); // a lead surrogate + surrogates.add(0xdc00, 0xdfff); // a range of trail surrogates + UnicodeString pat; + surrogates.toPattern(pat, FALSE); // bad: [ 0xd83a, 0xdc00, 0x2d, 0xdfff ] + // TODO: Probably fix either UnicodeSet::_generatePattern() or _appendToPat() + // so that at least one type of surrogate code points are escaped, + // or (minimally) so that adjacent lead+trail surrogate code points are escaped. + errorCode = U_ZERO_ERROR; + UnicodeSet s2; + s2.applyPattern(pat, errorCode); // looks like invalid range [ 0x1e800, 0x2d, 0xdfff ] + if(U_FAILURE(errorCode)) { + errln("FAIL: surrogates to/from pattern - %s", u_errorName(errorCode)); + } else { + checkEqual(surrogates, s2, "surrogates to/from pattern"); + } + // This occurs in the UCA unsafe-backwards set. + checkRoundTrip(*unsafeBackwardSet); + } +#endif +}