summaryrefslogtreecommitdiffstats
path: root/tests/storage/test_chewing_table.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-05-21 15:21:10 +0800
committerPeng Wu <alexepico@gmail.com>2012-05-21 15:21:10 +0800
commit48becacb2a3369491c869e78bcca88aa0db07518 (patch)
tree2951f7774048f1827bb317d12cdb33eab276ffc6 /tests/storage/test_chewing_table.cpp
parent2380f39316da63d8c140fc920309e8ff149fec1f (diff)
downloadlibpinyin-48becacb2a3369491c869e78bcca88aa0db07518.tar.gz
libpinyin-48becacb2a3369491c869e78bcca88aa0db07518.tar.xz
libpinyin-48becacb2a3369491c869e78bcca88aa0db07518.zip
updates tests
Diffstat (limited to 'tests/storage/test_chewing_table.cpp')
-rw-r--r--tests/storage/test_chewing_table.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/tests/storage/test_chewing_table.cpp b/tests/storage/test_chewing_table.cpp
index 1c705f1..028cda9 100644
--- a/tests/storage/test_chewing_table.cpp
+++ b/tests/storage/test_chewing_table.cpp
@@ -31,28 +31,26 @@ int main(int argc, char * argv[]) {
ChewingLargeTable largetable(options);
FacadePhraseIndex phrase_index;
- FILE * gbfile = fopen("../../data/gb_char.table", "r");
- if (NULL == gbfile) {
- 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;
- largetable.load_text(gbfile);
- fseek(gbfile, 0L, SEEK_SET);
- phrase_index.load_text(1, gbfile);
- fclose(gbfile);
+ 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);
+ }
- FILE * gbkfile = fopen("../../data/gbk_char.table", "r");
- if (NULL == gbkfile) {
- fprintf(stderr, "open gbk_char.table failed!\n");
- exit(ENOENT);
+ largetable.load_text(tablefile);
+ fseek(tablefile, 0L, SEEK_SET);
+ phrase_index.load_text(i, tablefile);
+ fclose(tablefile);
+ g_free(filename);
}
- largetable.load_text(gbkfile);
- fseek(gbkfile, 0L, SEEK_SET);
- phrase_index.load_text(2, gbkfile);
- fclose(gbkfile);
-
MemoryChunk * new_chunk = new MemoryChunk;
largetable.store(new_chunk);
largetable.load(new_chunk);