(linenum→info "unix/slp.c:2238")

anthy/9100e/test/check.c

    1: /* リリース前のチェックを行う */
    2: #include <stdio.h>
    3: #include <stdlib.h>
    4: #include <anthy/anthy.h>
    5: #include <anthy/xstr.h>
    6: 
    7: static int
    8: init(void)
    9: {
   10:   int res;
   11: 
   12:   res = anthy_init();
   13:   if (res) {
   14:     printf("failed to init\n");
   15:     return 1;
   16:   }
   17:   anthy_quit();
   18:   /* init again */
   19:   res = anthy_init();
   20:   if (res) {
   21:     printf("failed to init\n");
   22:     return 1;
   23:   }
   24:   return 0;
   25: }
   26: 
   27: static int
   28: test0(void)
   29: {
   30:   anthy_context_t ac;
   31:   ac = anthy_create_context();
   32:   if (!ac) {
   33:     printf("failed to create context\n");
   34:     return 1;
   35:   }
   36:   anthy_release_context(ac);
   37:   return 0;
   38: }
   39: 
   40: static int
   41: test1(void)
   42: {
   43:   anthy_context_t ac;
   44:   char buf[100];
   45:   xstr *xs;
   46:   ac = anthy_create_context();
   47:   if (!ac) {
   48:     printf("failed to create context\n");
   49:     return 1;
   50:   }
   51:   anthy_set_string(ac, "あいうえお、かきくけこ。");
   52:   if (anthy_get_segment(ac, 0, NTH_UNCONVERTED_CANDIDATE, buf, 100) > 0) {
   53:     printf("(%s)\n", buf);
   54:   }
   55:   if (anthy_get_segment(ac, 0, NTH_KATAKANA_CANDIDATE, buf, 100) > 0) {
   56:     printf("(%s)\n", buf);
   57:   }
   58:   if (anthy_get_segment(ac, 0, NTH_HIRAGANA_CANDIDATE, buf, 100) > 0) {
   59:     printf("(%s)\n", buf);
   60:   }
   61:   if (anthy_get_segment(ac, 0, NTH_HALFKANA_CANDIDATE, buf, 100) > 0) {
   62:     printf("(%s)\n", buf);
   63:   }
   64:   anthy_release_context(ac);
   65:   xs = anthy_cstr_to_xstr("あいうえおがぎぐげご", 0);
   66:   xs = anthy_xstr_hira_to_half_kata(xs);
   67:   anthy_putxstrln(xs);
   68:   return 0;
   69: }
   70: 
   71: static int
   72: shake_test(const char *str)
   73: {
   74:   int i;
   75:   anthy_context_t ac;
   76:   ac = anthy_create_context();
   77:   if (!ac) {
   78:     printf("failed to create context\n");
   79:     return 1;
   80:   }
   81:   anthy_set_string(ac, str);
   82:   for (i = 0; i < 50; i++) {
   83:     int res, nth, rsz;
   84:     struct anthy_conv_stat cs;
   85:     res = anthy_get_stat(ac, &cs);
   86:     nth = rand() % cs.nr_segment;
   87:     rsz = (rand() % 3) - 1;
   88:     anthy_resize_segment(ac, nth, rsz);
   89:   }
   90:   anthy_release_context(ac);
   91:   return 0;
   92: }
   93: 
   94: int
   95: main(int argc, char **argv)
   96: {
   97:   (void)argc;
   98:   (void)argv;
   99:   printf("checking\n");
  100:   if (init()) {
  101:     printf("fail (init)\n");
  102:     return 0;
  103:   }
  104:   if (test0()) {
  105:     printf("fail (test0)\n");
  106:   }
  107:   if (test1()) {
  108:     printf("fail (test1)\n");
  109:   }
  110:   if (shake_test("あいうえおかきくけこ")) {
  111:     printf("fail (shake_test)\n");
  112:   }
  113:   printf("done\n");
  114:   return 0;
  115: }
Syntax (Markdown)