X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/48b980fed3435926e0b3a8d72ecb58be703a1c7a..729e4ab9bc6618bc3d8a898e575df7f4019e29ca:/icuSources/test/intltest/ucaconf.cpp diff --git a/icuSources/test/intltest/ucaconf.cpp b/icuSources/test/intltest/ucaconf.cpp index bc85d90c..8c492c17 100644 --- a/icuSources/test/intltest/ucaconf.cpp +++ b/icuSources/test/intltest/ucaconf.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 2002-2008, International Business Machines Corporation and + * Copyright (c) 2002-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -31,7 +31,7 @@ status(U_ZERO_ERROR) const char *srcDir = IntlTest::getSourceTestData(status); if (U_FAILURE(status)) { - dataerrln("[DATA] Could not open test data %s", u_errorName(status)); + dataerrln("Could not open test data %s", u_errorName(status)); return; } uprv_strcpy(testDataPath, srcDir); @@ -136,7 +136,7 @@ void UCAConformanceTest::openTestFile(const char *type) if (testFile == 0) { *(buffer+bufLen) = 0; - dataerrln("[DATA] Could not open any of the conformance test files, tried opening base %s\n", buffer); + dataerrln("Could not open any of the conformance test files, tried opening base %s\n", buffer); return; } else { infoln( @@ -158,10 +158,14 @@ void UCAConformanceTest::testConformance(UCollator *coll) int32_t line = 0; UChar b1[1024], b2[1024]; - char lineB[1024]; UChar *buffer = b1, *oldB = NULL; + + char lineB1[1024], lineB2[1024]; + char *lineB = lineB1, *oldLineB = lineB2; + uint8_t sk1[1024], sk2[1024]; uint8_t *oldSk = NULL, *newSk = sk1; + int32_t resLen = 0, oldLen = 0; int32_t buflen = 0, oldBlen = 0; uint32_t first = 0; @@ -170,6 +174,8 @@ void UCAConformanceTest::testConformance(UCollator *coll) while (fgets(lineB, 1024, testFile) != NULL) { + // remove trailing whitespace + u_rtrim(lineB); offset = 0; line++; @@ -177,6 +183,11 @@ void UCAConformanceTest::testConformance(UCollator *coll) continue; } offset = u_parseString(lineB, buffer, 1024, &first, &status); + if(U_FAILURE(status)) { + errln("Error parsing line %ld (%s): %s\n", + (long)line, u_errorName(status), lineB); + status = U_ZERO_ERROR; + } buflen = offset; buffer[offset++] = 0; @@ -195,34 +206,51 @@ void UCAConformanceTest::testConformance(UCollator *coll) if(((res&0x80000000) != (cmpres&0x80000000)) || (res == 0 && cmpres != 0) || (res != 0 && cmpres == 0)) { errln("Difference between ucol_strcoll and sortkey compare on line %i", line); - logln("Data line %s", lineB); + errln(" Previous data line %s", oldLineB); + errln(" Current data line %s", lineB); } if(res > 0) { errln("Line %i is not greater or equal than previous line", line); - logln("Data line %s", lineB); + errln(" Previous data line %s", oldLineB); + errln(" Current data line %s", lineB); prettify(CollationKey(oldSk, oldLen), oldS); prettify(CollationKey(newSk, resLen), newS); - logln("Keys: "+oldS+" and "+newS); + errln(" Previous key: "+oldS); + errln(" Current key: "+newS); } else if(res == 0) { /* equal */ res = u_strcmpCodePointOrder(oldB, buffer); if (res == 0) { errln("Probable error in test file on line %i (comparing identical strings)", line); - logln("Data line %s", lineB); - } else if (res > 0) { - errln("Sortkeys are identical, but code point comapare gives >0 on line %i", line); - logln("Data line %s", lineB); + errln(" Data line %s", lineB); + } + /* + * UCA 6.0 test files can have lines that compare == if they are + * different strings but canonically equivalent. + else if (res > 0) { + errln("Sortkeys are identical, but code point compare gives >0 on line %i", line); + errln(" Previous data line %s", oldLineB); + errln(" Current data line %s", lineB); } + */ } } + // swap buffers + oldLineB = lineB; + oldB = buffer; oldSk = newSk; + if(lineB == lineB1) { + lineB = lineB2; + buffer = b2; + newSk = sk2; + } else { + lineB = lineB1; + buffer = b1; + newSk = sk1; + } oldLen = resLen; - - newSk = (newSk == sk1)?sk2:sk1; - oldB = buffer; oldBlen = buflen; - buffer = (buffer == b1)?b2:b1; } }