示例#1
0
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);
}
示例#2
0
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);
}
示例#3
0
void test_set_ChiEngMode()
{
	const int VALUE[] = {
		CHINESE_MODE,
		SYMBOL_MODE,
	};

	const int INVALID_VALUE[] = {
		-1,
		2,
	};

	ChewingContext *ctx;
	size_t i;
	size_t j;

	print_function_name();

	ctx = chewing_new();

	for ( i = 0; i < ARRAY_SIZE( VALUE ); ++i ) {
		chewing_set_ChiEngMode( ctx, VALUE[i] );
		ok( chewing_get_ChiEngMode( ctx ) == VALUE[i],
			"ChiEngMode 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_ChiEngMode( ctx, INVALID_VALUE[j] );
			ok( chewing_get_ChiEngMode( ctx ) == VALUE[i],
				"ChiEngMode shall be `%d'", VALUE[i] );
		}
	}

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


	ctx = chewing_new();

	ok( chewing_kbtype_Total( ctx ) == ARRAY_SIZE( KEYBOARD_STRING ),
		"total keyboard_string type shall be %d", ARRAY_SIZE( KEYBOARD_STRING ) );

	chewing_kbtype_Enumerate( ctx );
	for ( i = 0; i < ARRAY_SIZE( KEYBOARD_STRING ); ++i ) {
		ok( chewing_kbtype_hasNext( ctx ) == 1 ,
			"shall have next keyboard_string type" );
		keyboard_string = chewing_kbtype_String( ctx );
		ok( strcmp( keyboard_string, KEYBOARD_STRING[i] ) == 0,
			"`%s' shall be `%s'", keyboard_string, KEYBOARD_STRING[i] );
		chewing_free( keyboard_string );
	}
	ok( chewing_kbtype_hasNext( ctx ) == 0 ,
		"shall not have next keyboard_string type" );
	keyboard_string = chewing_kbtype_String( ctx );
	ok( strcmp( keyboard_string, "" ) == 0,
		"`%s' shall be `%s'", keyboard_string, "" );
	chewing_free( keyboard_string );

	chewing_delete( ctx );
}
示例#6
0
void test_zuin_buffer()
{
	ChewingContext *ctx;
	ctx = chewing_new();

	type_keystroke_by_string( ctx, "1ul" );
	ok_zuin_buffer( ctx, "\xE3\x84\x85\xE3\x84\xA7\xE3\x84\xA0" /* ㄅㄧㄠ */ );

	type_keystroke_by_string( ctx, " " );
	ok_zuin_buffer( ctx, "" );

	type_keystroke_by_string( ctx, "ul" );
	ok_zuin_buffer( ctx, "\xE3\x84\xA7\xE3\x84\xA0" /* ㄧㄠ */ );

	type_keystroke_by_string( ctx, " " );
	ok_zuin_buffer( ctx, "" );

	type_keystroke_by_string( ctx, "3");
	ok_zuin_buffer( ctx, "\xCB\x87" /* ˇ */);

	type_keystroke_by_string( ctx, " " );
	ok_zuin_buffer( ctx, "" );

	chewing_delete( ctx );
}
示例#7
0
void test_select_candidate_4_bytes_utf8()
{
	ChewingContext *ctx;

	remove( TEST_HASH_DIR PLAT_SEPARATOR HASH_FILE );


	ctx = chewing_new();

	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 );
}
示例#8
0
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);
}
示例#9
0
void test_userphrase_auto_learn_hardcode_break()
{
	/* 的 is a hardcode break point, see ChewingIsBreakPoint */
	static const char phrase[] = "\xE7\x9A\x84\xE7\x9A\x84" /* 的的 */;
	static const char bopomofo[] = "\xE3\x84\x89\xE3\x84\x9C\xCB\x99 \xE3\x84\x89\xE3\x84\x9C\xCB\x99" /* ㄉㄜ˙ ㄉㄜ˙ */;
	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, "2k72k7<E>" );
	ok( has_userphrase( ctx, bopomofo, phrase ) == 0,
		"`%s' shall not be in userphrase", phrase );

	chewing_delete( ctx );
	chewing_Terminate();
}
示例#10
0
void test_set_addPhraseDirection()
{
	ChewingContext *ctx;
	int value;
	int mode;

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

	for ( value = 0; value < 2; ++value ) {
		chewing_set_addPhraseDirection( ctx, value );
		mode = chewing_get_addPhraseDirection( ctx );
		ok( mode == value,
			"addPhraseDirection `%d' shall be `%d'", mode, value );

		chewing_set_addPhraseDirection( ctx, -1 );
		mode = chewing_get_addPhraseDirection( ctx );
		ok( mode == value,
			"addPhraseDirection `%d' shall be `%d'", mode, value );

		chewing_set_addPhraseDirection( ctx, 2 );
		mode = chewing_get_addPhraseDirection( ctx );
		ok( mode == value,
			"addPhraseDirection `%d' shall be `%d'", mode, value );
	}

	chewing_delete( ctx );
}
示例#11
0
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);
}
示例#12
0
void test_set_fullshape()
{
	ChewingContext *ctx;


	ctx = chewing_new();

	ok( chewing_get_ShapeMode( ctx ) == HALFSHAPE_MODE,
		"default is HALFSHAPE_MODE" );

	chewing_set_ShapeMode( ctx, FULLSHAPE_MODE );
	ok( chewing_get_ShapeMode( ctx ) == FULLSHAPE_MODE,
		"mode shall change to FULLSHAPE_MODE" );

	// XXX: What is the correct behavior when input parameter is wrong?
//	chewing_set_ShapeMode( ctx, -1 );
//	ok( chewing_get_ShapeMode( ctx ) == FULLSHAPE_MODE,
//		"mode shall not change when parameter is invalid" );

	chewing_set_ShapeMode( ctx, HALFSHAPE_MODE );
	ok( chewing_get_ShapeMode( ctx ) == HALFSHAPE_MODE,
		"mode shall change to HALFSHAPE_MODE" );

	chewing_set_ShapeMode( ctx, -1 );
	ok( chewing_get_ShapeMode( ctx ) == HALFSHAPE_MODE,
		"mode shall not change when parameter is invalid" );


	chewing_delete( ctx );
}
示例#13
0
void test_set_autoShiftCur()
{
	ChewingContext *ctx;
	int value;
	int mode;

	chewing_Init( 0, 0 );

	ctx = chewing_new();

	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 );
	chewing_Terminate();
}
示例#14
0
void test_set_easySymbolInput()
{
	ChewingContext *ctx;
	int value;
	int mode;

	chewing_Init( 0, 0 );

	ctx = chewing_new();

	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 );
	chewing_Terminate();
}
示例#15
0
void test_set_spaceAsSelection()
{
	ChewingContext *ctx;
	int value;
	int mode;

	chewing_Init( 0, 0 );

	ctx = chewing_new();

	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 );
	chewing_Terminate();
}
示例#16
0
void test_set_escCleanAllBuf()
{
	ChewingContext *ctx;
	int value;
	int mode;

	chewing_Init( 0, 0 );

	ctx = chewing_new();

	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 );
	chewing_Terminate();
}
示例#17
0
void test_set_selKey()
{
	ChewingContext *ctx;
	int *select_key;

	chewing_Init( 0, 0 );

	ctx = chewing_new();

	chewing_set_maxChiSymbolLen( ctx, 16 );

	// XXX: chewing_set_selKey shall accept const char *.
	chewing_set_selKey( ctx,
		ALTERNATE_SELECT_KEY, ARRAY_SIZE( ALTERNATE_SELECT_KEY ));
	select_key = chewing_get_selKey( ctx );
	ok( select_key, "chewing_get_selKey shall not return NULL" );
	ok( !memcmp( select_key, ALTERNATE_SELECT_KEY,
		sizeof( ALTERNATE_SELECT_KEY )),
		"select key shall be ALTERNATE_SELECT_KEY");

	type_keystroke_by_string( ctx, DATA.token );
	ok_preedit_buffer( ctx, DATA.expected );

	chewing_free( select_key );

	chewing_delete( ctx );
	chewing_Terminate();
}
示例#18
0
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 );
}
示例#19
0
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 );
}
示例#20
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);
}
示例#21
0
void test_set_phraseChoiceRearward()
{
	ChewingContext *ctx;
	int value;
	int mode;

	chewing_Init( 0, 0 );

	ctx = chewing_new();

	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 );
	chewing_Terminate();
}
示例#22
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);
}
示例#23
0
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();
}
示例#24
0
/**
 * @brief Destroy the input method while unload it.
 *
 * @return int
 **/
__EXPORT_API
void FcitxChewingDestroy(void* arg)
{
    FcitxChewing* chewing = (FcitxChewing*) arg;
    chewing_delete(chewing->context);
    chewing_Terminate();
    free(arg);
}
示例#25
0
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);
}
示例#26
0
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);
}
示例#27
0
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);
}
示例#28
0
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);
}
示例#29
0
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);
}
示例#30
0
void test_Up_not_entering_chewing()
{
	ChewingContext *ctx;


	ctx = chewing_new();
	type_keystroke_by_string( ctx, "<U>" );
	ok_keystroke_rtn( ctx, KEYSTROKE_IGNORE );

	chewing_delete( ctx );
}