Home | History | Annotate | Download | only in intltest

Lines Matching refs:errorCode

17 #include "unicode/errorcode.h"
100 UBool readNonEmptyLine(UCHARBUF *f, IcuTestErrorCode &errorCode);
101 void parseString(int32_t &start, UnicodeString &prefix, UnicodeString &s, UErrorCode &errorCode);
102 Collation::Level parseRelationAndString(UnicodeString &s, IcuTestErrorCode &errorCode);
103 void parseAndSetAttribute(IcuTestErrorCode &errorCode);
104 void parseAndSetReorderCodes(int32_t start, IcuTestErrorCode &errorCode);
105 void buildTailoring(UCHARBUF *f, IcuTestErrorCode &errorCode);
106 void setRootCollator(IcuTestErrorCode &errorCode);
107 void setLocaleCollator(IcuTestErrorCode &errorCode);
109 UBool needsNormalization(const UnicodeString &s, UErrorCode &errorCode) const;
113 IcuTestErrorCode &errorCode);
116 CollationKey &key, IcuTestErrorCode &errorCode);
118 CollationKey &key, IcuTestErrorCode &errorCode);
122 IcuTestErrorCode &errorCode);
123 void checkCompareStrings(UCHARBUF *f, IcuTestErrorCode &errorCode);
155 IcuTestErrorCode errorCode(*this, "TestMinMax");
157 setRootCollator(errorCode);
158 if(errorCode.isFailure()) {
159 errorCode.reset();
169 UVector64 ces(errorCode);
170 rbc->internalGetCEs(UnicodeString(FALSE, s, 2), ces, errorCode);
171 errorCode.assertSuccess();
190 IcuTestErrorCode errorCode(*this, "TestImplicits");
192 const CollationData *cd = CollationRoot::getData(errorCode);
193 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
205 errorCode);
210 errorCode);
211 UnicodeSet unassigned("[[:Cn:][:Cs:][:Co:]]", errorCode);
221 errorCode);
224 if(errorCode.logIfFailureAndReset("UnicodeSet")) {
237 int64_t ce = ci.nextCE(errorCode);
238 int64_t ce2 = ci.nextCE(errorCode);
239 if(errorCode.logIfFailureAndReset("CollationIterator.nextCE()")) {
263 IcuTestErrorCode errorCode(*this, "TestNulTerminated");
264 const CollationData *data = CollationRoot::getData(errorCode);
265 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
274 int64_t ce1 = ci1.nextCE(errorCode);
275 int64_t ce2 = ci2.nextCE(errorCode);
276 if(errorCode.logIfFailureAndReset("CollationIterator.nextCE()")) {
288 IcuTestErrorCode errorCode(*this, "TestIllegalUTF8");
290 setRootCollator(errorCode);
291 if(errorCode.isFailure()) {
292 errorCode.reset();
295 coll->setAttribute(UCOL_STRENGTH, UCOL_IDENTICAL, errorCode);
313 UCollationResult order = coll->compareUTF8(fffd, illegal, errorCode);
337 IcuTestErrorCode errorCode(*this, "TestShortFCDData");
338 UnicodeSet expectedLccc("[:^lccc=0:]", errorCode);
339 errorCode.assertSuccess();
358 UnicodeSet expectedTccc("[:^tccc=0:]", errorCode);
359 if (errorCode.isSuccess()) {
393 IcuTestErrorCode errorCode(*this, "checkFCD");
397 UChar32 c1 = ci.nextCodePoint(errorCode);
409 UChar32 c1 = ci.previousCodePoint(errorCode);
420 UChar32 c1 = ci.nextCodePoint(errorCode);
432 UChar32 c1 = ci.previousCodePoint(errorCode);
444 IcuTestErrorCode errorCode(*this, "TestFCD");
445 const CollationData *data = CollationRoot::getData(errorCode);
446 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
479 if(errorCode.logIfFailureAndReset("FCDUTF16CollationIterator constructor")) {
491 if(errorCode.logIfFailureAndReset("FCDUTF8CollationIterator constructor")) {
501 if(errorCode.logIfFailureAndReset("FCDUIterCollationIterator constructor")) {
765 IcuTestErrorCode errorCode(*this, "TestRootElements");
766 const CollationData *root = CollationRoot::getData(errorCode);
767 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
868 IcuTestErrorCode errorCode(*this, "TestTailoredElements");
869 const CollationData *root = CollationRoot::getData(errorCode);
870 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
875 UHashtable *prevLocales = uhash_open(uhash_hashChars, uhash_compareChars, NULL, errorCode);
876 if(errorCode.logIfFailureAndReset("failed to create a hash table")) {
881 uhash_puti(prevLocales, uprv_strdup(""), 1, errorCode);
882 uhash_puti(prevLocales, uprv_strdup("root"), 1, errorCode);
883 uhash_puti(prevLocales, uprv_strdup("root@collation=standard"), 1, errorCode);
885 UVector64 ces(errorCode);
892 Collator::getKeywordValuesForLocale("collation", locale, FALSE, errorCode));
893 errorCode.assertSuccess();
895 while((type = types->next(NULL, errorCode)) != NULL) {
901 localeWithType.setKeywordValue("collation", type, errorCode);
902 errorCode.assertSuccess();
903 LocalPointer<Collator> coll(Collator::createInstance(localeWithType, errorCode));
904 if(errorCode.logIfFailureAndReset("Collator::createInstance(%s)",
908 Locale actual = coll->getLocale(ULOC_ACTUAL_LOCALE, errorCode);
912 uhash_puti(prevLocales, uprv_strdup(actual.getName()), 1, errorCode);
913 errorCode.assertSuccess();
928 LocalPointer<UnicodeSet> tailored(coll->getTailoredSet(errorCode));
929 errorCode.assertSuccess();
934 rbc->internalGetCEs(s, ces, errorCode);
935 errorCode.assertSuccess();
946 } while((localeID = locales->next(NULL, errorCode)) != NULL);
972 UBool CollationTest::readNonEmptyLine(UCHARBUF *f, IcuTestErrorCode &errorCode) {
975 const UChar *line = ucbuf_readline(f, &lineLength, errorCode);
976 if(line == NULL || errorCode.isFailure()) {
998 UErrorCode &errorCode) {
1008 errorCode = U_PARSE_ERROR;
1019 errorCode = U_PARSE_ERROR;
1025 Collation::Level CollationTest::parseRelationAndString(UnicodeString &s, IcuTestErrorCode &errorCode) {
1064 errorCode.set(U_PARSE_ERROR);
1069 parseString(start, prefix, s, errorCode);
1070 if(errorCode.isSuccess() && !prefix.isEmpty()) {
1073 errorCode.set(U_PARSE_ERROR);
1079 errorCode.set(U_PARSE_ERROR);
1117 void CollationTest::parseAndSetAttribute(IcuTestErrorCode &errorCode) {
1124 parseAndSetReorderCodes(start + 7, errorCode);
1129 errorCode.set(U_PARSE_ERROR);
1148 errorCode.set(U_PARSE_ERROR);
1152 coll->setMaxVariable(max, errorCode);
1153 if(errorCode.isFailure()) {
1155 (int)fileLineNumber, errorCode.errorName());
1169 errorCode.set(U_PARSE_ERROR);
1183 errorCode.set(U_PARSE_ERROR);
1193 coll->setAttribute(attr, value, errorCode);
1194 if(errorCode.isFailure()) {
1196 (int)fileLineNumber, errorCode.errorName());
1204 void CollationTest::parseAndSetReorderCodes(int32_t start, IcuTestErrorCode &errorCode) {
1205 UVector32 reorderCodes(errorCode);
1211 name.appendInvariantChars(fileLine.tempSubStringBetween(start, limit), errorCode);
1219 errorCode.set(U_PARSE_ERROR);
1223 reorderCodes.addElement(code, errorCode);
1227 coll->setReorderCodes(reorderCodes.getBuffer(), reorderCodes.size(), errorCode);
1228 if(errorCode.isFailure()) {
1230 (int)fileLineNumber, errorCode.errorName());
1238 void CollationTest::buildTailoring(UCHARBUF *f, IcuTestErrorCode &errorCode) {
1240 while(readNonEmptyLine(f, errorCode) && !isSectionStarter(fileLine[0])) {
1243 if(errorCode.isFailure()) { return; }
1249 coll = new RuleBasedCollator(rules, parseError, reason, errorCode);
1252 errorCode.set(U_MEMORY_ALLOCATION_ERROR);
1255 if(errorCode.isFailure()) {
1256 dataerrln("RuleBasedCollator(rules) failed - %s", errorCode.errorName());
1265 errorCode.reset();
1272 void CollationTest::setRootCollator(IcuTestErrorCode &errorCode) {
1273 if(errorCode.isFailure()) { return; }
1275 coll = Collator::createInstance(Locale::getRoot(), errorCode);
1276 if(errorCode.isFailure()) {
1282 void CollationTest::setLocaleCollator(IcuTestErrorCode &errorCode) {
1283 if(errorCode.isFailure()) { return; }
1291 localeID.appendInvariantChars(fileLine.tempSubString(9), errorCode);
1296 if(fileLine.length() == 9 || errorCode.isFailure() || locale.isBogus()) {
1299 if(errorCode.isSuccess()) { errorCode.set(U_PARSE_ERROR); }
1304 coll = Collator::createInstance(locale, errorCode);
1305 if(errorCode.isFailure()) {
1311 errorCode.reset();
1315 UBool CollationTest::needsNormalization(const UnicodeString &s, UErrorCode &errorCode) const {
1316 if(U_FAILURE(errorCode) || !fcd->isNormalized(s, errorCode)) { return TRUE; }
1333 IcuTestErrorCode &errorCode) {
1334 if(errorCode.isFailure()) { return FALSE; }
1341 int32_t partLength = coll->internalNextSortKeyPart(&iter, state, part, partSize, errorCode);
1347 dest.append(reinterpret_cast<char *>(part), partLength, errorCode);
1349 return errorCode.isSuccess();
1356 CollationKey &key, IcuTestErrorCode &errorCode) {
1357 if(errorCode.isFailure()) { return FALSE; }
1358 coll->getCollationKey(s, length, key, errorCode);
1359 if(errorCode.isFailure()) {
1362 norm, errorCode.errorName());
1377 int32_t numLevels = coll->getAttribute(UCOL_STRENGTH, errorCode);
1383 if(coll->getAttribute(UCOL_CASE_LEVEL, errorCode) == UCOL_ON) {
1386 errorCode.assertSuccess();
1413 if(!getSortKeyParts(s, length, parts, 32, errorCode)) {
1416 norm, (int)partSize, errorCode.errorName());
1439 CollationKey &key, IcuTestErrorCode &errorCode) {
1440 if(errorCode.isFailure()) { return FALSE; }
1459 coll->getCollationKey(s + segmentStart, i - segmentStart, key2, errorCode);
1550 IcuTestErrorCode &errorCode) {
1551 if(errorCode.isFailure()) { return FALSE; }
1556 prevKey, errorCode)) {
1560 if(!getCollationKey(norm, fileLine, s.getBuffer(), s.length(), key, errorCode)) { return FALSE; }
1562 UCollationResult order = coll->compare(prevString, s, errorCode);
1563 if(order != expectedOrder || errorCode.isFailure()) {
1566 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1573 order = coll->compare(s, prevString, errorCode);
1574 if(order != -expectedOrder || errorCode.isFailure()) {
1577 (int)fileLineNumber, norm, order, -expectedOrder, errorCode.errorName());
1587 order = coll->compare(prevString.getBuffer(), -1, s.getBuffer(), -1, errorCode);
1588 if(order != expectedOrder || errorCode.isFailure()) {
1591 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1598 order = coll->compare(s.getBuffer(), -1, prevString.getBuffer(), -1, errorCode);
1599 if(order != -expectedOrder || errorCode.isFailure()) {
1602 (int)fileLineNumber, norm, order, -expectedOrder, errorCode.errorName());
1626 expectedUTF8Order = coll->compare(prevValid, sValid, errorCode);
1629 order = coll->compareUTF8(prevUTF8, sUTF8, errorCode);
1630 if(order != expectedUTF8Order || errorCode.isFailure()) {
1633 (int)fileLineNumber, norm, order, expectedUTF8Order, errorCode.errorName());
1640 order = coll->compareUTF8(sUTF8, prevUTF8, errorCode);
1641 if(order != -expectedUTF8Order || errorCode.isFailure()) {
1644 (int)fileLineNumber, norm, order, -expectedUTF8Order, errorCode.errorName());
1653 order = coll->internalCompareUTF8(prevUTF8.c_str(), -1, sUTF8.c_str(), -1, errorCode);
1654 if(order != expectedUTF8Order || errorCode.isFailure()) {
1657 (int)fileLineNumber, norm, order, expectedUTF8Order, errorCode.errorName());
1664 order = coll->internalCompareUTF8(sUTF8.c_str(), -1, prevUTF8.c_str(), -1, errorCode);
1665 if(order != -expectedUTF8Order || errorCode.isFailure()) {
1668 (int)fileLineNumber, norm, order, -expectedUTF8Order, errorCode.errorName());
1682 order = coll->compare(leftIter, rightIter, errorCode);
1683 if(order != expectedOrder || errorCode.isFailure()) {
1687 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1695 order = prevKey.compareTo(key, errorCode);
1696 if(order != expectedOrder || errorCode.isFailure()) {
1699 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1706 UBool collHasCaseLevel = coll->getAttribute(UCOL_CASE_LEVEL, errorCode) == UCOL_ON;
1729 if((getMergedCollationKey(prevString.getBuffer(), prevString.length(), prevKey, errorCode) |
1730 getMergedCollationKey(s.getBuffer(), s.length(), key, errorCode)) ||
1731 errorCode.isFailure()) {
1732 order = prevKey.compareTo(key, errorCode);
1733 if(order != expectedOrder || errorCode.isFailure()) {
1737 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1762 void CollationTest::checkCompareStrings(UCHARBUF *f, IcuTestErrorCode &errorCode) {
1763 if(errorCode.isFailure()) { return; }
1767 while(readNonEmptyLine(f, errorCode) && !isSectionStarter(fileLine[0])) {
1770 Collation::Level relation = parseRelationAndString(s, errorCode);
1771 if(errorCode.isFailure()) {
1772 errorCode.reset();
1785 if(!needsNormalization(prevString, errorCode) && !needsNormalization(s, errorCode)) {
1786 coll->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_OFF, errorCode);
1788 expectedOrder, expectedLevel, errorCode);
1791 coll->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, errorCode);
1793 expectedOrder, expectedLevel, errorCode);
1795 if(isOk && (!nfd->isNormalized(prevString, errorCode) || !nfd->isNormalized(s, errorCode))) {
1796 UnicodeString pn = nfd->normalize(prevString, errorCode);
1797 UnicodeString n = nfd->normalize(s, errorCode);
1800 errorCode.assertSuccess();
1802 expectedOrder, expectedLevel, errorCode);
1805 errorCode.reset(); // already reported
1814 IcuTestErrorCode errorCode(*this, "TestDataDriven");
1816 fcd = Normalizer2Factory::getFCDInstance(errorCode);
1817 nfd = Normalizer2::getNFDInstance(errorCode);
1818 if(errorCode.logDataIfFailureAndReset("Normalizer2Factory::getFCDInstance() or getNFDInstance()")) {
1822 CharString path(getSourceTestData(errorCode), errorCode);
1823 path.appendPathPart("collationtest.txt", errorCode);
1825 LocalUCHARBUFPointer f(ucbuf_open(path.data(), &codePage, TRUE, FALSE, errorCode));
1826 if(errorCode.logIfFailureAndReset("ucbuf_open(collationtest.txt)")) {
1831 while(errorCode.isSuccess() && (!fileLine.isEmpty() || readNonEmptyLine(f.getAlias(), errorCode))) {
1842 setRootCollator(errorCode);
1845 setLocaleCollator(errorCode);
1848 buildTailoring(f.getAlias(), errorCode);
1850 parseAndSetAttribute(errorCode);
1852 checkCompareStrings(f.getAlias(), errorCode);