Home | History | Annotate | Download | only in intltest

Lines Matching refs:errorCode

19 #include "unicode/errorcode.h"
99 UBool readNonEmptyLine(UCHARBUF *f, IcuTestErrorCode &errorCode);
100 void parseString(int32_t &start, UnicodeString &prefix, UnicodeString &s, UErrorCode &errorCode);
101 Collation::Level parseRelationAndString(UnicodeString &s, IcuTestErrorCode &errorCode);
102 void parseAndSetAttribute(IcuTestErrorCode &errorCode);
103 void parseAndSetReorderCodes(int32_t start, IcuTestErrorCode &errorCode);
104 void buildTailoring(UCHARBUF *f, IcuTestErrorCode &errorCode);
105 void setRootCollator(IcuTestErrorCode &errorCode);
106 void setLocaleCollator(IcuTestErrorCode &errorCode);
108 UBool needsNormalization(const UnicodeString &s, UErrorCode &errorCode) const;
112 IcuTestErrorCode &errorCode);
115 CollationKey &key, IcuTestErrorCode &errorCode);
117 CollationKey &key, IcuTestErrorCode &errorCode);
121 IcuTestErrorCode &errorCode);
122 void checkCompareStrings(UCHARBUF *f, IcuTestErrorCode &errorCode);
154 IcuTestErrorCode errorCode(*this, "TestMinMax");
156 setRootCollator(errorCode);
157 if(errorCode.isFailure()) {
158 errorCode.reset();
168 UVector64 ces(errorCode);
169 rbc->internalGetCEs(UnicodeString(FALSE, s, 2), ces, errorCode);
170 errorCode.assertSuccess();
189 IcuTestErrorCode errorCode(*this, "TestImplicits");
191 const CollationData *cd = CollationRoot::getData(errorCode);
192 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
204 errorCode);
209 errorCode);
210 UnicodeSet unassigned("[[:Cn:][:Cs:][:Co:]]", errorCode);
220 errorCode);
223 if(errorCode.logIfFailureAndReset("UnicodeSet")) {
236 int64_t ce = ci.nextCE(errorCode);
237 int64_t ce2 = ci.nextCE(errorCode);
238 if(errorCode.logIfFailureAndReset("CollationIterator.nextCE()")) {
262 IcuTestErrorCode errorCode(*this, "TestNulTerminated");
263 const CollationData *data = CollationRoot::getData(errorCode);
264 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
273 int64_t ce1 = ci1.nextCE(errorCode);
274 int64_t ce2 = ci2.nextCE(errorCode);
275 if(errorCode.logIfFailureAndReset("CollationIterator.nextCE()")) {
287 IcuTestErrorCode errorCode(*this, "TestIllegalUTF8");
289 setRootCollator(errorCode);
290 if(errorCode.isFailure()) {
291 errorCode.reset();
294 coll->setAttribute(UCOL_STRENGTH, UCOL_IDENTICAL, errorCode);
312 UCollationResult order = coll->compareUTF8(fffd, illegal, errorCode);
336 IcuTestErrorCode errorCode(*this, "TestShortFCDData");
337 UnicodeSet expectedLccc("[:^lccc=0:]", errorCode);
338 errorCode.assertSuccess();
357 UnicodeSet expectedTccc("[:^tccc=0:]", errorCode);
358 if (errorCode.isSuccess()) {
392 IcuTestErrorCode errorCode(*this, "checkFCD");
396 UChar32 c1 = ci.nextCodePoint(errorCode);
408 UChar32 c1 = ci.previousCodePoint(errorCode);
419 UChar32 c1 = ci.nextCodePoint(errorCode);
431 UChar32 c1 = ci.previousCodePoint(errorCode);
443 IcuTestErrorCode errorCode(*this, "TestFCD");
444 const CollationData *data = CollationRoot::getData(errorCode);
445 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
478 if(errorCode.logIfFailureAndReset("FCDUTF16CollationIterator constructor")) {
490 if(errorCode.logIfFailureAndReset("FCDUTF8CollationIterator constructor")) {
500 if(errorCode.logIfFailureAndReset("FCDUIterCollationIterator constructor")) {
764 IcuTestErrorCode errorCode(*this, "TestRootElements");
765 const CollationData *root = CollationRoot::getData(errorCode);
766 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
867 IcuTestErrorCode errorCode(*this, "TestTailoredElements");
868 const CollationData *root = CollationRoot::getData(errorCode);
869 if(errorCode.logDataIfFailureAndReset("CollationRoot::getData()")) {
874 UHashtable *prevLocales = uhash_open(uhash_hashChars, uhash_compareChars, NULL, errorCode);
875 if(errorCode.logIfFailureAndReset("failed to create a hash table")) {
880 uhash_puti(prevLocales, uprv_strdup(""), 1, errorCode);
881 uhash_puti(prevLocales, uprv_strdup("root"), 1, errorCode);
882 uhash_puti(prevLocales, uprv_strdup("root@collation=standard"), 1, errorCode);
884 UVector64 ces(errorCode);
891 Collator::getKeywordValuesForLocale("collation", locale, FALSE, errorCode));
892 errorCode.assertSuccess();
894 while((type = types->next(NULL, errorCode)) != NULL) {
900 localeWithType.setKeywordValue("collation", type, errorCode);
901 errorCode.assertSuccess();
902 LocalPointer<Collator> coll(Collator::createInstance(localeWithType, errorCode));
903 if(errorCode.logIfFailureAndReset("Collator::createInstance(%s)",
907 Locale actual = coll->getLocale(ULOC_ACTUAL_LOCALE, errorCode);
911 uhash_puti(prevLocales, uprv_strdup(actual.getName()), 1, errorCode);
912 errorCode.assertSuccess();
927 LocalPointer<UnicodeSet> tailored(coll->getTailoredSet(errorCode));
928 errorCode.assertSuccess();
933 rbc->internalGetCEs(s, ces, errorCode);
934 errorCode.assertSuccess();
945 } while((localeID = locales->next(NULL, errorCode)) != NULL);
971 UBool CollationTest::readNonEmptyLine(UCHARBUF *f, IcuTestErrorCode &errorCode) {
974 const UChar *line = ucbuf_readline(f, &lineLength, errorCode);
975 if(line == NULL || errorCode.isFailure()) {
997 UErrorCode &errorCode) {
1007 errorCode = U_PARSE_ERROR;
1018 errorCode = U_PARSE_ERROR;
1024 Collation::Level CollationTest::parseRelationAndString(UnicodeString &s, IcuTestErrorCode &errorCode) {
1063 errorCode.set(U_PARSE_ERROR);
1068 parseString(start, prefix, s, errorCode);
1069 if(errorCode.isSuccess() && !prefix.isEmpty()) {
1072 errorCode.set(U_PARSE_ERROR);
1078 errorCode.set(U_PARSE_ERROR);
1116 void CollationTest::parseAndSetAttribute(IcuTestErrorCode &errorCode) {
1123 parseAndSetReorderCodes(start + 7, errorCode);
1128 errorCode.set(U_PARSE_ERROR);
1147 errorCode.set(U_PARSE_ERROR);
1151 coll->setMaxVariable(max, errorCode);
1152 if(errorCode.isFailure()) {
1154 (int)fileLineNumber, errorCode.errorName());
1168 errorCode.set(U_PARSE_ERROR);
1182 errorCode.set(U_PARSE_ERROR);
1192 coll->setAttribute(attr, value, errorCode);
1193 if(errorCode.isFailure()) {
1195 (int)fileLineNumber, errorCode.errorName());
1203 void CollationTest::parseAndSetReorderCodes(int32_t start, IcuTestErrorCode &errorCode) {
1204 UVector32 reorderCodes(errorCode);
1210 name.appendInvariantChars(fileLine.tempSubStringBetween(start, limit), errorCode);
1218 errorCode.set(U_PARSE_ERROR);
1222 reorderCodes.addElement(code, errorCode);
1226 coll->setReorderCodes(reorderCodes.getBuffer(), reorderCodes.size(), errorCode);
1227 if(errorCode.isFailure()) {
1229 (int)fileLineNumber, errorCode.errorName());
1237 void CollationTest::buildTailoring(UCHARBUF *f, IcuTestErrorCode &errorCode) {
1239 while(readNonEmptyLine(f, errorCode) && !isSectionStarter(fileLine[0])) {
1242 if(errorCode.isFailure()) { return; }
1248 coll = new RuleBasedCollator(rules, parseError, reason, errorCode);
1251 errorCode.set(U_MEMORY_ALLOCATION_ERROR);
1254 if(errorCode.isFailure()) {
1255 dataerrln("RuleBasedCollator(rules) failed - %s", errorCode.errorName());
1264 errorCode.reset();
1271 void CollationTest::setRootCollator(IcuTestErrorCode &errorCode) {
1272 if(errorCode.isFailure()) { return; }
1274 coll = Collator::createInstance(Locale::getRoot(), errorCode);
1275 if(errorCode.isFailure()) {
1281 void CollationTest::setLocaleCollator(IcuTestErrorCode &errorCode) {
1282 if(errorCode.isFailure()) { return; }
1290 localeID.appendInvariantChars(fileLine.tempSubString(9), errorCode);
1295 if(fileLine.length() == 9 || errorCode.isFailure() || locale.isBogus()) {
1298 if(errorCode.isSuccess()) { errorCode.set(U_PARSE_ERROR); }
1303 coll = Collator::createInstance(locale, errorCode);
1304 if(errorCode.isFailure()) {
1310 errorCode.reset();
1314 UBool CollationTest::needsNormalization(const UnicodeString &s, UErrorCode &errorCode) const {
1315 if(U_FAILURE(errorCode) || !fcd->isNormalized(s, errorCode)) { return TRUE; }
1332 IcuTestErrorCode &errorCode) {
1333 if(errorCode.isFailure()) { return FALSE; }
1340 int32_t partLength = coll->internalNextSortKeyPart(&iter, state, part, partSize, errorCode);
1346 dest.append(reinterpret_cast<char *>(part), partLength, errorCode);
1348 return errorCode.isSuccess();
1355 CollationKey &key, IcuTestErrorCode &errorCode) {
1356 if(errorCode.isFailure()) { return FALSE; }
1357 coll->getCollationKey(s, length, key, errorCode);
1358 if(errorCode.isFailure()) {
1361 norm, errorCode.errorName());
1376 int32_t numLevels = coll->getAttribute(UCOL_STRENGTH, errorCode);
1382 if(coll->getAttribute(UCOL_CASE_LEVEL, errorCode) == UCOL_ON) {
1385 errorCode.assertSuccess();
1412 if(!getSortKeyParts(s, length, parts, 32, errorCode)) {
1415 norm, (int)partSize, errorCode.errorName());
1438 CollationKey &key, IcuTestErrorCode &errorCode) {
1439 if(errorCode.isFailure()) { return FALSE; }
1458 coll->getCollationKey(s + segmentStart, i - segmentStart, key2, errorCode);
1549 IcuTestErrorCode &errorCode) {
1550 if(errorCode.isFailure()) { return FALSE; }
1555 prevKey, errorCode)) {
1559 if(!getCollationKey(norm, fileLine, s.getBuffer(), s.length(), key, errorCode)) { return FALSE; }
1561 UCollationResult order = coll->compare(prevString, s, errorCode);
1562 if(order != expectedOrder || errorCode.isFailure()) {
1565 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1572 order = coll->compare(s, prevString, errorCode);
1573 if(order != -expectedOrder || errorCode.isFailure()) {
1576 (int)fileLineNumber, norm, order, -expectedOrder, errorCode.errorName());
1586 order = coll->compare(prevString.getBuffer(), -1, s.getBuffer(), -1, errorCode);
1587 if(order != expectedOrder || errorCode.isFailure()) {
1590 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1597 order = coll->compare(s.getBuffer(), -1, prevString.getBuffer(), -1, errorCode);
1598 if(order != -expectedOrder || errorCode.isFailure()) {
1601 (int)fileLineNumber, norm, order, -expectedOrder, errorCode.errorName());
1625 expectedUTF8Order = coll->compare(prevValid, sValid, errorCode);
1628 order = coll->compareUTF8(prevUTF8, sUTF8, errorCode);
1629 if(order != expectedUTF8Order || errorCode.isFailure()) {
1632 (int)fileLineNumber, norm, order, expectedUTF8Order, errorCode.errorName());
1639 order = coll->compareUTF8(sUTF8, prevUTF8, errorCode);
1640 if(order != -expectedUTF8Order || errorCode.isFailure()) {
1643 (int)fileLineNumber, norm, order, -expectedUTF8Order, errorCode.errorName());
1652 order = coll->internalCompareUTF8(prevUTF8.c_str(), -1, sUTF8.c_str(), -1, errorCode);
1653 if(order != expectedUTF8Order || errorCode.isFailure()) {
1656 (int)fileLineNumber, norm, order, expectedUTF8Order, errorCode.errorName());
1663 order = coll->internalCompareUTF8(sUTF8.c_str(), -1, prevUTF8.c_str(), -1, errorCode);
1664 if(order != -expectedUTF8Order || errorCode.isFailure()) {
1667 (int)fileLineNumber, norm, order, -expectedUTF8Order, errorCode.errorName());
1681 order = coll->compare(leftIter, rightIter, errorCode);
1682 if(order != expectedOrder || errorCode.isFailure()) {
1686 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1694 order = prevKey.compareTo(key, errorCode);
1695 if(order != expectedOrder || errorCode.isFailure()) {
1698 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1705 UBool collHasCaseLevel = coll->getAttribute(UCOL_CASE_LEVEL, errorCode) == UCOL_ON;
1728 if((getMergedCollationKey(prevString.getBuffer(), prevString.length(), prevKey, errorCode) |
1729 getMergedCollationKey(s.getBuffer(), s.length(), key, errorCode)) ||
1730 errorCode.isFailure()) {
1731 order = prevKey.compareTo(key, errorCode);
1732 if(order != expectedOrder || errorCode.isFailure()) {
1736 (int)fileLineNumber, norm, order, expectedOrder, errorCode.errorName());
1761 void CollationTest::checkCompareStrings(UCHARBUF *f, IcuTestErrorCode &errorCode) {
1762 if(errorCode.isFailure()) { return; }
1766 while(readNonEmptyLine(f, errorCode) && !isSectionStarter(fileLine[0])) {
1769 Collation::Level relation = parseRelationAndString(s, errorCode);
1770 if(errorCode.isFailure()) {
1771 errorCode.reset();
1784 if(!needsNormalization(prevString, errorCode) && !needsNormalization(s, errorCode)) {
1785 coll->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_OFF, errorCode);
1787 expectedOrder, expectedLevel, errorCode);
1790 coll->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, errorCode);
1792 expectedOrder, expectedLevel, errorCode);
1794 if(isOk && (!nfd->isNormalized(prevString, errorCode) || !nfd->isNormalized(s, errorCode))) {
1795 UnicodeString pn = nfd->normalize(prevString, errorCode);
1796 UnicodeString n = nfd->normalize(s, errorCode);
1799 errorCode.assertSuccess();
1801 expectedOrder, expectedLevel, errorCode);
1804 errorCode.reset(); // already reported
1813 IcuTestErrorCode errorCode(*this, "TestDataDriven");
1815 fcd = Normalizer2Factory::getFCDInstance(errorCode);
1816 nfd = Normalizer2::getNFDInstance(errorCode);
1817 if(errorCode.logDataIfFailureAndReset("Normalizer2Factory::getFCDInstance() or getNFDInstance()")) {
1821 CharString path(getSourceTestData(errorCode), errorCode);
1822 path.appendPathPart("collationtest.txt", errorCode);
1824 LocalUCHARBUFPointer f(ucbuf_open(path.data(), &codePage, TRUE, FALSE, errorCode));
1825 if(errorCode.logIfFailureAndReset("ucbuf_open(collationtest.txt)")) {
1830 while(errorCode.isSuccess() && (!fileLine.isEmpty() || readNonEmptyLine(f.getAlias(), errorCode))) {
1841 setRootCollator(errorCode);
1844 setLocaleCollator(errorCode);
1847 buildTailoring(f.getAlias(), errorCode);
1849 parseAndSetAttribute(errorCode);
1851 checkCompareStrings(f.getAlias(), errorCode);