summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-03-18 10:54:12 +0800
committerPeng Wu <alexepico@gmail.com>2016-03-18 11:15:47 +0800
commit2ad795e5832bf730cbdd5c2aacd4c2a4e94806bd (patch)
treeee8f67c76a52147979bebfccf1b3aa363b6e15ee /tests
parent1cf671992f34c0067d576c612aa94f7f28679aad (diff)
downloadlibpinyin-2ad795e5832bf730cbdd5c2aacd4c2a4e94806bd.zip
libpinyin-2ad795e5832bf730cbdd5c2aacd4c2a4e94806bd.tar.gz
libpinyin-2ad795e5832bf730cbdd5c2aacd4c2a4e94806bd.tar.xz
update test_chewing_table.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/storage/test_chewing_table.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/storage/test_chewing_table.cpp b/tests/storage/test_chewing_table.cpp
index 0aaa45e..e6ecdb0 100644
--- a/tests/storage/test_chewing_table.cpp
+++ b/tests/storage/test_chewing_table.cpp
@@ -45,9 +45,11 @@ int main(int argc, char * argv[]) {
if (!load_phrase_table(phrase_files, &largetable, NULL, &phrase_index))
exit(ENOENT);
+#if 0
MemoryChunk * new_chunk = new MemoryChunk;
largetable.store(new_chunk);
largetable.load(new_chunk);
+#endif
char* linebuf = NULL; size_t size = 0; ssize_t read;
while ((read = getline(&linebuf, &size, stdin)) != -1) {
@@ -70,21 +72,31 @@ int main(int argc, char * argv[]) {
}
guint32 start = record_time();
+ size_t i = 0;
PhraseIndexRanges ranges;
memset(ranges, 0, sizeof(PhraseIndexRanges));
phrase_index.prepare_ranges(ranges);
- for (size_t i = 0; i < bench_times; ++i) {
+ for (i = 0; i < bench_times; ++i) {
phrase_index.clear_ranges(ranges);
largetable.search(keys->len, (ChewingKey *)keys->data, ranges);
}
print_time(start, bench_times);
+ /* test search continued information. */
+ int retval = SEARCH_NONE;
+ for (i = 1; i < keys->len; ++i) {
+ phrase_index.clear_ranges(ranges);
+ retval = largetable.search(i, (ChewingKey *)keys->data, ranges);
+ if (retval & SEARCH_CONTINUED)
+ printf("return continued information with length:%ld\n", i);
+ }
+
phrase_index.clear_ranges(ranges);
largetable.search(keys->len, (ChewingKey *)keys->data, ranges);
- for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
+ for (i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
GArray * & range = ranges[i];
if (!range)
continue;