diff options
author | Peng Wu <alexepico@gmail.com> | 2011-07-26 15:30:38 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-07-26 15:30:38 +0800 |
commit | 16a42ce9d4cc77de1670b725dcfb5c7e8e8c25bf (patch) | |
tree | 34b67906aa526a5df1caf85c1ba39804005d5d2f | |
parent | 20817e002894a3897f262938dba393296af10b53 (diff) | |
download | libpinyin-16a42ce9d4cc77de1670b725dcfb5c7e8e8c25bf.tar.gz libpinyin-16a42ce9d4cc77de1670b725dcfb5c7e8e8c25bf.tar.xz libpinyin-16a42ce9d4cc77de1670b725dcfb5c7e8e8c25bf.zip |
improve test pinyin index
-rw-r--r-- | tests/storage/test_pinyin_index.cpp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/tests/storage/test_pinyin_index.cpp b/tests/storage/test_pinyin_index.cpp index 5b54df6..9f5669b 100644 --- a/tests/storage/test_pinyin_index.cpp +++ b/tests/storage/test_pinyin_index.cpp @@ -28,44 +28,30 @@ int main( int argc, char * argv[]){ PinyinCustomSettings custom; PinyinLargeTable largetable(&custom); + FacadePhraseIndex phrase_index; + FILE * gbfile = fopen("../../data/gb_char.table", "r"); if ( gbfile == NULL ) { fprintf(stderr, "open gb_char.table failed!\n"); - return 1; + exit(ENOENT); } largetable.load_text(gbfile); + fseek(gbfile, 0L, SEEK_SET); + phrase_index.load_text(1, gbfile); fclose(gbfile); FILE * gbkfile = fopen("../../data/gbk_char.table","r"); if ( gbkfile == NULL ) { fprintf(stderr, "open gb_char.table failed!\n"); - return 1; + exit(ENOENT); } largetable.load_text(gbkfile); + fseek(gbkfile, 0L, SEEK_SET); + phrase_index.load_text(2, gbkfile); fclose(gbkfile); - FacadePhraseIndex phrase_index; - - FILE* infile = fopen("../../data/gb_char.table", "r"); - if ( NULL == infile ){ - fprintf(stderr, "open gb_char.table failed!\n"); - exit(ENOENT); - } - - phrase_index.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_text(2, infile); - fclose(infile); - MemoryChunk* new_chunk = new MemoryChunk; largetable.store(new_chunk); largetable.load(new_chunk); |