MCPcopy Create free account
hub / github.com/catboost/catboost / TestPrefixGrouped

Method TestPrefixGrouped

library/cpp/containers/comptrie/comptrie_ut.cpp:778–821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

776}
777
778void TCompactTrieTest::TestPrefixGrouped() {
779 TBuffer b1b;
780 TCompactTrieBuilder<char, ui32> b1(CTBF_PREFIX_GROUPED);
781 const char* data[] = {
782 "Kazan",
783 "Moscow",
784 "Monino",
785 "Murmansk",
786 "Fryanovo",
787 "Fryazino",
788 "Fryazevo",
789 "Tumen",
790 };
791
792 for (size_t i = 0; i < Y_ARRAY_SIZE(data); ++i) {
793 ui32 val = strlen(data[i]) + 1;
794 b1.Add(data[i], strlen(data[i]), val);
795 for (size_t j = 0; j < Y_ARRAY_SIZE(data); ++j) {
796 ui32 mustHave = strlen(data[j]) + 1;
797 ui32 found = 0;
798 if (j <= i) {
799 UNIT_ASSERT(b1.Find(data[j], strlen(data[j]), &found));
800 UNIT_ASSERT_VALUES_EQUAL(mustHave, found);
801 } else {
802 UNIT_ASSERT(!b1.Find(data[j], strlen(data[j]), &found));
803 }
804 }
805 }
806
807 {
808 TBufferOutput b1bo(b1b);
809 b1.Save(b1bo);
810 }
811
812 TCompactTrie<char, ui32> t1(TBlob::FromBuffer(b1b));
813
814 //t1.Print(Cerr);
815
816 for (auto& i : data) {
817 ui32 v;
818 UNIT_ASSERT(t1.Find(i, strlen(i), &v));
819 UNIT_ASSERT_VALUES_EQUAL(strlen(i) + 1, v);
820 }
821}
822
823void TCompactTrieTest::CrashTestPrefixGrouped() {
824 TCompactTrieBuilder<char, ui32> builder(CTBF_PREFIX_GROUPED);

Callers

nothing calls this directly

Calls 3

AddMethod · 0.45
FindMethod · 0.45
SaveMethod · 0.45

Tested by

no test coverage detected