Home | History | Annotate | Download | only in intltest

Lines Matching refs:trie

70     void checkFirst(UCharsTrie &trie, const StringAndValue data[], int32_t dataLength);
71 void checkNext(UCharsTrie &trie, const StringAndValue data[], int32_t dataLength);
72 void checkNextWithState(UCharsTrie &trie, const StringAndValue data[], int32_t dataLength);
73 void checkNextString(UCharsTrie &trie, const StringAndValue data[], int32_t dataLength);
74 void checkIterator(UCharsTrie &trie, const StringAndValue data[], int32_t dataLength);
297 LocalPointer<UCharsTrie> trie(buildTrie(data, UPRV_LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
298 if(trie.isNull()) {
302 if( (result=trie->nextForCodePoint(0x4dff))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
303 (result=trie->nextForCodePoint(0x10000))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
304 (result=trie->nextForCodePoint(0x9999))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
305 (result=trie->nextForCodePoint(0x20000))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
306 (result=trie->nextForCodePoint(0xdfff))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
307 (result=trie->nextForCodePoint(0x10ffff))!=USTRINGTRIE_FINAL_VALUE || result!=trie->current() ||
308 trie->getValue()!=2000000000
312 if( (result=trie->firstForCodePoint(0x4dff))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
313 (result=trie->nextForCodePoint(0x10000))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
314 (result=trie->nextForCodePoint(0x9999))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
315 (result=trie->nextForCodePoint(0x20002))!=USTRINGTRIE_FINAL_VALUE || result!=trie->current() ||
316 trie->getValue()!=44444
320 if( (result=trie->reset().nextForCodePoint(0x4dff))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
321 (result=trie->nextForCodePoint(0x10000))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
322 (result=trie->nextForCodePoint(0x9999))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
323 (result=trie->nextForCodePoint(0x20222))!=USTRINGTRIE_NO_MATCH || result!=trie->current() // no match for trail surrogate
327 if( (result=trie->reset().nextForCodePoint(0x4dff))!=USTRINGTRIE_NO_VALUE || result!=trie->current() ||
328 (result=trie->nextForCodePoint(0x103ff))!=USTRINGTRIE_FINAL_VALUE || result!=trie->current() ||
329 trie->getValue()!=99999
380 logln("serialized trie size: %ld UChars\n", (long)trieUChars.length());
386 LocalPointer<UCharsTrie> trie(buildLargeTrie(1111));
387 if(trie.isNull()) {
395 if(trie->first(x[0])==USTRINGTRIE_NO_MATCH) {
402 UStringTrieResult result=trie->next(x.getBuffer(), x.length());
403 if(!USTRINGTRIE_HAS_VALUE(result) || result!=trie->current() || value!=trie->getValue()) {
465 LocalPointer<UCharsTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_FAST));
466 if(trie.isNull()) {
470 if(trie->hasUniqueValue(uniqueValue)) {
473 trie->next(u_j);
474 trie->next(u_a);
475 trie->next(u_n);
477 if(!trie->hasUniqueValue(uniqueValue) || uniqueValue!=1) {
480 trie->first(u_j);
481 trie->next(u_u);
482 if(trie->hasUniqueValue(uniqueValue)) {
485 if(trie->next(u_n)!=USTRINGTRIE_INTERMEDIATE_VALUE || 6!=trie->getValue()) {
489 if(!trie->hasUniqueValue(uniqueValue) || uniqueValue!=6) {
493 trie->first(u_a);
494 trie->next(u_u);
495 if(!trie->hasUniqueValue(uniqueValue) || uniqueValue!=8) {
501 LocalPointer<UCharsTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_SMALL));
502 if(trie.isNull()) {
507 int32_t count=trie->getNextUChars(app);
511 trie->next(u_j);
512 trie->next(u_a);
513 trie->next(u_n);
516 count=trie->getNextUChars(app);
521 trie->getValue(); // next() had returned USTRINGTRIE_INTERMEDIATE_VALUE.
523 count=trie->getNextUChars(app);
528 trie->next(u_u);
530 count=trie->getNextUChars(app);
534 trie->next(u_a);
536 count=trie->getNextUChars(app);
540 trie->next(u_r);
541 trie->next(u_y);
544 count=trie->getNextUChars(app);
551 LocalPointer<UCharsTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_FAST));
552 if(trie.isNull()) {
556 trie->next(u_j);
557 trie->next(u_a);
558 trie->next(u_n);
560 UCharsTrie::Iterator iter(*trie, 0, errorCode);
561 if(errorCode.logIfFailureAndReset("UCharsTrie::Iterator(trie) constructor")) {
600 LocalPointer<UCharsTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_SMALL));
601 if(trie.isNull()) {
605 trie->next(u_j);
606 trie->next(u_a);
607 trie->next(u_n);
608 trie->next(u_u);
609 trie->next(u_a);
611 UCharsTrie::Iterator iter(*trie, 0, errorCode);
612 if(errorCode.logIfFailureAndReset("UCharsTrie::Iterator(trie) constructor")) {
628 LocalPointer<UCharsTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_FAST));
629 if(trie.isNull()) {
633 UCharsTrie::Iterator iter(*trie, 4, errorCode);
634 if(errorCode.logIfFailureAndReset("UCharsTrie::Iterator(trie) constructor")) {
679 LocalPointer<UCharsTrie> trie(buildTrie(data, UPRV_LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
680 if(trie.isNull()) {
684 trie->next(u_a);
685 trie->next(u_b);
688 UCharsTrie::Iterator iter(*trie, 2, errorCode);
689 if(errorCode.logIfFailureAndReset("UCharsTrie::Iterator(trie) constructor")) {
707 LocalPointer<UCharsTrie> trie(buildTrie(data, UPRV_LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
708 if(trie.isNull()) {
712 trie->next(u_a);
713 trie->next(u_b);
714 trie->next(u_c);
717 UCharsTrie::Iterator iter(*trie, 3, errorCode);
718 if(errorCode.logIfFailureAndReset("UCharsTrie::Iterator(trie) constructor")) {
757 LocalPointer<UCharsTrie> trie(buildTrie(data, dataLength, buildOption));
758 if(trie.isNull()) {
761 checkFirst(*trie, data, dataLength);
762 checkNext(*trie, data, dataLength);
763 checkNextWithState(*trie, data, dataLength);
764 checkNextString(*trie, data, dataLength);
765 checkIterator(*trie, data, dataLength);
771 // Add the items to the trie builder in an interesting (not trivial, not random) order.
793 LocalPointer<UCharsTrie> trie(builder_->build(buildOption, errorCode));
800 logln("serialized trie size: %ld UChars\n", (long)trieUChars.length());
813 return trie.orphan();
819 void UCharsTrieTest::checkFirst(UCharsTrie &trie,
828 UStringTrieResult firstResult=trie.first(c);
829 int32_t firstValue=USTRINGTRIE_HAS_VALUE(firstResult) ? trie.getValue() : -1;
830 UStringTrieResult nextResult=trie.next(nextCp);
831 if(firstResult!=trie.reset().next(c) ||
832 firstResult!=trie.current() ||
833 firstValue!=(USTRINGTRIE_HAS_VALUE(firstResult) ? trie.getValue() : -1) ||
834 nextResult!=trie.next(nextCp)
836 errln("trie.first(U+%04X)!=trie.reset().next(same) for %s",
842 firstResult=trie.firstForCodePoint(c);
843 firstValue=USTRINGTRIE_HAS_VALUE(firstResult) ? trie.getValue() : -1;
844 nextResult=trie.nextForCodePoint(nextCp);
845 if(firstResult!=trie.reset().nextForCodePoint(c) ||
846 firstResult!=trie.current() ||
847 firstValue!=(USTRINGTRIE_HAS_VALUE(firstResult) ? trie.getValue() : -1) ||
848 nextResult!=trie.nextForCodePoint(nextCp)
850 errln("trie.firstForCodePoint(U+%04X)!=trie.reset().nextForCodePoint(same) for %s",
854 trie.reset();
857 void UCharsTrieTest::checkNext(UCharsTrie &trie,
865 result=trie.next(expectedString.getTerminatedBuffer(), stringLength)) ||
866 result!=trie.current()
868 errln("trie does not seem to contain %s", data[i].s);
869 } else if(trie.getValue()!=data[i].value) {
870 errln("trie value for %s is %ld=0x%lx instead of expected %ld=0x%lx",
872 (long)trie.getValue(), (long)trie.getValue(),
874 } else if(result!=trie.current() || trie.getValue()!=data[i].value) {
875 errln("trie value for %s changes when repeating current()/getValue()", data[i].s);
877 trie.reset();
879 result=trie.current();
882 errln("trie.current()!=hasNext before end of %s (at index %d)", data[i].s, j);
886 trie.getValue();
887 if(trie.current()!=USTRINGTRIE_INTERMEDIATE_VALUE) {
888 errln("trie.getValue().current()!=USTRINGTRIE_INTERMEDIATE_VALUE before end of %s (at index %d)", data[i].s, j);
892 result=trie.next(expectedString[j]);
894 errln("trie.next()=USTRINGTRIE_NO_MATCH before end of %s (at index %d)", data[i].s, j);
897 if(result!=trie.current()) {
898 errln("trie.next()!=following current() before end of %s (at index %d)", data[i].s, j);
903 errln("trie.next()!=hasValue at the end of %s", data[i].s);
906 trie.getValue();
907 if(result!=trie.current()) {
908 errln("trie.current() != current()+getValue()+current() after end of %s",
912 trie.saveState(state);
918 if(trie.resetToState(state).next(c)) {
924 errln("(trie.current()==USTRINGTRIE_INTERMEDIATE_VALUE) contradicts "
925 "(trie.next(some UChar)!=USTRINGTRIE_NO_MATCH) after end of %s", data[i].s);
927 trie.reset();
931 void UCharsTrieTest::checkNextWithState(UCharsTrie &trie,
937 trie.resetToState(noState);
943 if(!USTRINGTRIE_MATCHES(trie.next(expectedString[j]))) {
944 errln("trie.next()=USTRINGTRIE_NO_MATCH for a prefix of %s", data[i].s);
948 trie.saveState(state);
949 UStringTrieResult resultAtState=trie.current();
953 valueAtState=trie.getValue();
955 result=trie.next(0); // mismatch
956 if(result!=USTRINGTRIE_NO_MATCH || result!=trie.current()) {
957 errln("trie.next(0) matched after part of %s", data[i].s);
959 if( resultAtState!=trie.resetToState(state).current() ||
960 (USTRINGTRIE_HAS_VALUE(resultAtState) && valueAtState!=trie.getValue())
962 errln("trie.next(part of %s) changes current()/getValue() after "
966 result=trie.next(expectedString.getTerminatedBuffer()+partialLength,
968 result!=trie.current()) {
969 errln("trie.next(rest of %s) does not seem to contain %s after "
973 result=trie.resetToState(state).
976 result!=trie.current()) {
977 errln("trie does not seem to contain %s after saveState/next(rest)/resetToState",
979 } else if(trie.getValue()!=data[i].value) {
980 errln("trie value for %s is %ld=0x%lx instead of expected %ld=0x%lx",
982 (long)trie.getValue(), (long)trie.getValue(),
985 trie.reset();
991 void UCharsTrieTest::checkNextString(UCharsTrie &trie,
996 if(!trie.next(expectedString.getTerminatedBuffer(), stringLength/2)) {
997 errln("trie.next(up to middle of string)=USTRINGTRIE_NO_MATCH for %s", data[i].s);
1001 if(trie.next(expectedString.getTerminatedBuffer()+stringLength/2,
1003 errln("trie.next(string+NUL)!=USTRINGTRIE_NO_MATCH for %s", data[i].s);
1005 trie.reset();
1009 void UCharsTrieTest::checkIterator(UCharsTrie &trie,
1012 UCharsTrie::Iterator iter(trie, 0, errorCode);
1024 errln("trie iterator hasNext()=FALSE for item %d: %s", (int)i, data[i].s);
1028 if(errorCode.logIfFailureAndReset("trie iterator next() for item %d: %s", (int)i, data[i].s)) {
1032 errln("trie iterator next()=FALSE for item %d: %s", (int)i, data[i].s);
1040 errln("trie iterator next().getString()=%s but expected %s for item %d",
1044 errln("trie iterator next().getValue()=%ld=0x%lx but expected %ld=0x%lx for item %d: %s",
1051 errln("trie iterator hasNext()=TRUE after all items");
1054 errorCode.logIfFailureAndReset("trie iterator next() after all items");
1056 errln("trie iterator next()=TRUE after all items");