From: brarcher Date: Sun, 18 Nov 2012 04:13:48 +0000 (+0000) Subject: Updating examples to use alternatives to the fail* API X-Git-Tag: 0.10.0~503 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bdc339e08045b5e2eaabbf8654b7c71b01ec35bc;p=check Updating examples to use alternatives to the fail* API git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@677 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- diff --git a/doc/example/tests/check_money.2.c b/doc/example/tests/check_money.2.c index 7c7c9d4..ecfde5d 100644 --- a/doc/example/tests/check_money.2.c +++ b/doc/example/tests/check_money.2.c @@ -5,10 +5,8 @@ START_TEST (test_money_create) { Money *m; m = money_create (5, "USD"); - fail_unless (money_amount (m) == 5, - "Amount not set correctly on creation"); - fail_unless (strcmp (money_currency (m), "USD") == 0, - "Currency not set correctly on creation"); + ck_assert_int_eq (money_amount (m), 5); + ck_assert_str_eq (money_currency (m), "USD"); money_free (m); } END_TEST diff --git a/doc/example/tests/check_money.3.c b/doc/example/tests/check_money.3.c index a19cf8b..eb339bf 100644 --- a/doc/example/tests/check_money.3.c +++ b/doc/example/tests/check_money.3.c @@ -6,10 +6,8 @@ START_TEST (test_money_create) { Money *m; m = money_create (5, "USD"); - fail_unless (money_amount (m) == 5, - "Amount not set correctly on creation"); - fail_unless (strcmp (money_currency (m), "USD") == 0, - "Currency not set correctly on creation"); + ck_assert_int_eq (money_amount (m), 5); + ck_assert_str_eq (money_currency (m), "USD"); money_free (m); } END_TEST diff --git a/doc/example/tests/check_money.6.c b/doc/example/tests/check_money.6.c index f47fc77..acb00f4 100644 --- a/doc/example/tests/check_money.6.c +++ b/doc/example/tests/check_money.6.c @@ -6,10 +6,8 @@ START_TEST (test_money_create) { Money *m; m = money_create (5, "USD"); - fail_unless (money_amount (m) == 5, - "Amount not set correctly on creation"); - fail_unless (strcmp (money_currency (m), "USD") == 0, - "Currency not set correctly on creation"); + ck_assert_int_eq (money_amount (m), 5); + ck_assert_str_eq (money_currency (m), "USD"); money_free (m); } END_TEST @@ -17,7 +15,7 @@ END_TEST START_TEST (test_money_create_neg) { Money *m = money_create (-1, "USD"); - fail_unless (m == NULL, + ck_assert_msg (m == NULL, "NULL should be returned on attempt to create with " "a negative amount"); } @@ -26,8 +24,10 @@ END_TEST START_TEST (test_money_create_zero) { Money *m = money_create (0, "USD"); - fail_unless (money_amount (m) == 0, - "Zero is a valid amount of money"); + if(money_amount (m) != 0) + { + ck_abort_msg("Zero is a valid amount of money"); + } } END_TEST diff --git a/doc/example/tests/check_money.7.c b/doc/example/tests/check_money.7.c index b935998..bbc03eb 100644 --- a/doc/example/tests/check_money.7.c +++ b/doc/example/tests/check_money.7.c @@ -18,17 +18,15 @@ teardown (void) START_TEST (test_money_create) { - fail_unless (money_amount (five_dollars) == 5, - "Amount not set correctly on creation"); - fail_unless (strcmp (money_currency (five_dollars), "USD") == 0, - "Currency not set correctly on creation"); + ck_assert_int_eq (money_amount (five_dollars), 5); + ck_assert_str_eq (money_currency (five_dollars), "USD"); } END_TEST START_TEST (test_money_create_neg) { Money *m = money_create (-1, "USD"); - fail_unless (m == NULL, + ck_assert_msg (m == NULL, "NULL should be returned on attempt to create with " "a negative amount"); } @@ -37,8 +35,10 @@ END_TEST START_TEST (test_money_create_zero) { Money *m = money_create (0, "USD"); - fail_unless (money_amount (m) == 0, - "Zero is a valid amount of money"); + if(money_amount (m) != 0) + { + ck_abort_msg("Zero is a valid amount of money"); + } } END_TEST diff --git a/doc/example/tests/check_money.c b/doc/example/tests/check_money.c index b935998..bbc03eb 100644 --- a/doc/example/tests/check_money.c +++ b/doc/example/tests/check_money.c @@ -18,17 +18,15 @@ teardown (void) START_TEST (test_money_create) { - fail_unless (money_amount (five_dollars) == 5, - "Amount not set correctly on creation"); - fail_unless (strcmp (money_currency (five_dollars), "USD") == 0, - "Currency not set correctly on creation"); + ck_assert_int_eq (money_amount (five_dollars), 5); + ck_assert_str_eq (money_currency (five_dollars), "USD"); } END_TEST START_TEST (test_money_create_neg) { Money *m = money_create (-1, "USD"); - fail_unless (m == NULL, + ck_assert_msg (m == NULL, "NULL should be returned on attempt to create with " "a negative amount"); } @@ -37,8 +35,10 @@ END_TEST START_TEST (test_money_create_zero) { Money *m = money_create (0, "USD"); - fail_unless (money_amount (m) == 0, - "Zero is a valid amount of money"); + if(money_amount (m) != 0) + { + ck_abort_msg("Zero is a valid amount of money"); + } } END_TEST