コード例 #1
0
ファイル: testaux.c プロジェクト: BMJHayward/liblcthw
int test7 (void) {
struct tagbstring t = bsStatic ("  i am  ");
bstring b;
int ret = 0;

	printf ("TEST: bJustify functions.\n");
	ret += 0 <= bJustifyLeft (&t, ' ');
	ret += 0 <= bJustifyRight (&t, 8, ' ');
	ret += 0 <= bJustifyMargin (&t, 8, ' ');
	ret += 0 <= bJustifyCenter (&t, 8, ' ');
	ret += 0 >  bJustifyLeft (b = bstrcpy (&t), ' ');
	ret += 0 >= biseqcstr (b, "i am");
	ret += 0 >  bJustifyRight (b, 8, ' ');
	ret += 0 >= biseqcstr (b, "    i am");
	ret += 0 >  bJustifyMargin (b, 8, ' ');
	ret += 0 >= biseqcstr (b, "i     am");
	ret += 0 >  bJustifyCenter (b, 8, ' ');
	ret += 0 >= biseqcstr (b, "  i am");
	bdestroy (b);

	printf ("\t# failures: %d\n", ret);

	return ret;
}
コード例 #2
0
ファイル: testaux.c プロジェクト: 1000copy/bstring
END_TEST

START_TEST(core_007)
{
	struct tagbstring t = bsStatic("  i am  ");
	int ret = 0;
	bstring b;
	ret = bJustifyLeft(&t, ' ');
	ck_assert(ret < 0);
	ret = bJustifyRight(&t, 8, ' ');
	ck_assert(ret < 0);
	ret = bJustifyMargin(&t, 8, ' ');
	ck_assert(ret < 0);
	ret = bJustifyCenter(&t, 8, ' ');
	ck_assert(ret < 0);
	b = bstrcpy(&t);
	ck_assert(b != NULL);
	ret = bJustifyLeft(b, ' ');
	ck_assert_int_eq(ret, BSTR_OK);
	ret = biseqcstr(b, "i am");
	ck_assert_int_eq(ret, 1);
	ret = bJustifyRight(b, 8, ' ');
	ck_assert_int_eq(ret, BSTR_OK);
	ret = biseqcstr(b, "    i am");
	ck_assert_int_eq(ret, 1);
	ret = bJustifyMargin(b, 8, ' ');
	ck_assert_int_eq(ret, BSTR_OK);
	ret = biseqcstr(b, "i     am");
	ck_assert_int_eq(ret, 1);
	ret = bJustifyCenter(b, 8, ' ');
	ck_assert_int_eq(ret, BSTR_OK);
	ret = biseqcstr(b, "  i am");
	ck_assert_int_eq(ret, 1);
	ret = bdestroy(b);
	ck_assert_int_eq(ret, BSTR_OK);
}