void test_set_phraseChoiceRearward() { ChewingContext *ctx; int value; int mode; ctx = chewing_new(); start_testcase( ctx, fd ); for ( value = 0; value < 2; ++value ) { chewing_set_phraseChoiceRearward( ctx, value ); mode = chewing_get_phraseChoiceRearward( ctx ); ok( mode == value, "phraseChoiceRearward `%d' shall be `%d'", mode, value ); chewing_set_phraseChoiceRearward( ctx, -1 ); mode = chewing_get_phraseChoiceRearward( ctx ); ok( mode == value, "phraseChoiceRearward `%d' shall be `%d'", mode, value ); chewing_set_phraseChoiceRearward( ctx, 2 ); mode = chewing_get_phraseChoiceRearward( ctx ); ok( mode == value, "phraseChoiceRearward `%d' shall be `%d'", mode, value ); } chewing_delete( ctx ); }
void test_set_ShapeMode() { const int VALUE[] = { HALFSHAPE_MODE, FULLSHAPE_MODE, }; const int INVALID_VALUE[] = { -1, 2, }; ChewingContext *ctx; size_t i; size_t j; ctx = chewing_new(); start_testcase( ctx, fd ); for ( i = 0; i < ARRAY_SIZE( VALUE ); ++i ) { chewing_set_ShapeMode( ctx, VALUE[i] ); ok( chewing_get_ShapeMode( ctx ) == VALUE[i], "ShapeMode shall be `%d'", VALUE[i] ); for ( j = 0; j < ARRAY_SIZE( INVALID_VALUE ); ++j ) { // mode shall not change when set mode has invalid value. chewing_set_ShapeMode( ctx, INVALID_VALUE[j] ); ok( chewing_get_ShapeMode( ctx ) == VALUE[i], "ShapeMode shall be `%d'", VALUE[i] ); } } chewing_delete( ctx ); }
void test_set_autoShiftCur() { ChewingContext *ctx; int value; int mode; ctx = chewing_new(); start_testcase( ctx, fd ); for ( value = 0; value < 2; ++value ) { chewing_set_autoShiftCur( ctx, value ); mode = chewing_get_autoShiftCur( ctx ); ok( mode = chewing_get_autoShiftCur( ctx ) == value, "autoShiftCur shall be `%d'", value ); chewing_set_autoShiftCur( ctx, -1 ); mode = chewing_get_autoShiftCur( ctx ); ok( mode = chewing_get_autoShiftCur( ctx ) == value, "autoShiftCur shall be `%d'", value ); chewing_set_autoShiftCur( ctx, 2 ); mode = chewing_get_autoShiftCur( ctx ); ok( mode = chewing_get_autoShiftCur( ctx ) == value, "autoShiftCur shall be `%d'", value ); } chewing_delete( ctx ); }
void test_set_easySymbolInput() { ChewingContext *ctx; int value; int mode; ctx = chewing_new(); start_testcase( ctx, fd ); for ( value = 0; value < 2; ++value ) { chewing_set_easySymbolInput( ctx, value ); mode = chewing_get_easySymbolInput( ctx ); ok( mode == value, "easySymbolInput `%d', shall be `%d'", mode, value ); chewing_set_easySymbolInput( ctx, -1 ); mode = chewing_get_easySymbolInput( ctx ); ok( mode == value, "easySymbolInput `%d', shall be `%d'", mode, value ); chewing_set_easySymbolInput( ctx, 2 ); mode = chewing_get_easySymbolInput( ctx ); ok( mode == value, "easySymbolInput `%d', shall be `%d'", mode, value ); } chewing_delete( ctx ); }
void test_set_escCleanAllBuf() { ChewingContext *ctx; int value; int mode; ctx = chewing_new(); start_testcase( ctx, fd ); for ( value = 0; value < 2; ++value ) { chewing_set_escCleanAllBuf( ctx, value ); mode = chewing_get_escCleanAllBuf( ctx ); ok( mode == value, "escCleanAllBuf shall be `%d'", value ); chewing_set_escCleanAllBuf( ctx, -1 ); mode = chewing_get_escCleanAllBuf( ctx ); ok( mode == value, "escCleanAllBuf shall be `%d'", value ); chewing_set_escCleanAllBuf( ctx, 2 ); mode = chewing_get_escCleanAllBuf( ctx ); ok( mode == value, "escCleanAllBuf shall be `%d'", value ); } chewing_delete( ctx ); }
void test_set_spaceAsSelection() { ChewingContext *ctx; int value; int mode; ctx = chewing_new(); start_testcase( ctx, fd ); for ( value = 0; value < 2; ++value ) { chewing_set_spaceAsSelection( ctx, value ); mode = chewing_get_spaceAsSelection( ctx ); ok( mode == value, "spaceAsSelection `%d' shall be `%d'", mode, value ); chewing_set_spaceAsSelection( ctx, -1 ); mode = chewing_get_spaceAsSelection( ctx ); ok( mode == value, "spaceAsSelection `%d' shall be `%d'", mode, value ); chewing_set_spaceAsSelection( ctx, 2 ); mode = chewing_get_spaceAsSelection( ctx ); ok( mode == value, "spaceAsSelection `%d' shall be `%d'", mode, value ); } chewing_delete( ctx ); }
void test_libchewing_googlecode_issue_473() { /* FIXME: Add const cause gcc warning */ static char *INPUT[] = { "t<N->_ M1<N+>H[Ls3<L><N1>PL+Z]4<C1>&(^H*H<TT>Sc<N->P]!|<CB>-<C6>S<H><N1><C0>U<B>d}P!f<EN><N.><C7>V!U!w|4-=S<C1>b<N2>Q", "wv<C0><C5><N9>$FIF<D><N4>B *<C2>E4*<C2>q)Kf)<SS><TT>4=<N5>%<R>mN4<EN>H<N9><N.>8s{XTD<N6>jZV(y3G`9<C6>JTy<B>J<C1>SNc<E>hC<SL><N/><R><C6>@an<C3><N7>wzF<C3>P*<N*><B>l<C3><N6>W<N*> $<SR><N.><N1><E><E><N0><N6>Y", }; size_t i; ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); chewing_set_maxChiSymbolLen(ctx, 16); chewing_set_autoShiftCur(ctx, 1); chewing_set_candPerPage(ctx, 9); chewing_set_addPhraseDirection(ctx, 1); chewing_set_spaceAsSelection(ctx, 1); for (i = 0; i < ARRAY_SIZE(INPUT); ++i) { chewing_Reset(ctx); type_keystroke_by_string(ctx, INPUT[i]); } chewing_delete(ctx); }
void test_set_candPerPage() { const int VALUE[] = { MIN_CAND_PER_PAGE, MAX_CAND_PER_PAGE, }; const int INVALID_VALUE[] = { MIN_CAND_PER_PAGE - 1, MAX_CAND_PER_PAGE + 1, }; ChewingContext *ctx; size_t i; size_t j; ctx = chewing_new(); start_testcase( ctx, fd ); for ( i = 0; i < ARRAY_SIZE( VALUE ); ++i ) { chewing_set_candPerPage( ctx, VALUE[i] ); ok( chewing_get_candPerPage( ctx ) == VALUE[i], "candPerPage shall be `%d'", VALUE[i] ); for ( j = 0; j < ARRAY_SIZE( INVALID_VALUE ); ++j ) { // mode shall not change when set mode has invalid value. chewing_set_candPerPage( ctx, INVALID_VALUE[j] ); ok( chewing_get_candPerPage( ctx ) == VALUE[i], "candPerPage shall be `%d'", VALUE[i] ); } } chewing_delete( ctx ); }
void test_Space_selection_symbol() { const char CAND_1[] = "\xE2\x80\xA6" /* … */ ; const char CAND_2[] = "\xE9\x9B\x99\xE7\xB7\x9A\xE6\xA1\x86" /* 雙線框 */ ; ChewingContext *ctx; const char *const_buf; clean_userphrase(); ctx = chewing_new(); start_testcase(ctx, fd); chewing_set_spaceAsSelection(ctx, 1); type_keystroke_by_string(ctx, "`"); chewing_cand_Enumerate(ctx); const_buf = chewing_cand_String_static(ctx); ok(strcmp(const_buf, CAND_1) == 0, "first candidate list head `%s' shall be `%s'", const_buf, CAND_1); type_keystroke_by_string(ctx, " "); chewing_cand_Enumerate(ctx); const_buf = chewing_cand_String_static(ctx); ok(strcmp(const_buf, CAND_2) == 0, "second candidate list head `%s' shall be `%s'", const_buf, CAND_2); /* rollover */ type_keystroke_by_string(ctx, " "); chewing_cand_Enumerate(ctx); const_buf = chewing_cand_String_static(ctx); ok(strcmp(const_buf, CAND_1) == 0, "first candidate list head `%s' shall be `%s'", const_buf, CAND_1); chewing_delete(ctx); }
void test_Capslock() { ChewingContext *ctx; int mode; ctx = chewing_new(); start_testcase(ctx, fd); mode = chewing_get_ChiEngMode(ctx); ok(mode == CHINESE_MODE, "mode shall be CHINESE_MODE"); type_keystroke_by_string(ctx, "ji"); /* ㄨㄛ */ ok_bopomofo_buffer(ctx, "\xe3\x84\xa8\xe3\x84\x9b" /* ㄨㄛ */ ); ok_preedit_buffer(ctx, ""); ok_commit_buffer(ctx, ""); type_keystroke_by_string(ctx, "<CB>"); mode = chewing_get_ChiEngMode(ctx); ok(mode == SYMBOL_MODE, "mode shall change to SYMBOL_MODE"); ok_bopomofo_buffer(ctx, ""); ok_preedit_buffer(ctx, ""); ok_commit_buffer(ctx, ""); chewing_delete(ctx); }
void test_del_bopomofo_as_mode_switch() { ChewingContext *ctx; clean_userphrase(); ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "2k"); /* ㄉㄜ */ ok_bopomofo_buffer(ctx, "\xe3\x84\x89\xe3\x84\x9c" /* ㄉㄜ */ ); ok_preedit_buffer(ctx, ""); chewing_set_ChiEngMode(ctx, SYMBOL_MODE); ok_bopomofo_buffer(ctx, ""); ok_preedit_buffer(ctx, ""); chewing_set_ChiEngMode(ctx, CHINESE_MODE); type_keystroke_by_string(ctx, "ji"); /* ㄨㄛ */ ok_bopomofo_buffer(ctx, "\xe3\x84\xa8\xe3\x84\x9b" /* ㄨㄛ */ ); ok_preedit_buffer(ctx, ""); chewing_set_ChiEngMode(ctx, SYMBOL_MODE); ok_bopomofo_buffer(ctx, ""); ok_preedit_buffer(ctx, ""); chewing_delete(ctx); }
void test_UnitFromPlatMmap() { unsigned int idx; plat_mmap m_mmap; size_t offset = 0; size_t csize; char *data_buf; char hard_copy[] = "ji3cp3vu3cj0 vup dj4up <E>"; int i; start_testcase( NULL, fd ); idx = plat_mmap_create(&m_mmap, TESTDATA, FLAG_ATTRIBUTE_READ); ok (idx == 28, "plat_mmap_create"); if (idx > 0) { csize = idx; data_buf = (char *) plat_mmap_set_view(&m_mmap, &offset, &csize); for (i = 0; i < 26; i++) { if (data_buf[i] != hard_copy[i]) break; } ok (i == 26, "plat_mmap_set_view"); } plat_mmap_close( &m_mmap ); }
void test_interval() { ChewingContext *ctx; IntervalType it; ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "`31hk4g4`31hk4g4`31" /* ,測試,測試, */ ); ok_preedit_buffer(ctx, "\xEF\xBC\x8C\xE6\xB8\xAC\xE8\xA9\xA6\xEF\xBC\x8C\xE6\xB8\xAC\xE8\xA9\xA6\xEF\xBC\x8C" /* ,測試,測試, */ ); chewing_interval_Enumerate(ctx); ok(chewing_interval_hasNext(ctx) == 1, "shall have next interval"); chewing_interval_Get(ctx, &it); ok(it.from == 1 && it.to == 3, "interval (%d, %d) shall be (1, 3)", it.from, it.to); ok(chewing_interval_hasNext(ctx) == 1, "shall have next interval"); chewing_interval_Get(ctx, &it); ok(it.from == 4 && it.to == 6, "interval (%d, %d) shall be (4, 6)", it.from, it.to); ok(chewing_interval_hasNext(ctx) == 0, "shall not have next interval"); chewing_delete(ctx); }
void test_jk_selection() { #if 0 FIXME: libchewing is broken in this case ChewingContext *ctx; int ret; int i; const int EXPECT_CAND_LEN[] = { 1, 2, 1, 1, 2, 1, 1 }; ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "`31hk4g4`31hk4g4`31" /* ,測試,測試, */ ); ret = chewing_cand_open(ctx); ok(ret == 0, "chewing_cand_open() returns `%d' shall be `%d'", ret, 0); for (i = ARRAY_SIZE(EXPECT_CAND_LEN) - 1; i >= 0; --i) { ret = chewing_cand_TotalChoice(ctx); ok(ret > 0, "chewing_cand_TotalChoice() returns `%d' shall be greater than `%d'", ret, 0); ok_candidate_len(ctx, EXPECT_CAND_LEN[i]); type_keystroke_by_string(ctx, "j"); } for (i = 0; i < ARRAY_SIZE(EXPECT_CAND_LEN); ++i) { ret = chewing_cand_TotalChoice(ctx); ok(ret > 0, "chewing_cand_TotalChoice() returns `%d' shall be greater than `%d'", ret, 0); ok_candidate_len(ctx, EXPECT_CAND_LEN[i]); type_keystroke_by_string(ctx, "i"); } chewing_delete(ctx); #endif }
void test_libchewing_googlecode_issue_472() { /* FIXME: Add const cause gcc warning */ static char *INPUT[] = { "<T>|&Wt<H>mrJY)G<C2>OqJ<H><H>Yl<R>p0<EE>QE[^<C1>k", "+F<C9>hQ$UIICMr!X8/9<C3>(N<T>yU2!-LUI<D>`CS<D>jShm9SF}<EN>[`QYu<C8>k", "hk4`2<D>jk", "hk4`j 0", "hk4<C0>j 0", }; size_t i; ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); chewing_set_maxChiSymbolLen(ctx, 16); chewing_set_autoShiftCur(ctx, 1); for (i = 0; i < ARRAY_SIZE(INPUT); ++i) { chewing_Reset(ctx); type_keystroke_by_string(ctx, INPUT[i]); } chewing_delete(ctx); }
void test_bopomofo_buffer() { ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "1ul"); ok_bopomofo_buffer(ctx, "\xE3\x84\x85\xE3\x84\xA7\xE3\x84\xA0" /* ㄅㄧㄠ */ ); type_keystroke_by_string(ctx, " "); ok_bopomofo_buffer(ctx, ""); type_keystroke_by_string(ctx, "ul"); ok_bopomofo_buffer(ctx, "\xE3\x84\xA7\xE3\x84\xA0" /* ㄧㄠ */ ); type_keystroke_by_string(ctx, " "); ok_bopomofo_buffer(ctx, ""); type_keystroke_by_string(ctx, "3"); ok_bopomofo_buffer(ctx, "\xCB\x87" /* ˇ */ ); type_keystroke_by_string(ctx, " "); ok_bopomofo_buffer(ctx, ""); chewing_delete(ctx); }
void test_Space_selection_word() { ChewingContext *ctx; char *buf; int len; clean_userphrase(); ctx = chewing_new(); start_testcase(ctx, fd); chewing_set_spaceAsSelection(ctx, 1); type_keystroke_by_string(ctx, "hk4g4<H>" /* 測試 */ ); type_keystroke_by_string(ctx, " "); /* open candidate window */ chewing_cand_Enumerate(ctx); buf = chewing_cand_String(ctx); len = ueStrLen(buf); ok(len == 2, "candidate `%s' length `%d' shall be `%d'", buf, len, 2); chewing_free(buf); type_keystroke_by_string(ctx, " "); /* next candidate list */ chewing_cand_Enumerate(ctx); buf = chewing_cand_String(ctx); len = ueStrLen(buf); ok(len == 1, "candidate `%s' length `%d' shall be `%d'", buf, len, 1); chewing_free(buf); type_keystroke_by_string(ctx, " "); /* next page */ ok(chewing_cand_CurrentPage(ctx) == 1, "current page shall be 1"); chewing_delete(ctx); }
void test_Numlock_select_candidate() { const TestData NUMLOCK_SELECT[] = { {"hk4<D><N1><E>", "\xE5\x86\x8A" /* 冊 */ }, {"hk4<D><N2><E>", "\xE7\xAD\x96" /* 策 */ }, {"hk4<D><N3><E>", "\xE6\xB8\xAC" /* 測 */ }, {"hk4<D><N4><E>", "\xE5\x81\xB4" /* 側 */ }, {"hk4<D><N5><E>", "\xE5\xBB\x81" /* 廁 */ }, {"hk4<D><N6><E>", "\xE6\x83\xBB" /* 惻 */ }, {"hk4<D><N7><E>", "\xE7\xAD\xB4" /* 筴 */ }, {"hk4<D><N8><E>", "\xE7\x95\x9F" /* 畟 */ }, {"hk4<D><N9><E>", "\xE8\x8C\xA6" /* 茦 */ }, {"hk4<D><N0><E>", "\xE7\xB2\xA3" /* 粣 */ }, }; size_t i; ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); chewing_set_maxChiSymbolLen(ctx, 16); for (i = 0; i < ARRAY_SIZE(NUMLOCK_SELECT); ++i) { type_keystroke_by_string(ctx, NUMLOCK_SELECT[i].token); ok_commit_buffer(ctx, NUMLOCK_SELECT[i].expected); } chewing_delete(ctx); }
void test_Numlock_numeric_input() { const TestData NUMLOCK_INPUT[] = { {"<N0>", "0"}, {"<N1>", "1"}, {"<N2>", "2"}, {"<N3>", "3"}, {"<N4>", "4"}, {"<N5>", "5"}, {"<N6>", "6"}, {"<N7>", "7"}, {"<N8>", "8"}, {"<N9>", "9"}, {"<N+>", "+"}, {"<N->", "-"}, {"<N*>", "*"}, {"<N/>", "/"}, {"<N.>", "."}, }; size_t i; ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); chewing_set_maxChiSymbolLen(ctx, 16); for (i = 0; i < ARRAY_SIZE(NUMLOCK_INPUT); ++i) { type_keystroke_by_string(ctx, NUMLOCK_INPUT[i].token); ok_commit_buffer(ctx, NUMLOCK_INPUT[i].expected); } chewing_delete(ctx); }
void test_select_candidate_in_middle_reaward() { ChewingContext *ctx; int ret; const char *cand; clean_userphrase(); ctx = chewing_new(); start_testcase(ctx, fd); chewing_set_phraseChoiceRearward(ctx, 1); type_keystroke_by_string(ctx, "hk4g4u6<L><L>" /* 測試儀*/); ret = chewing_cand_open(ctx); ok(ret == 0, "chewing_cand_open return %d shall be %d", ret, 0); cand = chewing_cand_string_by_index_static(ctx, 0); ok(strcmp(cand, "\xE6\xB8\xAC\xE8\xA9\xA6") == 0, "first candidate `%s' shall be `%s'", cand, "\xE6\xB8\xAC\xE8\xA9\xA6" /* 測試 */); ret = chewing_cand_list_next(ctx); ok(ret == 0, "chewing_cand_list_next return %d shall be %d", ret, 0); cand = chewing_cand_string_by_index_static(ctx, 0); ok(strcmp(cand, "\xE5\xB8\x82") == 0, "first candidate `%s' shall be `%s'", cand, "\xE5\xB8\x82" /* 市 */); chewing_delete(ctx); }
void test_select_candidate_4_bytes_utf8() { ChewingContext *ctx; clean_userphrase(); ctx = chewing_new(); start_testcase(ctx, fd); chewing_set_maxChiSymbolLen(ctx, 16); chewing_set_phraseChoiceRearward(ctx, 1); chewing_set_autoShiftCur(ctx, 1); type_keystroke_by_string(ctx, "2k62k6"); /* ㄉㄜˊ ㄉㄜˊ */ ok_preedit_buffer(ctx, "\xE5\xBE\x97\xE5\xBE\x97" /* 得得 */ ); type_keystroke_by_string(ctx, "<H>"); type_keystroke_by_string(ctx, "<D>8"); ok_preedit_buffer(ctx, "\xF0\xA2\x94\xA8\xE5\xBE\x97" /* 𢔨得 */ ); type_keystroke_by_string(ctx, "<D>8"); ok_preedit_buffer(ctx, "\xF0\xA2\x94\xA8\xF0\xA2\x94\xA8" /* 𢔨𢔨 */ ); chewing_delete(ctx); }
void test_utf8() { char *u8string; int u8len; int len; char u8string2[16]; start_testcase(NULL, fd); u8string = "HelloWorld"; u8len = ueStrLen(u8string); len = strlen(u8string); ok(u8len == len, "ueStrLen"); u8string = "\xE6\xB8\xAC\xE8\xA9\xA6\xE8\xA8\x88\xE7\xAE\x97\xE9\x95\xB7\xE5\xBA\xA6"; /* 測試計算長度 */ u8len = ueStrLen(u8string); ok(u8len == 6, "ueStrLen"); u8string = "\xE6\xB8\xAC\xE8\xA9\xA6\xE8\xA8\x88\xE7\xAE\x97\xE9\x95\xB7\xE5\xBA\xA6"; /* 測試計算長度 */ ueStrNCpy(u8string2, u8string, 3, STRNCPY_CLOSE); ok(!strcmp(u8string2, "\xE6\xB8\xAC\xE8\xA9\xA6\xE8\xA8\x88" /* 測試計 */ ), "ueStrNCpy"); u8string = "\xE6\xB8\xAC\xE8\xA9\xA6\xE8\xA8\x88\xE7\xAE\x97\xE9\x95\xB7\xE5\xBA\xA6"; /* 測試計算長度 */ u8string = ueStrSeek(u8string, 3); ok(!strcmp(u8string, "\xE7\xAE\x97\xE9\x95\xB7\xE5\xBA\xA6" /* 算長度 */ ), "ueStrSeek"); u8string = "\xE6\xB8\xAC\xE8\xA9\xA6\xE8\xA8\x88\xE7\xAE\x97\xE9\x95\xB7\xE5\xBA\xA6"; /* 測試計算長度 */ u8string = ueStrSeek(u8string, 0); ok(!strcmp (u8string, "\xE6\xB8\xAC\xE8\xA9\xA6\xE8\xA8\x88\xE7\xAE\x97\xE9\x95\xB7\xE5\xBA\xA6" /* 測試計算長度 */ ), "ueStrSeek"); }
void test_Backspace_in_select() { ChewingContext *ctx; int ret; ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "`<B>"); ok_candidate(ctx, NULL, 0); type_keystroke_by_string(ctx, "hk4"); ret = chewing_cand_TotalChoice(ctx); ok(ret == 0, "chewing_cand_TotalChoice() returns `%d' shall be `%d'", ret, 0); type_keystroke_by_string(ctx, "<D>"); ret = chewing_cand_TotalChoice(ctx); ok(ret > 0, "chewing_cand_TotalChoice() returns `%d' shall be greater than `%d'", ret, 0); type_keystroke_by_string(ctx, "<B>"); ret = chewing_cand_TotalChoice(ctx); ok(ret == 0, "chewing_cand_TotalChoice() returns `%d' shall be `%d'", ret, 0); chewing_delete(ctx); }
void test_Tab_connect_word() { ChewingContext *ctx; IntervalType it; ctx = chewing_new(); start_testcase(ctx, fd); chewing_set_maxChiSymbolLen(ctx, 16); type_keystroke_by_string(ctx, "u -4<L>"); chewing_interval_Enumerate(ctx); ok(chewing_interval_hasNext(ctx) == 1, "shall have next interval"); chewing_interval_Get(ctx, &it); ok(it.from == 0 && it.to == 1, "interval (%d, %d) shall be (0, 1)", it.from, it.to); ok(chewing_interval_hasNext(ctx) == 1, "shall have next interval"); chewing_interval_Get(ctx, &it); ok(it.from == 1 && it.to == 2, "interval (%d, %d) shall be (1, 2)", it.from, it.to); ok(chewing_interval_hasNext(ctx) == 0, "shall not have next interval"); /* connect 一 and 二 */ type_keystroke_by_string(ctx, "<T>"); chewing_interval_Enumerate(ctx); ok(chewing_interval_hasNext(ctx) == 1, "shall have next interval"); chewing_interval_Get(ctx, &it); ok(it.from == 0 && it.to == 2, "interval (%d, %d) shall be (0, 2)", it.from, it.to); ok(chewing_interval_hasNext(ctx) == 0, "shall not have next interval"); chewing_delete(ctx); }
void test_Down_not_entering_chewing() { ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "<D>"); ok_keystroke_rtn(ctx, KEYSTROKE_IGNORE); chewing_delete(ctx); }
void test_Backspace_remove_bopomofo() { ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "hk<B>"); ok_bopomofo_buffer(ctx, "\xE3\x84\x98" /* ㄘ */ ); chewing_delete(ctx); }
void test_Del_in_select() { ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "`<DC>"); ok_keystroke_rtn(ctx, KEYSTROKE_ABSORB); /* XXX: shall be ignore? */ chewing_delete(ctx); }
void test_Esc_entering_bopomofo() { ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "hk<EE>"); ok_bopomofo_buffer(ctx, ""); chewing_delete(ctx); }
void test_Esc_in_select() { ChewingContext *ctx; ctx = chewing_new(); start_testcase(ctx, fd); type_keystroke_by_string(ctx, "`<EE>"); ok_candidate(ctx, NULL, 0); chewing_delete(ctx); }
void test_set_null_logger() { ChewingContext *ctx; ctx = chewing_new(); start_testcase( ctx, fd ); chewing_set_logger( ctx, NULL, 0 ); type_keystroke_by_string( ctx, "hk4g4" ); chewing_delete( ctx ); }