Lines Matching refs:errorCode
70 UBool dataDriven(const TestCase &test, IcuTestErrorCode &errorCode);
98 IcuTestErrorCode errorCode(*this, "testEmpty"); in testEmpty() local
99 LocaleMatcher matcher = LocaleMatcher::Builder().build(errorCode); in testEmpty()
100 const Locale *best = matcher.getBestMatch(Locale::getFrench(), errorCode); in testEmpty()
102 LocaleMatcher::Result result = matcher.getBestMatchResult("fr", errorCode); in testEmpty()
112 IcuTestErrorCode errorCode(*this, "testCopyErrorTo"); in testCopyErrorTo() local
125 IcuTestErrorCode errorCode(*this, "testBasics"); in testBasics() local
129 setSupportedLocales(ARRAY_RANGE(locales)).build(errorCode); in testBasics()
130 const Locale *best = matcher.getBestMatch("en_GB", errorCode); in testBasics()
132 best = matcher.getBestMatch("en_US", errorCode); in testBasics()
134 best = matcher.getBestMatch("fr_FR", errorCode); in testBasics()
136 best = matcher.getBestMatch("ja_JP", errorCode); in testBasics()
143 setSupportedLocales(locales.begin(), locales.end()).build(errorCode); in testBasics()
144 const Locale *best = matcher.getBestMatch("en_GB", errorCode); in testBasics()
146 best = matcher.getBestMatch("en_US", errorCode); in testBasics()
148 best = matcher.getBestMatch("fr_FR", errorCode); in testBasics()
150 best = matcher.getBestMatch("ja_JP", errorCode); in testBasics()
156 setSupportedLocales(iter).build(errorCode); in testBasics()
157 const Locale *best = matcher.getBestMatch("en_GB", errorCode); in testBasics()
159 best = matcher.getBestMatch("en_US", errorCode); in testBasics()
161 best = matcher.getBestMatch("fr_FR", errorCode); in testBasics()
163 best = matcher.getBestMatch("ja_JP", errorCode); in testBasics()
173 build(errorCode); in testBasics()
174 const Locale *best = matcher.getBestMatch("en_GB", errorCode); in testBasics()
176 best = matcher.getBestMatch("en_US", errorCode); in testBasics()
178 best = matcher.getBestMatch("fr_FR", errorCode); in testBasics()
180 best = matcher.getBestMatch("ja_JP", errorCode); in testBasics()
188 build(errorCode); in testBasics()
189 const Locale *best = matcher.getBestMatch("en_GB", errorCode); in testBasics()
191 best = matcher.getBestMatch("en_US", errorCode); in testBasics()
193 best = matcher.getBestMatch("fr_FR", errorCode); in testBasics()
195 best = matcher.getBestMatch("ja_JP", errorCode); in testBasics()
202 build(errorCode); in testBasics()
203 const Locale *best = matcher.getBestMatchForListString("el, fr, fr;q=0, en-GB", errorCode); in testBasics()
205 best = matcher.getBestMatch("en_US", errorCode); in testBasics()
207 best = matcher.getBestMatch("fr_FR", errorCode); in testBasics()
209 best = matcher.getBestMatch("ja_JP", errorCode); in testBasics()
214 LocalePriorityList list("fr, en-GB", errorCode); in testBasics()
220 build(errorCode); in testBasics()
221 const Locale *best = matcher.getBestMatch("en_GB", errorCode); in testBasics()
223 best = matcher.getBestMatch("en_US", errorCode); in testBasics()
225 best = matcher.getBestMatch("fr_FR", errorCode); in testBasics()
227 best = matcher.getBestMatch("ja_JP", errorCode); in testBasics()
231 LocaleMatcher::Result result = matcher.getBestMatchResult(desired, errorCode); in testBasics()
239 LocalePriorityList list2("ja-JP, en-US", errorCode); in testBasics()
241 result = matcher.getBestMatchResult(iter2, errorCode); in testBasics()
247 result = matcher.getBestMatchResult(desired, errorCode); in testBasics()
254 result = matcher.getBestMatchResult("ja_JP", errorCode); in testBasics()
264 IcuTestErrorCode errorCode(*this, "testSupportedDefault"); in testSupportedDefault() local
269 build(errorCode); in testSupportedDefault()
270 const Locale *best = matcher.getBestMatch("en_GB", errorCode); in testSupportedDefault()
272 best = matcher.getBestMatch("en_US", errorCode); in testSupportedDefault()
274 best = matcher.getBestMatch("fr_FR", errorCode); in testSupportedDefault()
276 best = matcher.getBestMatch("ja_JP", errorCode); in testSupportedDefault()
278 LocaleMatcher::Result result = matcher.getBestMatchResult("ja_JP", errorCode); in testSupportedDefault()
287 IcuTestErrorCode errorCode(*this, "testUnsupportedDefault"); in testUnsupportedDefault() local
293 build(errorCode); in testUnsupportedDefault()
294 const Locale *best = matcher.getBestMatch("en_GB", errorCode); in testUnsupportedDefault()
296 best = matcher.getBestMatch("en_US", errorCode); in testUnsupportedDefault()
298 best = matcher.getBestMatch("fr_FR", errorCode); in testUnsupportedDefault()
300 best = matcher.getBestMatch("ja_JP", errorCode); in testUnsupportedDefault()
302 LocaleMatcher::Result result = matcher.getBestMatchResult("ja_JP", errorCode); in testUnsupportedDefault()
311 IcuTestErrorCode errorCode(*this, "testNoDefault"); in testNoDefault() local
316 build(errorCode); in testNoDefault()
317 const Locale *best = matcher.getBestMatch("en_GB", errorCode); in testNoDefault()
319 best = matcher.getBestMatch("en_US", errorCode); in testNoDefault()
321 best = matcher.getBestMatch("fr_FR", errorCode); in testNoDefault()
323 best = matcher.getBestMatch("ja_JP", errorCode); in testNoDefault()
325 LocaleMatcher::Result result = matcher.getBestMatchResult("ja_JP", errorCode); in testNoDefault()
333 IcuTestErrorCode errorCode(*this, "testDemotion"); in testDemotion() local
339 setDemotionPerDesiredLocale(ULOCMATCH_DEMOTION_NONE).build(errorCode); in testDemotion()
342 "de_CH", locString(noDemotion.getBestMatch(desiredIter, errorCode))); in testDemotion()
348 setDemotionPerDesiredLocale(ULOCMATCH_DEMOTION_REGION).build(errorCode); in testDemotion()
351 "fr", locString(regionDemotion.getBestMatch(desiredIter, errorCode))); in testDemotion()
356 IcuTestErrorCode errorCode(*this, "testDirection"); in testDirection() local
365 LocaleMatcher built = builder.build(errorCode); in testDirection()
369 locString(withOneWay.getBestMatch(desiredIter, errorCode))); in testDirection()
375 LocaleMatcher onlyTwoWay = builder.build(errorCode); in testDirection()
377 builder.setDirection(ULOCMATCH_DIRECTION_ONLY_TWO_WAY).build(errorCode); in testDirection()
381 locString(onlyTwoWay.getBestMatch(desiredIter, errorCode))); in testDirection()
386 IcuTestErrorCode errorCode(*this, "testMaxDistanceAndIsMatch"); in testMaxDistanceAndIsMatch() local
388 LocaleMatcher standard = builder.build(errorCode); in testMaxDistanceAndIsMatch()
392 assertTrue("standard de-LU / de", standard.isMatch(germanLux, Locale::getGerman(), errorCode)); in testMaxDistanceAndIsMatch()
394 standard.isMatch(germanPhoenician, Locale::getGerman(), errorCode)); in testMaxDistanceAndIsMatch()
398 builder.setMaxDistance(germanPhoenician, Locale::getGerman()).build(errorCode); in testMaxDistanceAndIsMatch()
399 assertTrue("loose de-LU / de", loose.isMatch(germanLux, Locale::getGerman(), errorCode)); in testMaxDistanceAndIsMatch()
401 loose.isMatch(germanPhoenician, Locale::getGerman(), errorCode)); in testMaxDistanceAndIsMatch()
402 assertFalse("loose el / de", loose.isMatch(greek, Locale::getGerman(), errorCode)); in testMaxDistanceAndIsMatch()
406 builder.setMaxDistance(Locale("de-AT"), Locale::getGerman()).build(errorCode); in testMaxDistanceAndIsMatch()
408 regional.isMatch(Locale("de-LU"), Locale::getGerman(), errorCode)); in testMaxDistanceAndIsMatch()
409 assertFalse("regional da / no", regional.isMatch(Locale("da"), Locale("no"), errorCode)); in testMaxDistanceAndIsMatch()
411 regional.isMatch(Locale::getChinese(), Locale::getTraditionalChinese(), errorCode)); in testMaxDistanceAndIsMatch()
416 IcuTestErrorCode errorCode(*this, "testMatch"); in testMatch() local
417 LocaleMatcher matcher = LocaleMatcher::Builder().build(errorCode); in testMatch()
421 assertEquals("exact match", 1.0, matcher.internalMatch(en_CA, en_CA, errorCode)); in testMatch()
425 double match = matcher.internalMatch(ar_MK, en_CA, errorCode); in testMatch()
432 double matchZh = matcher.internalMatch(und_TW, zh, errorCode); in testMatch()
433 double matchZhHant = matcher.internalMatch(und_TW, zh_Hant, errorCode); in testMatch()
437 double matchEnHantTw = matcher.internalMatch(en_Hant_TW, zh_Hant, errorCode); in testMatch()
445 IcuTestErrorCode errorCode(*this, "testResolvedLocale"); in testResolvedLocale() local
448 build(errorCode); in testResolvedLocale()
450 LocaleMatcher::Result result = matcher.getBestMatchResult(desired, errorCode); in testResolvedLocale()
452 Locale resolved = result.makeResolvedLocale(errorCode); in testResolvedLocale()
455 resolved.toLanguageTag<std::string>(errorCode).data()); in testResolvedLocale()
460 bool toInvariant(const UnicodeString &s, CharString &inv, ErrorCode &errorCode) { in toInvariant() argument
461 if (errorCode.isSuccess()) { in toInvariant()
462 inv.clear().appendInvariantChars(s, errorCode); in toInvariant()
463 return errorCode.isSuccess(); in toInvariant()
480 ErrorCode &errorCode) { in getInvariantSuffixAfterPrefix() argument
483 toInvariant(u_suffix, suffix, errorCode); in getInvariantSuffixAfterPrefix()
486 bool readTestCase(const UnicodeString &line, TestCase &test, IcuTestErrorCode &errorCode) { in readTestCase() argument
487 if (errorCode.isFailure()) { return false; } in readTestCase()
510 test.supported, errorCode)) { in readTestCase()
512 test.def, errorCode)) { in readTestCase()
519 toInvariant(line.tempSubStringBetween(0, matchSep).trim(), test.desired, errorCode); in readTestCase()
526 test.expMatch, errorCode); in readTestCase()
529 test.expMatch, errorCode); in readTestCase()
534 test.expDesired, errorCode); in readTestCase()
537 test.expDesired, errorCode); in readTestCase()
539 test.expCombined, errorCode); in readTestCase()
542 return errorCode.isSuccess(); in readTestCase()
544 errorCode.set(U_INVALID_FORMAT_ERROR); in readTestCase()
560 UBool LocaleMatcherTest::dataDriven(const TestCase &test, IcuTestErrorCode &errorCode) { in dataDriven() argument
586 LocaleMatcher matcher = builder.build(errorCode); in dataDriven()
587 if (errorCode.errIfFailureAndReset("LocaleMatcher::Builder::build()")) { in dataDriven()
595 const Locale *bestSupported = matcher.getBestMatchForListString(desiredSP, errorCode); in dataDriven()
600 LocalePriorityList desired(test.desired.toStringPiece(), errorCode); in dataDriven()
604 bestSupported = matcher.getBestMatch(desiredLocale, errorCode); in dataDriven()
608 LocaleMatcher::Result result = matcher.getBestMatchResult(desiredLocale, errorCode); in dataDriven()
612 bestSupported = matcher.getBestMatch(desiredIter, errorCode); in dataDriven()
617 LocalePriorityList desired(test.desired.toStringPiece(), errorCode); in dataDriven()
619 LocaleMatcher::Result result = matcher.getBestMatchResult(desiredIter, errorCode); in dataDriven()
636 Locale combined = result.makeResolvedLocale(errorCode); in dataDriven()
645 IcuTestErrorCode errorCode(*this, "testDataDriven"); in testDataDriven() local
646 CharString path(getSourceTestData(errorCode), errorCode); in testDataDriven()
647 path.appendPathPart("localeMatcherTest.txt", errorCode); in testDataDriven()
649 LocalUCHARBUFPointer f(ucbuf_open(path.data(), &codePage, TRUE, FALSE, errorCode)); in testDataDriven()
650 if(errorCode.errIfFailureAndReset("ucbuf_open(localeMatcherTest.txt)")) { in testDataDriven()
658 while ((p = ucbuf_readline(f.getAlias(), &lineLength, errorCode)) != nullptr && in testDataDriven()
659 errorCode.isSuccess()) { in testDataDriven()
661 if (!readTestCase(line, test, errorCode)) { in testDataDriven()
662 if (errorCode.errIfFailureAndReset( in testDataDriven()
668 UBool ok = dataDriven(test, errorCode); in testDataDriven()
669 if (errorCode.errIfFailureAndReset("test error on line %d", (int)test.lineNr)) { in testDataDriven()