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_table.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_table.cpp')
-rw-r--r-- | tests/storage/test_phrase_table.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/storage/test_phrase_table.cpp b/tests/storage/test_phrase_table.cpp index 2907948..a7043a8 100644 --- a/tests/storage/test_phrase_table.cpp +++ b/tests/storage/test_phrase_table.cpp @@ -7,24 +7,24 @@ size_t bench_times = 1000; int main(int argc, char * argv[]){ PhraseLargeTable largetable; - FILE * gbfile = fopen("../../data/gb_char.table", "r"); - if ( gbfile == NULL ) { - fprintf(stderr, "open gb_char.table failed!\n"); - return 1; - } - - largetable.load_text(gbfile); - fclose(gbfile); + 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 ( tablefile == NULL ) { + fprintf(stderr, "open %s failed!\n", tablename); + return 1; + } - FILE * gbkfile = fopen("../../data/gbk_char.table", "r"); - if (gbkfile == NULL ) { - fprintf(stderr, "open gbk_char.table failed!\n"); - return 1; + largetable.load_text(tablefile); + fclose(tablefile); + g_free(filename); } - largetable.load_text(gbkfile); - fclose(gbkfile); - MemoryChunk * chunk = new MemoryChunk; largetable.store(chunk); largetable.load(chunk); |