• Home
  • Raw
  • Download

Lines Matching refs:trie

15   marisa::Trie trie;  in TestEmptyTrie()  local
17 EXCEPT(trie.save("marisa-test.dat"), MARISA_STATE_ERROR); in TestEmptyTrie()
19 EXCEPT(trie.write(::_fileno(stdout)), MARISA_STATE_ERROR); in TestEmptyTrie()
21 EXCEPT(trie.write(::fileno(stdout)), MARISA_STATE_ERROR); in TestEmptyTrie()
23 EXCEPT(std::cout << trie, MARISA_STATE_ERROR); in TestEmptyTrie()
24 EXCEPT(marisa::fwrite(stdout, trie), MARISA_STATE_ERROR); in TestEmptyTrie()
28 EXCEPT(trie.lookup(agent), MARISA_STATE_ERROR); in TestEmptyTrie()
29 EXCEPT(trie.reverse_lookup(agent), MARISA_STATE_ERROR); in TestEmptyTrie()
30 EXCEPT(trie.common_prefix_search(agent), MARISA_STATE_ERROR); in TestEmptyTrie()
31 EXCEPT(trie.predictive_search(agent), MARISA_STATE_ERROR); in TestEmptyTrie()
33 EXCEPT(trie.num_tries(), MARISA_STATE_ERROR); in TestEmptyTrie()
34 EXCEPT(trie.num_keys(), MARISA_STATE_ERROR); in TestEmptyTrie()
35 EXCEPT(trie.num_nodes(), MARISA_STATE_ERROR); in TestEmptyTrie()
37 EXCEPT(trie.tail_mode(), MARISA_STATE_ERROR); in TestEmptyTrie()
38 EXCEPT(trie.node_order(), MARISA_STATE_ERROR); in TestEmptyTrie()
40 EXCEPT(trie.empty(), MARISA_STATE_ERROR); in TestEmptyTrie()
41 EXCEPT(trie.size(), MARISA_STATE_ERROR); in TestEmptyTrie()
42 EXCEPT(trie.total_size(), MARISA_STATE_ERROR); in TestEmptyTrie()
43 EXCEPT(trie.io_size(), MARISA_STATE_ERROR); in TestEmptyTrie()
46 trie.build(keyset); in TestEmptyTrie()
48 ASSERT(!trie.lookup(agent)); in TestEmptyTrie()
49 EXCEPT(trie.reverse_lookup(agent), MARISA_BOUND_ERROR); in TestEmptyTrie()
50 ASSERT(!trie.common_prefix_search(agent)); in TestEmptyTrie()
51 ASSERT(!trie.predictive_search(agent)); in TestEmptyTrie()
53 ASSERT(trie.num_tries() == 1); in TestEmptyTrie()
54 ASSERT(trie.num_keys() == 0); in TestEmptyTrie()
55 ASSERT(trie.num_nodes() == 1); in TestEmptyTrie()
57 ASSERT(trie.tail_mode() == MARISA_DEFAULT_TAIL); in TestEmptyTrie()
58 ASSERT(trie.node_order() == MARISA_DEFAULT_ORDER); in TestEmptyTrie()
60 ASSERT(trie.empty()); in TestEmptyTrie()
61 ASSERT(trie.size() == 0); in TestEmptyTrie()
62 ASSERT(trie.total_size() != 0); in TestEmptyTrie()
63 ASSERT(trie.io_size() != 0); in TestEmptyTrie()
66 trie.build(keyset); in TestEmptyTrie()
68 ASSERT(trie.lookup(agent)); in TestEmptyTrie()
69 trie.reverse_lookup(agent); in TestEmptyTrie()
70 ASSERT(trie.common_prefix_search(agent)); in TestEmptyTrie()
71 ASSERT(!trie.common_prefix_search(agent)); in TestEmptyTrie()
72 ASSERT(trie.predictive_search(agent)); in TestEmptyTrie()
73 ASSERT(!trie.predictive_search(agent)); in TestEmptyTrie()
75 ASSERT(trie.num_keys() == 1); in TestEmptyTrie()
76 ASSERT(trie.num_nodes() == 1); in TestEmptyTrie()
78 ASSERT(!trie.empty()); in TestEmptyTrie()
79 ASSERT(trie.size() == 1); in TestEmptyTrie()
80 ASSERT(trie.total_size() != 0); in TestEmptyTrie()
81 ASSERT(trie.io_size() != 0); in TestEmptyTrie()
96 marisa::Trie trie; in TestTinyTrie() local
97 trie.build(keyset, 1); in TestTinyTrie()
99 ASSERT(trie.num_tries() == 1); in TestTinyTrie()
100 ASSERT(trie.num_keys() == 4); in TestTinyTrie()
101 ASSERT(trie.num_nodes() == 7); in TestTinyTrie()
103 ASSERT(trie.tail_mode() == MARISA_DEFAULT_TAIL); in TestTinyTrie()
104 ASSERT(trie.node_order() == MARISA_DEFAULT_ORDER); in TestTinyTrie()
115 ASSERT(trie.lookup(agent)); in TestTinyTrie()
119 trie.reverse_lookup(agent); in TestTinyTrie()
126 ASSERT(!trie.common_prefix_search(agent)); in TestTinyTrie()
128 ASSERT(!trie.common_prefix_search(agent)); in TestTinyTrie()
130 ASSERT(trie.common_prefix_search(agent)); in TestTinyTrie()
131 ASSERT(!trie.common_prefix_search(agent)); in TestTinyTrie()
133 ASSERT(trie.common_prefix_search(agent)); in TestTinyTrie()
134 ASSERT(!trie.common_prefix_search(agent)); in TestTinyTrie()
137 ASSERT(!trie.predictive_search(agent)); in TestTinyTrie()
139 ASSERT(trie.predictive_search(agent)); in TestTinyTrie()
141 ASSERT(!trie.predictive_search(agent)); in TestTinyTrie()
144 ASSERT(trie.predictive_search(agent)); in TestTinyTrie()
146 ASSERT(!trie.predictive_search(agent)); in TestTinyTrie()
149 ASSERT(trie.predictive_search(agent)); in TestTinyTrie()
152 ASSERT(trie.predictive_search(agent)); in TestTinyTrie()
155 ASSERT(!trie.predictive_search(agent)); in TestTinyTrie()
158 ASSERT(trie.predictive_search(agent)); in TestTinyTrie()
161 ASSERT(trie.predictive_search(agent)); in TestTinyTrie()
164 ASSERT(!trie.predictive_search(agent)); in TestTinyTrie()
166 trie.build(keyset, 1 | MARISA_LABEL_ORDER); in TestTinyTrie()
168 ASSERT(trie.num_tries() == 1); in TestTinyTrie()
169 ASSERT(trie.num_keys() == 4); in TestTinyTrie()
170 ASSERT(trie.num_nodes() == 7); in TestTinyTrie()
172 ASSERT(trie.tail_mode() == MARISA_DEFAULT_TAIL); in TestTinyTrie()
173 ASSERT(trie.node_order() == MARISA_LABEL_ORDER); in TestTinyTrie()
183 ASSERT(trie.lookup(agent)); in TestTinyTrie()
187 trie.reverse_lookup(agent); in TestTinyTrie()
194 for (std::size_t i = 0; i < trie.size(); ++i) { in TestTinyTrie()
195 ASSERT(trie.predictive_search(agent)); in TestTinyTrie()
198 ASSERT(!trie.predictive_search(agent)); in TestTinyTrie()
219 void TestLookup(const marisa::Trie &trie, const marisa::Keyset &keyset) { in TestLookup() argument
223 ASSERT(trie.lookup(agent)); in TestLookup()
227 trie.reverse_lookup(agent); in TestLookup()
234 void TestCommonPrefixSearch(const marisa::Trie &trie, in TestCommonPrefixSearch() argument
239 ASSERT(trie.common_prefix_search(agent)); in TestCommonPrefixSearch()
241 while (trie.common_prefix_search(agent)) { in TestCommonPrefixSearch()
248 void TestPredictiveSearch(const marisa::Trie &trie, in TestPredictiveSearch() argument
253 ASSERT(trie.predictive_search(agent)); in TestPredictiveSearch()
255 while (trie.predictive_search(agent)) { in TestPredictiveSearch()
267 marisa::Trie trie; in TestTrie() local
268 trie.build(keyset, num_tries | tail_mode | node_order); in TestTrie()
270 ASSERT(trie.num_tries() == (std::size_t)num_tries); in TestTrie()
271 ASSERT(trie.num_keys() <= keyset.size()); in TestTrie()
273 ASSERT(trie.tail_mode() == tail_mode); in TestTrie()
274 ASSERT(trie.node_order() == node_order); in TestTrie()
276 TestLookup(trie, keyset); in TestTrie()
277 TestCommonPrefixSearch(trie, keyset); in TestTrie()
278 TestPredictiveSearch(trie, keyset); in TestTrie()
280 trie.save("marisa-test.dat"); in TestTrie()
282 trie.clear(); in TestTrie()
283 trie.load("marisa-test.dat"); in TestTrie()
285 ASSERT(trie.num_tries() == (std::size_t)num_tries); in TestTrie()
286 ASSERT(trie.num_keys() <= keyset.size()); in TestTrie()
288 ASSERT(trie.tail_mode() == tail_mode); in TestTrie()
289 ASSERT(trie.node_order() == node_order); in TestTrie()
291 TestLookup(trie, keyset); in TestTrie()
301 marisa::fwrite(file, trie); in TestTrie()
303 trie.clear(); in TestTrie()
310 marisa::fread(file, &trie); in TestTrie()
314 ASSERT(trie.num_tries() == (std::size_t)num_tries); in TestTrie()
315 ASSERT(trie.num_keys() <= keyset.size()); in TestTrie()
317 ASSERT(trie.tail_mode() == tail_mode); in TestTrie()
318 ASSERT(trie.node_order() == node_order); in TestTrie()
320 TestLookup(trie, keyset); in TestTrie()
322 trie.clear(); in TestTrie()
323 trie.mmap("marisa-test.dat"); in TestTrie()
325 ASSERT(trie.num_tries() == (std::size_t)num_tries); in TestTrie()
326 ASSERT(trie.num_keys() <= keyset.size()); in TestTrie()
328 ASSERT(trie.tail_mode() == tail_mode); in TestTrie()
329 ASSERT(trie.node_order() == node_order); in TestTrie()
331 TestLookup(trie, keyset); in TestTrie()
335 stream << trie; in TestTrie()
336 trie.clear(); in TestTrie()
337 stream >> trie; in TestTrie()
340 ASSERT(trie.num_tries() == (std::size_t)num_tries); in TestTrie()
341 ASSERT(trie.num_keys() <= keyset.size()); in TestTrie()
343 ASSERT(trie.tail_mode() == tail_mode); in TestTrie()
344 ASSERT(trie.node_order() == node_order); in TestTrie()
346 TestLookup(trie, keyset); in TestTrie()