From 16a42ce9d4cc77de1670b725dcfb5c7e8e8c25bf Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 26 Jul 2011 15:30:38 +0800 Subject: improve test pinyin index --- tests/storage/test_pinyin_index.cpp | 30 ++++++++---------------------- 1 file 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); -- cgit