示例#1
0
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);
}
示例#2
0
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);
}
示例#3
0
void test_in_fullshape_mode()
{
	ChewingContext *ctx;
	size_t i;


	ctx = chewing_new();

	chewing_set_maxChiSymbolLen( ctx, 16 );
	chewing_set_ChiEngMode( ctx, SYMBOL_MODE );
	chewing_set_ShapeMode( ctx, FULLSHAPE_MODE );

	for ( i = 0; i < ARRAY_SIZE( SPECIAL_SYMBOL_TABLE ); ++i ) {
		// If fullshape symbol is collided with special symbol, use
		// fullshape symbol
		if ( is_fullshape_collision_key( SPECIAL_SYMBOL_TABLE[i].token ) )
			continue;

		type_keystroke_by_string( ctx, SPECIAL_SYMBOL_TABLE[i].token );
		ok_preedit_buffer( ctx, "" );
		ok_commit_buffer( ctx, SPECIAL_SYMBOL_TABLE[i].expected );
	}

	chewing_delete( ctx );
}
示例#4
0
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);
}
示例#5
0
void test_Backspace_word()
{
    ChewingContext *ctx;

    ctx = chewing_new();
    start_testcase(ctx, fd);
    chewing_set_maxChiSymbolLen(ctx, 16);

    type_keystroke_by_string(ctx, "hk4u g4<L><B><E>");
    ok_commit_buffer(ctx, "\xE6\xB8\xAC\xE8\xA9\xA6" /* 測試 */ );

    chewing_delete(ctx);
}
示例#6
0
void test_mode_change()
{
	chewing_Init( NULL, NULL );

	ChewingContext *ctx = chewing_new();
	ok( ctx, "chewing_new shall not return NULL" );

	chewing_set_maxChiSymbolLen( ctx, 16 );

	type_keystoke_by_string( ctx, CHINESE.token );
	ok_commit_buffer( ctx, CHINESE.expected );

	chewing_set_easySymbolInput( ctx, 1 );
	type_keystoke_by_string( ctx, EASY_SYMBOL[0].token );
	ok_commit_buffer( ctx, EASY_SYMBOL[0].expected );

	chewing_set_easySymbolInput( ctx, 0 );
	type_keystoke_by_string( ctx, CHINESE.token );
	ok_commit_buffer( ctx, CHINESE.expected );

	chewing_delete( ctx );
	chewing_Terminate();
}
void test_mode_change()
{
    ChewingContext *ctx;


    ctx = chewing_new();

    chewing_set_maxChiSymbolLen( ctx, 16 );

    type_keystroke_by_string( ctx, CHINESE.token );
    ok_commit_buffer( ctx, CHINESE.expected );

    chewing_set_easySymbolInput( ctx, 1 );
    type_keystroke_by_string( ctx, EASY_SYMBOL[0].token );
    type_keystroke_by_string( ctx, "<E>" );
    ok_commit_buffer( ctx, EASY_SYMBOL[0].expected );

    chewing_set_easySymbolInput( ctx, 0 );
    type_keystroke_by_string( ctx, CHINESE.token );
    ok_commit_buffer( ctx, CHINESE.expected );

    chewing_delete( ctx );
}
示例#8
0
void test_auto_commit_symbol()
{
    ChewingContext *ctx;

    ctx = chewing_new();
    start_testcase(ctx, fd);
    chewing_set_maxChiSymbolLen(ctx, 2);

    type_keystroke_by_string(ctx, "`31hk4g4" /* ,測試 */ );
    ok_preedit_buffer(ctx, "\xE6\xB8\xAC\xE8\xA9\xA6" /* 測試 */ );
    ok_commit_buffer(ctx, "\xEF\xBC\x8C" /* , */ );

    chewing_delete(ctx);
}
示例#9
0
void test_ShiftSpace()
{
    ChewingContext *ctx;
    int mode;

    ctx = chewing_new();
    start_testcase(ctx, fd);

    mode = chewing_get_ShapeMode(ctx);
    ok(mode == HALFSHAPE_MODE, "mode shall be HALFSHAPE_MODE");

    type_keystroke_by_string(ctx, "<SS>");
    mode = chewing_get_ShapeMode(ctx);
    ok(mode == FULLSHAPE_MODE, "mode shall be FULLSHAPE_MODE");

    type_keystroke_by_string(ctx, " ");
    ok_commit_buffer(ctx, "\xE3\x80\x80"); /* Fullshape Space (U+3000) */

    chewing_set_ChiEngMode(ctx, SYMBOL_MODE);
    type_keystroke_by_string(ctx, "a");
    ok_commit_buffer(ctx, "\xEF\xBD\x81"); /* Fullshape a */

    chewing_delete(ctx);
}
示例#10
0
void test_Esc_escCleanAllBuf()
{
    ChewingContext *ctx;

    ctx = chewing_new();
    start_testcase(ctx, fd);
    chewing_set_escCleanAllBuf(ctx, 1);

    type_keystroke_by_string(ctx, "hk4g4<EE>");
    ok_bopomofo_buffer(ctx, "");
    ok_preedit_buffer(ctx, "");
    ok_commit_buffer(ctx, "");

    chewing_delete(ctx);
}
示例#11
0
void test_type_easy_symbol()
{
	chewing_Init( NULL, NULL );

	ChewingContext *ctx = chewing_new();
	ok( ctx, "chewing_new shall not return NULL" );

	chewing_set_maxChiSymbolLen( ctx, 16 );
	chewing_set_easySymbolInput( ctx, 1 );

	for ( int i = 0; i < ARRAY_SIZE( EASY_SYMBOL ); ++i ) {
		type_keystoke_by_string( ctx, EASY_SYMBOL[i].token );
		ok_commit_buffer( ctx, EASY_SYMBOL[i].expected );
	}

	chewing_delete( ctx );
	chewing_Terminate();
}
示例#12
0
void test_select_candidate_rearward()
{
    /*
     * The following phrases are in dict
     * 一上來
     * 上來
     * 移上來
     * 移上
     */

    static const char *CAND_1[] = {
        "\xE4\xB8\x80\xE4\xB8\x8A\xE4\xBE\x86" /* 一上來 */ ,
        "\xE7\xA7\xBB\xE4\xB8\x8A\xE4\xBE\x86" /* 移上來 */ ,
    };

    static const char *CAND_2[] = {
        "\xE4\xB8\x8A\xE4\xBE\x86" /* 上來 */ ,
    };
    ChewingContext *ctx;

    clean_userphrase();

    ctx = chewing_new();
    start_testcase(ctx, fd);

    chewing_set_maxChiSymbolLen(ctx, 16);
    chewing_set_phraseChoiceRearward(ctx, 1);

    type_keystroke_by_string(ctx, "u6g;4x96");  /* ㄧˊㄕㄤˋㄌㄞˊ */
    ok_preedit_buffer(ctx, CAND_1[0]);

    type_keystroke_by_string(ctx, "<D>");       /* ㄧˊㄕㄤˋㄌㄞˊ */
    ok_candidate(ctx, CAND_1, ARRAY_SIZE(CAND_1));

    type_keystroke_by_string(ctx, "<D>");       /* ㄕㄤˋㄌㄞˊ */
    ok_candidate(ctx, CAND_2, ARRAY_SIZE(CAND_2));

    type_keystroke_by_string(ctx, "<D><D>2<E>");        /* select 移上來 */
    ok_commit_buffer(ctx, CAND_1[1]);

    chewing_delete(ctx);
}
示例#13
0
void test_in_easy_symbol_mode()
{
	ChewingContext *ctx;
	size_t i;


	ctx = chewing_new();

	chewing_set_maxChiSymbolLen( ctx, 16 );
	chewing_set_easySymbolInput( ctx, 1 );

	for ( i = 0; i < ARRAY_SIZE( SPECIAL_SYMBOL_TABLE ); ++i ) {
		type_keystroke_by_string( ctx, SPECIAL_SYMBOL_TABLE[i].token );
		ok_preedit_buffer( ctx, SPECIAL_SYMBOL_TABLE[i].expected );
		type_keystroke_by_string( ctx, "<E>" );
		ok_commit_buffer( ctx, SPECIAL_SYMBOL_TABLE[i].expected );
	}

	chewing_delete( ctx );
}
示例#14
0
void test_fullshape_input()
{
	ChewingContext *ctx;
	size_t i;


	ctx = chewing_new();

	chewing_set_ChiEngMode( ctx, SYMBOL_MODE );
	chewing_set_ShapeMode( ctx, FULLSHAPE_MODE );

	for ( i = 0; i < ARRAY_SIZE( FULLSHAPE_DATA ); ++i ) {
		type_keystroke_by_string( ctx, FULLSHAPE_DATA[i].token );
		// fullshape symbol does not present in preedit buffer.
		ok_preedit_buffer( ctx, "" );
		ok_commit_buffer( ctx, FULLSHAPE_DATA[i].expected );
	}

	chewing_delete( ctx );
}
示例#15
0
void test_Numlock_select_candidate()
{
	const TestData NUMLOCK_SELECT[] = {
		{ "hk4<D><N3><E>", "\xE6\xB8\xAC" /* 測 */ },
		{ "`<N1><E>", "\xE2\x80\xA6" /* … */ },
	};
	size_t i;
	ChewingContext *ctx;


	ctx = chewing_new();
	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 );
}
示例#16
0
void test_select_candidate_no_phrase_choice_rearward()
{
	/*
	 * The following phrases are in dict
	 * 一上來
	 * 上來
	 * 移上來
	 * 移上
	 */

	static const char *CAND_1[] = {
		"\xE4\xB8\x80\xE4\xB8\x8A\xE4\xBE\x86" /* 一上來 */,
		"\xE7\xA7\xBB\xE4\xB8\x8A\xE4\xBE\x86" /* 移上來 */,
	};

	static const char *CAND_2[] = {
		"\xE7\xA7\xBB\xE4\xB8\x8A" /* 移上 */,
	};

	ChewingContext *ctx;

	remove( TEST_HASH_DIR PLAT_SEPARATOR HASH_FILE );


	ctx = chewing_new();

	chewing_set_maxChiSymbolLen( ctx, 16 );

	type_keystroke_by_string( ctx, "u6g;4x96<L><L><L>" ); /* ㄧˊㄕㄤˋㄌㄞˊ */

	type_keystroke_by_string( ctx, "<D>" ); /* ㄧˊㄕㄤˋㄌㄞˊ */
	ok_candidate( ctx, CAND_1, ARRAY_SIZE( CAND_1 ) );

	type_keystroke_by_string( ctx, "<D>" ); /* ㄕㄤˋㄌㄞˊ */
	ok_candidate( ctx, CAND_2, ARRAY_SIZE( CAND_2 ) );

	type_keystroke_by_string( ctx, "<D><D>2<E>" ); /* select 移上來 */
	ok_commit_buffer( ctx, CAND_1[1] );

	chewing_delete( ctx );
}
示例#17
0
void test_type_symbol()
{
	ChewingContext *ctx;
	int i;

	chewing_Init( NULL, NULL );

	ctx = chewing_new();

	chewing_set_candPerPage( ctx, 10 );
	chewing_set_maxChiSymbolLen( ctx, 16 );

	for (i = 0; i < ARRAY_SIZE(SYMBOL); ++i ) {
		type_keystroke_by_string( ctx, SYMBOL[i].token );
		ok_preedit_buffer( ctx, "" );
		ok_commit_buffer( ctx, SYMBOL[i].expected );
	}

	chewing_delete( ctx );
	chewing_Terminate();
}
示例#18
0
void test_in_chinese_mode()
{
	ChewingContext *ctx;
	size_t i;


	ctx = chewing_new();

	chewing_set_maxChiSymbolLen( ctx, 16 );

	for ( i = 0; i < ARRAY_SIZE( SPECIAL_SYMBOL_TABLE ); ++i ) {
		// If bopomofo symbol is collided with special symbol, use
		// bopomofo symbol
		if ( is_bopomofo_collision_key( SPECIAL_SYMBOL_TABLE[i].token ) )
			continue;

		type_keystroke_by_string( ctx, SPECIAL_SYMBOL_TABLE[i].token );
		ok_preedit_buffer( ctx, SPECIAL_SYMBOL_TABLE[i].expected );
		type_keystroke_by_string( ctx, "<E>" );
		ok_commit_buffer( ctx, SPECIAL_SYMBOL_TABLE[i].expected );
	}

	chewing_delete( ctx );
}