Home | History | Annotate | Download | only in intltest

Lines Matching full:trie

62     void checkFirst(BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
63 void checkNext(BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
64 void checkNextWithState(BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
65 void checkNextString(BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
66 void checkIterator(const BytesTrie &trie, const StringAndValue data[], int32_t dataLength);
307 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_FAST));
308 if(trie.isNull()) {
312 if(trie->hasUniqueValue(uniqueValue)) {
315 trie->next('j');
316 trie->next('a');
317 trie->next('n');
319 if(!trie->hasUniqueValue(uniqueValue) || uniqueValue!=1) {
322 trie->first('j');
323 trie->next('u');
324 if(trie->hasUniqueValue(uniqueValue)) {
327 if(trie->next('n')!=USTRINGTRIE_INTERMEDIATE_VALUE || 6!=trie->getValue()) {
331 if(!trie->hasUniqueValue(uniqueValue) || uniqueValue!=6) {
335 trie->first('a');
336 trie->next('u');
337 if(!trie->hasUniqueValue(uniqueValue) || uniqueValue!=8) {
343 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_SMALL));
344 if(trie.isNull()) {
349 int32_t count=trie->getNextBytes(sink);
353 trie->next('j');
354 trie->next('a');
355 trie->next('n');
357 count=trie->getNextBytes(sink.Reset());
363 trie->getValue(); // next() had returned USTRINGTRIE_INTERMEDIATE_VALUE.
365 count=trie->getNextBytes(sink.Reset());
370 trie->next('u');
372 count=trie->getNextBytes(sink.Reset());
376 trie->next('a');
378 count=trie->getNextBytes(sink.Reset());
382 trie->next('r');
383 trie->next('y');
385 count=trie->getNextBytes(sink.Reset());
392 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_FAST));
393 if(trie.isNull()) {
397 trie->next('j');
398 trie->next('a');
399 trie->next('n');
401 BytesTrie::Iterator iter(*trie, 0, errorCode);
402 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
441 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_SMALL));
442 if(trie.isNull()) {
446 trie->next('j');
447 trie->next('a');
448 trie->next('n');
449 trie->next('u');
450 trie->next('a');
452 BytesTrie::Iterator iter(*trie, 0, errorCode);
453 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
469 LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_FAST));
470 if(trie.isNull()) {
474 BytesTrie::Iterator iter(*trie, 4, errorCode);
475 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
520 LocalPointer<BytesTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
521 if(trie.isNull()) {
525 trie->next('a');
526 trie->next('b');
529 BytesTrie::Iterator iter(*trie, 2, errorCode);
530 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
548 LocalPointer<BytesTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
549 if(trie.isNull()) {
553 trie->next('a');
554 trie->next('b');
555 trie->next('c');
558 BytesTrie::Iterator iter(*trie, 3, errorCode);
559 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
597 LocalPointer<BytesTrie> trie(buildTrie(data, dataLength, buildOption));
598 if(trie.isNull()) {
601 checkFirst(*trie, data, dataLength);
602 checkNext(*trie, data, dataLength);
603 checkNextWithState(*trie, data, dataLength);
604 checkNextString(*trie, data, dataLength);
605 checkIterator(*trie, data, dataLength);
611 // Add the items to the trie builder in an interesting (not trivial, not random) order.
631 LocalPointer<BytesTrie> trie(builder_->build(buildOption, errorCode));
638 logln("serialized trie size: %ld bytes\n", (long)sp.length());
650 return trie.orphan();
656 void BytesTrieTest::checkFirst(BytesTrie &trie,
663 UStringTrieResult firstResult=trie.first(c);
664 int32_t firstValue=USTRINGTRIE_HAS_VALUE(firstResult) ? trie.getValue() : -1;
665 UStringTrieResult nextResult=trie.next(data[i].s[1]);
666 if(firstResult!=trie.reset().next(c) ||
667 firstResult!=trie.current() ||
668 firstValue!=(USTRINGTRIE_HAS_VALUE(firstResult) ? trie.getValue() : -1) ||
669 nextResult!=trie.next(data[i].s[1])
671 errln("trie.first(%c)!=trie.reset().next(same) for %s",
675 trie.reset();
678 void BytesTrieTest::checkNext(BytesTrie &trie,
684 if( !USTRINGTRIE_HAS_VALUE(result=trie.next(data[i].s, stringLength)) ||
685 result!=trie.current()
687 errln("trie does not seem to contain %s", data[i].s);
688 } else if(trie.getValue()!=data[i].value) {
689 errln("trie value for %s is %ld=0x%lx instead of expected %ld=0x%lx",
691 (long)trie.getValue(), (long)trie.getValue(),
693 } else if(result!=trie.current() || trie.getValue()!=data[i].value) {
694 errln("trie value for %s changes when repeating current()/getValue()", data[i].s);
696 trie.reset();
698 result=trie.current();
701 errln("trie.current()!=hasNext before end of %s (at index %d)", data[i].s, j);
705 trie.getValue();
706 if(trie.current()!=USTRINGTRIE_INTERMEDIATE_VALUE) {
707 errln("trie.getValue().current()!=USTRINGTRIE_INTERMEDIATE_VALUE before end of %s (at index %d)", data[i].s, j);
711 result=trie.next(data[i].s[j]);
713 errln("trie.next()=USTRINGTRIE_NO_MATCH before end of %s (at index %d)", data[i].s, j);
716 if(result!=trie.current()) {
717 errln("trie.next()!=following current() before end of %s (at index %d)", data[i].s, j);
722 errln("trie.next()!=hasValue at the end of %s", data[i].s);
725 trie.getValue();
726 if(result!=trie.current()) {
727 errln("trie.current() != current()+getValue()+current() after end of %s",
731 trie.saveState(state);
745 if(trie.resetToState(state).next(c)) {
751 errln("(trie.current()==USTRINGTRIE_INTERMEDIATE_VALUE) contradicts "
752 "(trie.next(some byte)!=USTRINGTRIE_NO_MATCH) after end of %s", data[i].s);
754 trie.reset();
758 void BytesTrieTest::checkNextWithState(BytesTrie &trie,
764 trie.resetToState(noState);
770 if(!USTRINGTRIE_MATCHES(trie.next(expectedString[j]))) {
771 errln("trie.next()=USTRINGTRIE_NO_MATCH for a prefix of %s", data[i].s);
775 trie.saveState(state);
776 UStringTrieResult resultAtState=trie.current();
780 valueAtState=trie.getValue();
782 result=trie.next(0); // mismatch
783 if(result!=USTRINGTRIE_NO_MATCH || result!=trie.current()) {
784 errln("trie.next(0) matched after part of %s", data[i].s);
786 if( resultAtState!=trie.resetToState(state).current() ||
787 (USTRINGTRIE_HAS_VALUE(resultAtState) && valueAtState!=trie.getValue())
789 errln("trie.next(part of %s) changes current()/getValue() after "
793 result=trie.next(expectedString+partialLength,
795 result!=trie.current()) {
796 errln("trie.next(rest of %s) does not seem to contain %s after "
800 result=trie.resetToState(state).
803 result!=trie.current()) {
804 errln("trie does not seem to contain %s after saveState/next(rest)/resetToState",
806 } else if(trie.getValue()!=data[i].value) {
807 errln("trie value for %s is %ld=0x%lx instead of expected %ld=0x%lx",
809 (long)trie.getValue(), (long)trie.getValue(),
812 trie.reset();
818 void BytesTrieTest::checkNextString(BytesTrie &trie,
823 if(!trie.next(expectedString, stringLength/2)) {
824 errln("trie.next(up to middle of string)=USTRINGTRIE_NO_MATCH for %s", data[i].s);
828 if(trie.next(expectedString+stringLength/2, stringLength+1-stringLength/2)) {
829 errln("trie.next(string+NUL)!=USTRINGTRIE_NO_MATCH for %s", data[i].s);
831 trie.reset();
835 void BytesTrieTest::checkIterator(const BytesTrie &trie,
838 BytesTrie::Iterator iter(trie, 0, errorCode);
839 if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
850 errln("trie iterator hasNext()=FALSE for item %d: %s", (int)i, data[i].s);
854 if(errorCode.logIfFailureAndReset("trie iterator next() for item %d: %s", (int)i, data[i].s)) {
858 errln("trie iterator next()=FALSE for item %d: %s", (int)i, data[i].s);
862 errln("trie iterator next().getString()=%s but expected %s for item %d",
866 errln("trie iterator next().getValue()=%ld=0x%lx but expected %ld=0x%lx for item %d: %s",
873 errln("trie iterator hasNext()=TRUE after all items");
876 errorCode.logIfFailureAndReset("trie iterator next() after all items");
878 errln("trie iterator next()=TRUE after all items");