Home | History | Annotate | Download | only in intltest

Lines Matching refs:trie

64     void checkFirst(BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
65 void checkNext(BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
66 void checkNextWithState(BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
67 void checkNextString(BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
68 void checkIterator(const BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
310 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_FAST));
311 if(trie.isNull()) {
315 if(trie->hasUniqueValue(uniqueValue)) {
318 trie->next('j');
319 trie->next('a');
320 trie->next('n');
322 if(!trie->hasUniqueValue(uniqueValue) || uniqueValue!=1) {
325 trie->first('j');
326 trie->next('u');
327 if(trie->hasUniqueValue(uniqueValue)) {
330 if(trie->next('n')!=USTRINGTRIE_INTERMEDIATE_VALUE || 6!=trie->getValue()) {
334 if(!trie->hasUniqueValue(uniqueValue) || uniqueValue!=6) {
338 trie->first('a');
339 trie->next('u');
340 if(!trie->hasUniqueValue(uniqueValue) || uniqueValue!=8) {
346 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_SMALL));
347 if(trie.isNull()) {
352 int32_t count=trie->getNextBytes(sink);
356 trie->next('j');
357 trie->next('a');
358 trie->next('n');
360 count=trie->getNextBytes(sink.Reset());
366 trie->getValue(); // next() had returned USTRINGTRIE_INTERMEDIATE_VALUE.
368 count=trie->getNextBytes(sink.Reset());
373 trie->next('u');
375 count=trie->getNextBytes(sink.Reset());
379 trie->next('a');
381 count=trie->getNextBytes(sink.Reset());
385 trie->next('r');
386 trie->next('y');
388 count=trie->getNextBytes(sink.Reset());
395 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_FAST));
396 if(trie.isNull()) {
400 trie->next('j');
401 trie->next('a');
402 trie->next('n');
404 BytesTrie::Iterator iter(*trie, 0, errorCode);
405 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
444 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_SMALL));
445 if(trie.isNull()) {
449 trie->next('j');
450 trie->next('a');
451 trie->next('n');
452 trie->next('u');
453 trie->next('a');
455 BytesTrie::Iterator iter(*trie, 0, errorCode);
456 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
472 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_FAST));
473 if(trie.isNull()) {
477 BytesTrie::Iterator iter(*trie, 4, errorCode);
478 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
523 LocalPointer<BytesTrie> trie(buildTrie(data, UPRV_LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
524 if(trie.isNull()) {
528 trie->next('a');
529 trie->next('b');
532 BytesTrie::Iterator iter(*trie, 2, errorCode);
533 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
551 LocalPointer<BytesTrie> trie(buildTrie(data, UPRV_LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
552 if(trie.isNull()) {
556 trie->next('a');
557 trie->next('b');
558 trie->next('c');
561 BytesTrie::Iterator iter(*trie, 3, errorCode);
562 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
609 LocalPointer<BytesTrie> trie(buildTrie(data, dataLength, buildOption));
610 if(trie.isNull()) {
613 checkFirst(*trie, data, dataLength);
614 checkNext(*trie, data, dataLength);
615 checkNextWithState(*trie, data, dataLength);
616 checkNextString(*trie, data, dataLength);
617 checkIterator(*trie, data, dataLength);
623 // Add the items to the trie builder in an interesting (not trivial, not random) order.
643 LocalPointer<BytesTrie> trie(builder_->build(buildOption, errorCode));
650 logln("serialized trie size: %ld bytes\n", (long)sp.length());
662 return trie.orphan();
668 void BytesTrieTest::checkFirst(BytesTrie &trie,
675 UStringTrieResult firstResult=trie.first(c);
676 int32_t firstValue=USTRINGTRIE_HAS_VALUE(firstResult) ? trie.getValue() : -1;
677 UStringTrieResult nextResult=trie.next(data[i].s[1]);
678 if(firstResult!=trie.reset().next(c) ||
679 firstResult!=trie.current() ||
680 firstValue!=(USTRINGTRIE_HAS_VALUE(firstResult) ? trie.getValue() : -1) ||
681 nextResult!=trie.next(data[i].s[1])
683 errln("trie.first(%c)!=trie.reset().next(same) for %s",
687 trie.reset();
690 void BytesTrieTest::checkNext(BytesTrie &trie,
696 if( !USTRINGTRIE_HAS_VALUE(result=trie.next(data[i].s, stringLength)) ||
697 result!=trie.current()
699 errln("trie does not seem to contain %s", data[i].s);
700 } else if(trie.getValue()!=data[i].value) {
701 errln("trie value for %s is %ld=0x%lx instead of expected %ld=0x%lx",
703 (long)trie.getValue(), (long)trie.getValue(),
705 } else if(result!=trie.current() || trie.getValue()!=data[i].value) {
706 errln("trie value for %s changes when repeating current()/getValue()", data[i].s);
708 trie.reset();
710 result=trie.current();
713 errln("trie.current()!=hasNext before end of %s (at index %d)", data[i].s, j);
717 trie.getValue();
718 if(trie.current()!=USTRINGTRIE_INTERMEDIATE_VALUE) {
719 errln("trie.getValue().current()!=USTRINGTRIE_INTERMEDIATE_VALUE before end of %s (at index %d)", data[i].s, j);
723 result=trie.next(data[i].s[j]);
725 errln("trie.next()=USTRINGTRIE_NO_MATCH before end of %s (at index %d)", data[i].s, j);
728 if(result!=trie.current()) {
729 errln("trie.next()!=following current() before end of %s (at index %d)", data[i].s, j);
734 errln("trie.next()!=hasValue at the end of %s", data[i].s);
737 trie.getValue();
738 if(result!=trie.current()) {
739 errln("trie.current() != current()+getValue()+current() after end of %s",
743 trie.saveState(state);
757 if(trie.resetToState(state).next(c)) {
763 errln("(trie.current()==USTRINGTRIE_INTERMEDIATE_VALUE) contradicts "
764 "(trie.next(some byte)!=USTRINGTRIE_NO_MATCH) after end of %s", data[i].s);
766 trie.reset();
770 void BytesTrieTest::checkNextWithState(BytesTrie &trie,
776 trie.resetToState(noState);
782 if(!USTRINGTRIE_MATCHES(trie.next(expectedString[j]))) {
783 errln("trie.next()=USTRINGTRIE_NO_MATCH for a prefix of %s", data[i].s);
787 trie.saveState(state);
788 UStringTrieResult resultAtState=trie.current();
792 valueAtState=trie.getValue();
794 result=trie.next(0); // mismatch
795 if(result!=USTRINGTRIE_NO_MATCH || result!=trie.current()) {
796 errln("trie.next(0) matched after part of %s", data[i].s);
798 if( resultAtState!=trie.resetToState(state).current() ||
799 (USTRINGTRIE_HAS_VALUE(resultAtState) && valueAtState!=trie.getValue())
801 errln("trie.next(part of %s) changes current()/getValue() after "
805 result=trie.next(expectedString+partialLength,
807 result!=trie.current()) {
808 errln("trie.next(rest of %s) does not seem to contain %s after "
812 result=trie.resetToState(state).
815 result!=trie.current()) {
816 errln("trie does not seem to contain %s after saveState/next(rest)/resetToState",
818 } else if(trie.getValue()!=data[i].value) {
819 errln("trie value for %s is %ld=0x%lx instead of expected %ld=0x%lx",
821 (long)trie.getValue(), (long)trie.getValue(),
824 trie.reset();
830 void BytesTrieTest::checkNextString(BytesTrie &trie,
835 if(!trie.next(expectedString, stringLength/2)) {
836 errln("trie.next(up to middle of string)=USTRINGTRIE_NO_MATCH for %s", data[i].s);
840 if(trie.next(expectedString+stringLength/2, stringLength+1-stringLength/2)) {
841 errln("trie.next(string+NUL)!=USTRINGTRIE_NO_MATCH for %s", data[i].s);
843 trie.reset();
847 void BytesTrieTest::checkIterator(const BytesTrie &trie,
850 BytesTrie::Iterator iter(trie, 0, errorCode);
851 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
862 errln("trie iterator hasNext()=FALSE for item %d: %s", (int)i, data[i].s);
866 if(errorCode.logIfFailureAndReset("trie iterator next() for item %d: %s", (int)i, data[i].s)) {
870 errln("trie iterator next()=FALSE for item %d: %s", (int)i, data[i].s);
874 errln("trie iterator next().getString()=%s but expected %s for item %d",
878 errln("trie iterator next().getValue()=%ld=0x%lx but expected %ld=0x%lx for item %d: %s",
885 errln("trie iterator hasNext()=TRUE after all items");
888 errorCode.logIfFailureAndReset("trie iterator next() after all items");
890 errln("trie iterator next()=TRUE after all items");