diff options
author | Peng Wu <alexepico@gmail.com> | 2012-05-21 15:21:10 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-05-21 15:21:10 +0800 |
commit | 48becacb2a3369491c869e78bcca88aa0db07518 (patch) | |
tree | 2951f7774048f1827bb317d12cdb33eab276ffc6 /tests/storage/test_phrase_index.cpp | |
parent | 2380f39316da63d8c140fc920309e8ff149fec1f (diff) | |
download | libpinyin-48becacb2a3369491c869e78bcca88aa0db07518.tar.gz libpinyin-48becacb2a3369491c869e78bcca88aa0db07518.tar.xz libpinyin-48becacb2a3369491c869e78bcca88aa0db07518.zip |
updates tests
Diffstat (limited to 'tests/storage/test_phrase_index.cpp')
-rw-r--r-- | tests/storage/test_phrase_index.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
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; |