summaryrefslogtreecommitdiffstats
path: root/tests/tests_helper.h
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-06-14 11:13:51 +0800
committerPeng Wu <alexepico@gmail.com>2012-06-14 11:13:51 +0800
commit4c42f29cb8863cc5d6810a8a2a25c478e16292f7 (patch)
treee4bcd14f79ca5b147e6908f074f443784ce9e1f1 /tests/tests_helper.h
parent188af7797fc9fbb4d9ffe775ae2a05369698cdef (diff)
downloadlibpinyin-4c42f29cb8863cc5d6810a8a2a25c478e16292f7.tar.gz
libpinyin-4c42f29cb8863cc5d6810a8a2a25c478e16292f7.tar.xz
libpinyin-4c42f29cb8863cc5d6810a8a2a25c478e16292f7.zip
refine tests
Diffstat (limited to 'tests/tests_helper.h')
-rw-r--r--tests/tests_helper.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/tests_helper.h b/tests/tests_helper.h
index af1b38a..5694148 100644
--- a/tests/tests_helper.h
+++ b/tests/tests_helper.h
@@ -44,4 +44,34 @@ static bool load_phrase_index(FacadePhraseIndex * phrase_index){
return true;
}
+static bool load_phrase_table(ChewingLargeTable * chewing_table,
+ PhraseLargeTable * phrase_table,
+ FacadePhraseIndex * phrase_index){
+ for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
+ const char * tablename = pinyin_table_files[i];
+ if ( NULL == tablename )
+ continue;
+
+ gchar * filename = g_build_filename("..", "..", "data",
+ tablename, NULL);
+ FILE * tablefile = fopen(filename, "r");
+ if (NULL == tablefile) {
+ fprintf(stderr, "open %s failed!\n", tablename);
+ return false;
+ }
+ g_free(filename);
+
+ if (chewing_table)
+ chewing_table->load_text(tablefile);
+ fseek(tablefile, 0L, SEEK_SET);
+ if (phrase_table)
+ phrase_table->load_text(tablefile);
+ fseek(tablefile, 0L, SEEK_SET);
+ if (phrase_index)
+ phrase_index->load_text(i, tablefile);
+ fclose(tablefile);
+ }
+ return true;
+}
+
#endif