blob: f146bfaff55c21c141b7f406f3d4116cc98458d6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/containers/comptrie/comptrie.h>
#include <library/cpp/containers/comptrie/loader/loader.h>
using TDummyTrie = TCompactTrie<char, i32>;
namespace {
const unsigned char DATA[] = {
#include "data.inc"
};
}
Y_UNIT_TEST_SUITE(ArchiveLoaderTests) {
Y_UNIT_TEST(BaseTest) {
TDummyTrie trie = LoadTrieFromArchive<TDummyTrie>("/dummy.trie", DATA, true);
UNIT_ASSERT_EQUAL(trie.Size(), 3);
const TString TrieKyes[3] = {
"zero", "one", "two"};
i32 val = -1;
for (i32 i = 0; i < 3; ++i) {
UNIT_ASSERT(trie.Find(TrieKyes[i].data(), TrieKyes[i].size(), &val));
UNIT_ASSERT_EQUAL(i, val);
}
UNIT_CHECK_GENERATED_EXCEPTION(
LoadTrieFromArchive<TDummyTrie>("/noname.trie", DATA),
yexception);
}
}
|