summaryrefslogtreecommitdiffstats
path: root/tests/storage
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-11-28 17:18:39 +0800
committerPeng Wu <alexepico@gmail.com>2011-11-28 17:18:39 +0800
commit2e94362059fe96a490ef7a8b320a08941b96ec81 (patch)
tree567e4e3ed81eb5a068b7c6665a4ba2916a815d44 /tests/storage
parentb90b28bc329c1c7db4ea3e085b10218b3f6c47f2 (diff)
downloadlibpinyin-2e94362059fe96a490ef7a8b320a08941b96ec81.tar.gz
libpinyin-2e94362059fe96a490ef7a8b320a08941b96ec81.tar.xz
libpinyin-2e94362059fe96a490ef7a8b320a08941b96ec81.zip
write test parser2 in progress
Diffstat (limited to 'tests/storage')
-rw-r--r--tests/storage/test_parser2.cpp53
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;
}