diff options
Diffstat (limited to 'tests/storage')
-rw-r--r-- | tests/storage/test_parser2.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/storage/test_parser2.cpp b/tests/storage/test_parser2.cpp index be22351..a7e57e2 100644 --- a/tests/storage/test_parser2.cpp +++ b/tests/storage/test_parser2.cpp @@ -20,16 +20,26 @@ */ +#include <errno.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "pinyin_parser2.h" + + +using namespace pinyin; static const char * help_msg = "Usage:\n" " test-parser -p <parser> [-s <scheme>] [options].\n\n" " -p <parser> fullpinyin/doublepinyin/chewing.\n" +#if 0 " -s <scheme> specify scheme for doublepinyin/chewing.\n" " schemes for doublepinyin: zrm, ms, ziguang, abc, pyjj, xhe.\n" " schemes for chewing: standard, ibm, ginyieh, eten.\n" +#endif " -i Use incomplete pinyin.\n" + " -h print this help msg.\n" ; @@ -38,5 +48,48 @@ void print_help(){ } int main(int argc, char * argv[]) { + PinyinParser2 * parser = NULL; + ChewingKeyVector keys = g_array_new(FALSE, FALSE, sizeof(ChewingKey)); + ChewingKeyRestVector key_rests = + g_array_new(FALSE, FALSE, sizeof(ChewingKeyRest)); + guint32 options = PINYIN_CORRECT_ALL; + + int i = 1; + while(i < argc) { + if (strcmp("-h", argv[i]) == 0) { + print_help(); + exit(0); + } else if (strcmp("-i", argv[i]) == 0) { + options |= PINYIN_INCOMPLETE | CHEWING_INCOMPLETE; + } else if (strcmp("-p", argv[i]) == 0) { + if ( ++i >= argc ) { + print_help(); + exit(EINVAL); + } + const char * name = argv[i]; + if (strcmp("fullpinyin", name) == 0) { + parser = new FullPinyinParser2(); + } else if (strcmp("doublepinyin", name) == 0) { + parser = new DoublePinyinParser2(); + } else if (strcmp("chewing", name) == 0) { + parser = new ChewingParser2(); + } else { + print_help(); + exit(EINVAL); + } + } else { + print_help(); + exit(EINVAL); + } + ++i; + } + + if (NULL == parser) { + print_help(); + exit(EINVAL); + } + + + return 0; } |