summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-04-15 17:13:24 +0800
committerPeng Wu <alexepico@gmail.com>2011-04-15 17:13:24 +0800
commit2f85c451d14b0bb0284daf25d7b4f639355532c2 (patch)
treeb5b5704986c40bb5814a9b6efda4e73ec5e6293b /tests
parentf3e68a089ba76467a7adc15d657dd2f9552b2bc7 (diff)
downloadlibpinyin-2f85c451d14b0bb0284daf25d7b4f639355532c2.tar.gz
libpinyin-2f85c451d14b0bb0284daf25d7b4f639355532c2.tar.xz
libpinyin-2f85c451d14b0bb0284daf25d7b4f639355532c2.zip
add more test cases for get/set array header
Diffstat (limited to 'tests')
-rw-r--r--tests/storage/test_flexible_ngram.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/storage/test_flexible_ngram.cpp b/tests/storage/test_flexible_ngram.cpp
index 16eb225..e8f6a9b 100644
--- a/tests/storage/test_flexible_ngram.cpp
+++ b/tests/storage/test_flexible_ngram.cpp
@@ -53,7 +53,6 @@ int main(int argc, char * argv[]) {
}
delete train_gram;
}
- g_array_free(array, TRUE);
GArray * items = g_array_new(FALSE, FALSE, sizeof(phrase_token_t));
bigram.get_all_items(items);
@@ -83,5 +82,20 @@ int main(int argc, char * argv[]) {
printf("single gram: %d, freq:%d\n", i, freq);
}
+ for (int m = 1; m <= 2; ++m ){
+ printf("--------------------------------------------------------\n");
+ FlexibleSingleGram<guint32, guint32> * train_gram;
+ bigram.load(m, train_gram);
+ g_array_set_size(array, 0);
+ range.m_range_begin = 0; range.m_range_end = 8;
+ train_gram->search(&range, array);
+ for ( size_t i = 0; i < array->len; ++i ){
+ array_item_t * item = &g_array_index(array, array_item_t, i);
+ printf("item:%d:%d\n", item->m_token, item->m_item);
+ }
+ delete train_gram;
+ }
+
+ g_array_free(array, TRUE);
return 0;
}