Permalink
Browse files

Move userphrase test cases to test-userphrase.c

  • Loading branch information...
1 parent 7f0bdb1 commit c30f296e973fa687015cc875153973df3187b58f @czchen czchen committed Mar 22, 2013
Showing with 231 additions and 196 deletions.
  1. +2 −0 .gitignore
  2. +1 −0 CMakeLists.txt
  3. +1 −0 test/Makefile.am
  4. +0 −196 test/test-bopomofo.c
  5. +227 −0 test/test-userphrase.c
View
@@ -77,6 +77,8 @@ test/test-symbol
test/test-symbol.exe
test/test-special-symbol
test/test-special-symbol.exe
+test/test-userphrase
+test/test-userphrase.exe
test/test-utf8
test/test-utf8.exe
View
@@ -213,6 +213,7 @@ set(ALL_TESTCASES
test-reset
test-special-symbol
test-symbol
+ test-userphrase
test-utf8
)
set(ALL_TESTTOOLS
View
@@ -36,6 +36,7 @@ NATIVE_TESTS = \
test-regression \
test-symbol \
test-special-symbol \
+ test-userphrase \
test-utf8 \
$(NULL)
View
@@ -320,102 +320,6 @@ void test_Down()
test_Down_not_entering_chewing();
}
-void test_ShiftLeft_not_entering_chewing()
-{
- ChewingContext *ctx;
-
- chewing_Init( NULL, NULL );
-
- ctx = chewing_new();
- type_keystroke_by_string( ctx, "<SL>" );
- ok_keystroke_rtn( ctx, KEYSTROKE_IGNORE );
-
- chewing_delete( ctx );
- chewing_Terminate();
-}
-
-void test_ShiftLeft_add_userphrase()
-{
- static const char phrase[] = "\xE6\xB8\xAC\xE8\xA9\xA6" /* 測試 */;
- static const char bopomofo[] = "\xE3\x84\x98\xE3\x84\x9C\xCB\x8B \xE3\x84\x95\xCB\x8B" /* ㄘㄜˋ ㄕˋ */;
- int cursor;
- ChewingContext *ctx;
-
- remove( TEST_HASH_DIR PLAT_SEPARATOR HASH_FILE );
-
- chewing_Init( NULL, NULL );
-
- ctx = chewing_new();
- chewing_set_maxChiSymbolLen( ctx, 16 );
-
- ok( has_userphrase( ctx, bopomofo, phrase ) == 0,
- "`%s' shall not be in userphrase", phrase );
-
- type_keystroke_by_string( ctx, "hk4g4<SL><SL><E>" );
- ok_preedit_buffer( ctx, phrase );
- cursor = chewing_cursor_Current( ctx );
- ok( cursor == 0, "cursor position `%d' shall be 0", cursor );
- ok( has_userphrase( ctx, bopomofo, phrase ) == 1,
- "`%s' shall be in userphrase", phrase );
-
- chewing_delete( ctx );
- chewing_Terminate();
-}
-
-void test_ShiftLeft()
-{
- test_ShiftLeft_not_entering_chewing();
- test_ShiftLeft_add_userphrase();
-}
-
-void test_ShiftRight_not_entering_chewing()
-{
- ChewingContext *ctx;
-
- chewing_Init( NULL, NULL );
-
- ctx = chewing_new();
- type_keystroke_by_string( ctx, "<SR>" );
- ok_keystroke_rtn( ctx, KEYSTROKE_IGNORE );
-
- chewing_delete( ctx );
- chewing_Terminate();
-}
-
-void test_ShiftRight_add_userphrase()
-{
- static const char phrase[] = "\xE6\xB8\xAC\xE8\xA9\xA6" /* 測試 */;
- static const char bopomofo[] = "\xE3\x84\x98\xE3\x84\x9C\xCB\x8B \xE3\x84\x95\xCB\x8B" /* ㄘㄜˋ ㄕˋ */;
- int cursor;
- ChewingContext *ctx;
-
- remove( TEST_HASH_DIR PLAT_SEPARATOR HASH_FILE );
-
- chewing_Init( NULL, NULL );
-
- ctx = chewing_new();
- chewing_set_maxChiSymbolLen( ctx, 16 );
-
- ok( has_userphrase( ctx, bopomofo, phrase ) == 0,
- "`%s' shall not be in userphrase", phrase );
-
- type_keystroke_by_string( ctx, "hk4g4<L><L><SR><SR><E>" );
- ok_preedit_buffer( ctx, phrase );
- cursor = chewing_cursor_Current( ctx );
- ok( cursor == 2, "cursor position `%d' shall be 2", cursor );
- ok( has_userphrase( ctx, bopomofo, phrase ) == 1,
- "`%s' shall be in userphrase", phrase );
-
- chewing_delete( ctx );
- chewing_Terminate();
-}
-
-void test_ShiftRight()
-{
- test_ShiftRight_not_entering_chewing();
- test_ShiftRight_add_userphrase();
-}
-
void test_Tab_insert_breakpoint_between_word()
{
ChewingContext *ctx;
@@ -636,103 +540,6 @@ void test_PageDown()
chewing_Terminate();
}
-void test_CtrlNum_add_phrase_right()
-{
- static const char phrase[] = "\xE6\xB8\xAC\xE8\xA9\xA6" /* 測試 */;
- static const char bopomofo[] = "\xE3\x84\x98\xE3\x84\x9C\xCB\x8B \xE3\x84\x95\xCB\x8B" /* ㄘㄜˋ ㄕˋ */;
- int cursor;
- ChewingContext *ctx;
-
- remove( TEST_HASH_DIR PLAT_SEPARATOR HASH_FILE );
-
- chewing_Init( NULL, NULL );
-
- ctx = chewing_new();
- chewing_set_maxChiSymbolLen( ctx, 16 );
- chewing_set_addPhraseDirection( ctx, 0 );
-
- ok( has_userphrase( ctx, bopomofo, phrase ) == 0,
- "`%s' shall not be in userphrase", phrase );
-
- type_keystroke_by_string( ctx, "hk4g4<H><C2>" );
- ok_preedit_buffer( ctx, phrase );
- cursor = chewing_cursor_Current( ctx );
- ok( cursor == 0, "cursor position `%d' shall be 0", cursor );
- ok( has_userphrase( ctx, bopomofo, phrase ) == 1,
- "`%s' shall be in userphrase", phrase );
-
- chewing_delete( ctx );
- chewing_Terminate();
-}
-
-void test_CtrlNum_add_phrase_left()
-{
- static const char phrase[] = "\xE6\xB8\xAC\xE8\xA9\xA6" /* 測試 */;
- static const char bopomofo[] = "\xE3\x84\x98\xE3\x84\x9C\xCB\x8B \xE3\x84\x95\xCB\x8B" /* ㄘㄜˋ ㄕˋ */;
- int cursor;
- ChewingContext *ctx;
-
- remove( TEST_HASH_DIR PLAT_SEPARATOR HASH_FILE );
-
- chewing_Init( NULL, NULL );
-
- ctx = chewing_new();
- chewing_set_maxChiSymbolLen( ctx, 16 );
- chewing_set_addPhraseDirection( ctx, 1 );
-
- ok( has_userphrase( ctx, bopomofo, phrase ) == 0,
- "`%s' shall not be in userphrase", phrase );
-
- type_keystroke_by_string( ctx, "hk4g4<C2>" );
- ok_preedit_buffer( ctx, phrase );
- cursor = chewing_cursor_Current( ctx );
- ok( cursor == 2, "cursor position `%d' shall be 2", cursor );
- ok( has_userphrase( ctx, bopomofo, phrase ) == 1,
- "`%s' shall be in userphrase", phrase );
-
- chewing_delete( ctx );
- chewing_Terminate();
-}
-
-void test_CtrlNum_add_phrase_symbol_in_between()
-{
- static const char bopomofo[] = "\xE3\x84\x98\xE3\x84\x9C\xCB\x8B \xE3\x84\x95\xCB\x8B" /* ㄘㄜˋ ㄕˋ */;
- int cursor;
- ChewingContext *ctx;
-
- remove( TEST_HASH_DIR PLAT_SEPARATOR HASH_FILE );
-
- chewing_Init( NULL, NULL );
-
- ctx = chewing_new();
- chewing_set_maxChiSymbolLen( ctx, 16 );
- chewing_set_addPhraseDirection( ctx, 1 );
-
- ok( has_userphrase( ctx, bopomofo, NULL ) == 0,
- "`%s' shall not be in userphrase", bopomofo );
-
- type_keystroke_by_string( ctx, "hk4`1g4<C2>" );
- cursor = chewing_cursor_Current( ctx );
- ok( cursor == 3, "cursor position `%d' shall be 3", cursor );
-
- /*
- * FIXME: Current buggy here. User phrase shall not be added when there
- * is a symbol in between.
- */
- /* ok( has_userphrase( ctx, bopomofo, NULL ) == 0,
- "`%s' shall not be in userphrase", bopomofo ); */
-
- chewing_delete( ctx );
- chewing_Terminate();
-}
-
-void test_CtrlNum()
-{
- test_CtrlNum_add_phrase_right();
- test_CtrlNum_add_phrase_left();
- test_CtrlNum_add_phrase_symbol_in_between();
-}
-
void test_ShiftSpace()
{
/* FIXME: Implement this. */
@@ -843,16 +650,13 @@ int main()
test_Backspace();
test_Up();
test_Down();
- test_ShiftLeft();
- test_ShiftRight();
test_Tab();
test_DblTab();
test_Capslock();
test_Home();
test_End();
test_PageUp();
test_PageDown();
- test_CtrlNum();
test_ShiftSpace();
test_Numlock();
Oops, something went wrong.

0 comments on commit c30f296

Please sign in to comment.