From 48becacb2a3369491c869e78bcca88aa0db07518 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 21 May 2012 15:21:10 +0800 Subject: updates tests --- tests/storage/test_phrase_index.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'tests/storage/test_phrase_index.cpp') diff --git a/tests/storage/test_phrase_index.cpp b/tests/storage/test_phrase_index.cpp index 22f5efc..4f1fe58 100644 --- a/tests/storage/test_phrase_index.cpp +++ b/tests/storage/test_phrase_index.cpp @@ -71,25 +71,24 @@ int main(int argc, char * argv[]){ } FacadePhraseIndex phrase_index_load; - - FILE* infile = fopen("../../data/gb_char.table", "r"); - if ( NULL == infile ){ - fprintf(stderr, "open gb_char.table failed!\n"); - exit(ENOENT); + 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); + exit(ENOENT); + } + + phrase_index_load.load_text(i, tablefile); + fclose(tablefile); + g_free(filename); } - phrase_index_load.load_text(1, infile); - fclose(infile); - - infile = fopen("../../data/gbk_char.table", "r"); - if ( NULL == infile ){ - fprintf(stderr, "open gbk_char.table failed!\n"); - exit(ENOENT); - } - - phrase_index_load.load_text(2, infile); - fclose(infile); - phrase_index.compat(); MemoryChunk* store1 = new MemoryChunk; -- cgit