From: brarcher Date: Sun, 4 Nov 2012 03:27:03 +0000 (+0000) Subject: replace usage of fail_unless() with ck_assert_msg() X-Git-Tag: 0.10.0~527 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5fc0d8a2373bbb39b18674e3cd8110dbb301cedb;p=check replace usage of fail_unless() with ck_assert_msg() git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@653 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- diff --git a/tests/check_check_fixture.c b/tests/check_check_fixture.c index 49972e7..cde6c0a 100644 --- a/tests/check_check_fixture.c +++ b/tests/check_check_fixture.c @@ -43,7 +43,7 @@ START_TEST(test_fixture_fail_counts) nrun = srunner_ntests_run(fixture_sr); nfail = srunner_ntests_failed(fixture_sr); - fail_unless (nrun == 1 && nfail == 1, + ck_assert_msg (nrun == 1 && nfail == 1, "Counts for run and fail for fixture failure not correct"); } END_TEST @@ -53,7 +53,7 @@ START_TEST(test_print_counts) char *srstat = sr_stat_str(fixture_sr); const char *exp = "0%: Checks: 1, Failures: 1, Errors: 0"; - fail_unless(strcmp(srstat, exp) == 0, + ck_assert_msg(strcmp(srstat, exp) == 0, "SRunner stat string incorrect with setup failure"); free(srstat); } @@ -117,7 +117,7 @@ START_TEST(test_ch_setup) tcase_add_checked_fixture(tc,sub_ch_setup_norm,sub_ch_teardown_norm); srunner_run_all(sr, CK_VERBOSE); - fail_unless(srunner_ntests_failed(sr) == 0, + ck_assert_msg(srunner_ntests_failed(sr) == 0, "Checked setup not being run correctly"); srunner_free(sr); @@ -154,7 +154,7 @@ END_TEST START_TEST(test_sub_pass) { - fail_unless(1 == 1, "Always pass"); + ck_assert_msg(1 == 1, "Always pass"); } END_TEST @@ -174,14 +174,14 @@ START_TEST(test_ch_setup_fail) sr = srunner_create(s); srunner_run_all(sr,CK_VERBOSE); - fail_unless (srunner_ntests_run(sr) == 1, + ck_assert_msg (srunner_ntests_run(sr) == 1, "Test run counts not correct for checked setup failure"); - fail_unless (srunner_ntests_failed(sr) == 1, + ck_assert_msg (srunner_ntests_failed(sr) == 1, "Failure counts not correct for checked setup failure"); strstat= sr_stat_str(sr); - fail_unless(strcmp(strstat, + ck_assert_msg(strcmp(strstat, "0%: Checks: 1, Failures: 1, Errors: 0") == 0, "SRunner stat string incorrect with checked setup failure"); @@ -214,9 +214,9 @@ START_TEST(test_ch_setup_fail_nofork) srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all(sr, CK_VERBOSE); - fail_unless (srunner_ntests_run(sr) == 1, + ck_assert_msg (srunner_ntests_run(sr) == 1, "Test run counts not correct for checked setup failure"); - fail_unless (srunner_ntests_failed(sr) == 1, + ck_assert_msg (srunner_ntests_failed(sr) == 1, "Failure counts not correct for checked setup failure"); } END_TEST @@ -237,9 +237,9 @@ START_TEST(test_ch_setup_fail_nofork_2) srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all(sr, CK_VERBOSE); - fail_unless (srunner_ntests_run(sr) == 1, + ck_assert_msg (srunner_ntests_run(sr) == 1, "Test run counts not correct for checked setup failure"); - fail_unless (srunner_ntests_failed(sr) == 1, + ck_assert_msg (srunner_ntests_failed(sr) == 1, "Failure counts not correct for checked setup failure"); } END_TEST @@ -262,12 +262,12 @@ START_TEST(test_ch_setup_pass_nofork) testval_up = 1; testval_down = 1; srunner_run_all(sr, CK_VERBOSE); - fail_unless(testval_up == 7, "Multiple setups failed"); - fail_unless(testval_down == 7, "Multiple teardowns failed"); + ck_assert_msg(testval_up == 7, "Multiple setups failed"); + ck_assert_msg(testval_down == 7, "Multiple teardowns failed"); - fail_unless (srunner_ntests_run(sr) == 1, + ck_assert_msg (srunner_ntests_run(sr) == 1, "Test run counts not correct for checked setup failure"); - fail_unless (srunner_ntests_failed(sr) == 0, + ck_assert_msg (srunner_ntests_failed(sr) == 0, "Failure counts not correct for checked setup failure"); } END_TEST @@ -288,14 +288,14 @@ START_TEST(test_ch_setup_sig) sr = srunner_create(s); srunner_run_all(sr,CK_VERBOSE); - fail_unless (srunner_ntests_failed(sr) == 1, + ck_assert_msg (srunner_ntests_failed(sr) == 1, "Failure counts not correct for checked setup signal"); - fail_unless (srunner_ntests_run(sr) == 1, + ck_assert_msg (srunner_ntests_run(sr) == 1, "Test run counts not correct for checked setup signal"); strstat= sr_stat_str(sr); - fail_unless(strcmp(strstat, + ck_assert_msg(strcmp(strstat, "0%: Checks: 1, Failures: 0, Errors: 1") == 0, "SRunner stat string incorrect with checked setup signal"); @@ -316,19 +316,19 @@ END_TEST static void sub_ch_setup_dual_1(void) { - fail_unless(testval_up == 1, "Wrong start value"); + ck_assert_msg(testval_up == 1, "Wrong start value"); testval_up += 2; } static void sub_ch_setup_dual_2(void) { - fail_unless(testval_up == 3, "First setup failed"); + ck_assert_msg(testval_up == 3, "First setup failed"); testval_up += 3; } START_TEST(test_sub_two_setups) { - fail_unless(testval_up == 6, "Multiple setups failed"); + ck_assert_msg(testval_up == 6, "Multiple setups failed"); } END_TEST @@ -348,7 +348,7 @@ START_TEST(test_ch_setup_two_setups_fork) testval_up = 1; srunner_run_all(sr, CK_VERBOSE); - fail_unless(srunner_ntests_failed(sr) == 0, + ck_assert_msg(srunner_ntests_failed(sr) == 0, "Problem with several setups"); srunner_free(sr); @@ -371,14 +371,14 @@ START_TEST(test_ch_teardown_fail) sr = srunner_create(s); srunner_run_all(sr,CK_VERBOSE); - fail_unless (srunner_ntests_failed(sr) == 1, + ck_assert_msg (srunner_ntests_failed(sr) == 1, "Failure counts not correct for checked teardown failure"); - fail_unless (srunner_ntests_run(sr) == 1, + ck_assert_msg (srunner_ntests_run(sr) == 1, "Test run counts not correct for checked teardown failure"); strstat= sr_stat_str(sr); - fail_unless(strcmp(strstat, + ck_assert_msg(strcmp(strstat, "0%: Checks: 1, Failures: 1, Errors: 0") == 0, "SRunner stat string incorrect with checked setup failure"); @@ -413,14 +413,14 @@ START_TEST(test_ch_teardown_sig) sr = srunner_create(s); srunner_run_all(sr,CK_VERBOSE); - fail_unless (srunner_ntests_failed(sr) == 1, + ck_assert_msg (srunner_ntests_failed(sr) == 1, "Failure counts not correct for checked teardown signal"); - fail_unless (srunner_ntests_run(sr) == 1, + ck_assert_msg (srunner_ntests_run(sr) == 1, "Test run counts not correct for checked teardown signal"); strstat= sr_stat_str(sr); - fail_unless(strcmp(strstat, + ck_assert_msg(strcmp(strstat, "0%: Checks: 1, Failures: 0, Errors: 1") == 0, "SRunner stat string incorrect with checked teardown signal"); @@ -443,12 +443,12 @@ END_TEST /* Teardowns are run in reverse order */ static void sub_ch_teardown_dual_1(void) { - fail_unless(testval_down == 6, "Second teardown failed"); + ck_assert_msg(testval_down == 6, "Second teardown failed"); } static void sub_ch_teardown_dual_2(void) { - fail_unless(testval_down == 3, "First teardown failed"); + ck_assert_msg(testval_down == 3, "First teardown failed"); testval_down += 3; } @@ -492,7 +492,7 @@ START_TEST(test_ch_teardown_two_teardowns_fork) } free(tra); } - fail_unless(nr_of_failures == 0, "Problem with several teardowns\n %s", + ck_assert_msg(nr_of_failures == 0, "Problem with several teardowns\n %s", errm); srunner_free(sr); diff --git a/tests/check_check_fork.c b/tests/check_check_fork.c index 447e44d..22e2c93 100644 --- a/tests/check_check_fork.c +++ b/tests/check_check_fork.c @@ -23,14 +23,14 @@ END_TEST START_TEST(test_nofork_sideeffects) { - fail_unless(counter == 1, + ck_assert_msg(counter == 1, "Side effects not seen across tests"); } END_TEST START_TEST(test_nofork_pid) { - fail_unless(mypid == getpid(), + ck_assert_msg(mypid == getpid(), "Unit test is in a different adresss space from setup code"); } END_TEST @@ -71,7 +71,7 @@ void fork_teardown (void) START_TEST(test_default_fork) { - fail_unless(srunner_fork_status(fork_dummy_sr) == CK_FORK, + ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_FORK, "Default fork status not set correctly"); } END_TEST @@ -79,7 +79,7 @@ END_TEST START_TEST(test_set_fork) { srunner_set_fork_status(fork_dummy_sr, CK_NOFORK); - fail_unless(srunner_fork_status(fork_dummy_sr) == CK_NOFORK, + ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_NOFORK, "Fork status not changed correctly"); } END_TEST @@ -87,7 +87,7 @@ END_TEST START_TEST(test_env) { putenv((char *) "CK_FORK=no"); - fail_unless(srunner_fork_status(fork_dummy_sr) == CK_NOFORK, + ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_NOFORK, "Fork status does not obey environment variable"); } END_TEST @@ -96,7 +96,7 @@ START_TEST(test_env_and_set) { putenv((char *) "CK_FORK=no"); srunner_set_fork_status(fork_dummy_sr, CK_FORK); - fail_unless(srunner_fork_status(fork_dummy_sr) == CK_FORK, + ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_FORK, "Explicit setting of fork status should override env"); } END_TEST @@ -104,7 +104,7 @@ END_TEST START_TEST(test_nofork) { - fail_unless(srunner_ntests_failed(fork_sr) == 0, + ck_assert_msg(srunner_ntests_failed(fork_sr) == 0, "Errors on nofork test"); } END_TEST diff --git a/tests/check_check_limit.c b/tests/check_check_limit.c index afd1c5d..156241c 100644 --- a/tests/check_check_limit.c +++ b/tests/check_check_limit.c @@ -23,7 +23,7 @@ static void limit_teardown (void) START_TEST(test_summary) { - fail_unless(strcmp(sr_stat_str(sr), + ck_assert_msg(strcmp(sr_stat_str(sr), "100%: Checks: 0, Failures: 0, Errors: 0") == 0, "Bad statistics string for empty suite"); } diff --git a/tests/check_check_log.c b/tests/check_check_log.c index 96bf58c..ed601b1 100644 --- a/tests/check_check_log.c +++ b/tests/check_check_log.c @@ -35,8 +35,8 @@ START_TEST(test_set_log) srunner_set_log (sr, "test_log"); - fail_unless (srunner_has_log (sr), "SRunner not logging"); - fail_unless (strcmp(srunner_log_fname(sr), "test_log") == 0, + ck_assert_msg (srunner_has_log (sr), "SRunner not logging"); + ck_assert_msg (strcmp(srunner_log_fname(sr), "test_log") == 0, "Bad file name returned"); } END_TEST @@ -49,23 +49,23 @@ START_TEST(test_set_log_env) SRunner *sr = srunner_create(s); /* check that setting log file via environment variable works */ - fail_unless(save_set_env("CK_LOG_FILE_NAME", "test_log", &old_val) == 0, + ck_assert_msg(save_set_env("CK_LOG_FILE_NAME", "test_log", &old_val) == 0, "Failed to set environment variable"); - fail_unless (srunner_has_log (sr), "SRunner not logging"); - fail_unless (strcmp(srunner_log_fname(sr), "test_log") == 0, + ck_assert_msg (srunner_has_log (sr), "SRunner not logging"); + ck_assert_msg (strcmp(srunner_log_fname(sr), "test_log") == 0, "Bad file name returned"); /* check that explicit call to srunner_set_log() overrides environment variable */ srunner_set_log (sr, "test2_log"); - fail_unless (srunner_has_log (sr), "SRunner not logging"); - fail_unless (strcmp(srunner_log_fname(sr), "test2_log") == 0, + ck_assert_msg (srunner_has_log (sr), "SRunner not logging"); + ck_assert_msg (strcmp(srunner_log_fname(sr), "test2_log") == 0, "Bad file name returned"); /* restore old environment */ - fail_unless(restore_env("CK_LOG_FILE_NAME", old_val) == 0, + ck_assert_msg(restore_env("CK_LOG_FILE_NAME", old_val) == 0, "Failed to restore environment variable"); } END_TEST @@ -75,8 +75,8 @@ START_TEST(test_no_set_log) Suite *s = suite_create("Suite"); SRunner *sr = srunner_create(s); - fail_unless (!srunner_has_log (sr), "SRunner not logging"); - fail_unless (srunner_log_fname(sr) == NULL, "Bad file name returned"); + ck_assert_msg (!srunner_has_log (sr), "SRunner not logging"); + ck_assert_msg (srunner_log_fname(sr) == NULL, "Bad file name returned"); } END_TEST @@ -88,7 +88,7 @@ START_TEST(test_double_set_log) srunner_set_log (sr, "test_log"); srunner_set_log (sr, "test2_log"); - fail_unless(strcmp(srunner_log_fname(sr), "test_log") == 0, + ck_assert_msg(strcmp(srunner_log_fname(sr), "test_log") == 0, "Log file is initialize only and shouldn't be changeable once set"); } END_TEST @@ -101,8 +101,8 @@ START_TEST(test_set_xml) srunner_set_xml (sr, "test_log.xml"); - fail_unless (srunner_has_xml (sr), "SRunner not logging XML"); - fail_unless (strcmp(srunner_xml_fname(sr), "test_log.xml") == 0, + ck_assert_msg (srunner_has_xml (sr), "SRunner not logging XML"); + ck_assert_msg (strcmp(srunner_xml_fname(sr), "test_log.xml") == 0, "Bad file name returned"); } END_TEST @@ -115,23 +115,23 @@ START_TEST(test_set_xml_env) SRunner *sr = srunner_create(s); /* check that setting XML log file via environment variable works */ - fail_unless(save_set_env("CK_XML_LOG_FILE_NAME", "test_log.xml", &old_val) == 0, + ck_assert_msg(save_set_env("CK_XML_LOG_FILE_NAME", "test_log.xml", &old_val) == 0, "Failed to set environment variable"); - fail_unless (srunner_has_xml (sr), "SRunner not logging XML"); - fail_unless (strcmp(srunner_xml_fname(sr), "test_log.xml") == 0, + ck_assert_msg (srunner_has_xml (sr), "SRunner not logging XML"); + ck_assert_msg (strcmp(srunner_xml_fname(sr), "test_log.xml") == 0, "Bad file name returned"); /* check that explicit call to srunner_set_xml() overrides environment variable */ srunner_set_xml (sr, "test2_log.xml"); - fail_unless (srunner_has_xml (sr), "SRunner not logging XML"); - fail_unless (strcmp(srunner_xml_fname(sr), "test2_log.xml") == 0, + ck_assert_msg (srunner_has_xml (sr), "SRunner not logging XML"); + ck_assert_msg (strcmp(srunner_xml_fname(sr), "test2_log.xml") == 0, "Bad file name returned"); /* restore old environment */ - fail_unless(restore_env("CK_XML_LOG_FILE_NAME", old_val) == 0, + ck_assert_msg(restore_env("CK_XML_LOG_FILE_NAME", old_val) == 0, "Failed to restore environment variable"); } END_TEST @@ -141,8 +141,8 @@ START_TEST(test_no_set_xml) Suite *s = suite_create("Suite"); SRunner *sr = srunner_create(s); - fail_unless (!srunner_has_xml (sr), "SRunner not logging XML"); - fail_unless (srunner_xml_fname(sr) == NULL, "Bad file name returned"); + ck_assert_msg (!srunner_has_xml (sr), "SRunner not logging XML"); + ck_assert_msg (srunner_xml_fname(sr) == NULL, "Bad file name returned"); } END_TEST @@ -154,7 +154,7 @@ START_TEST(test_double_set_xml) srunner_set_xml (sr, "test_log.xml"); srunner_set_xml (sr, "test2_log.xml"); - fail_unless(strcmp(srunner_xml_fname(sr), "test_log.xml") == 0, + ck_assert_msg(strcmp(srunner_xml_fname(sr), "test_log.xml") == 0, "XML Log file is initialize only and shouldn't be changeable once set"); } END_TEST diff --git a/tests/check_check_log_internal.c b/tests/check_check_log_internal.c index c223534..5f30cb7 100644 --- a/tests/check_check_log_internal.c +++ b/tests/check_check_log_internal.c @@ -27,8 +27,8 @@ START_TEST(test_init_logging_subunit) first_log = list_val(sr->loglst); fail_if (first_log == NULL, "log is NULL"); list_advance(sr->loglst); - fail_unless(list_at_end(sr->loglst), "More than one entry in log list"); - fail_unless(first_log->lfun == subunit_lfun, + ck_assert_msg(list_at_end(sr->loglst), "More than one entry in log list"); + ck_assert_msg(first_log->lfun == subunit_lfun, "Log function is not the subunit lfun."); srunner_end_logging(sr); srunner_free(sr); diff --git a/tests/check_check_master.c b/tests/check_check_master.c index b7fac4e..2a6fc96 100644 --- a/tests/check_check_master.c +++ b/tests/check_check_master.c @@ -133,7 +133,7 @@ START_TEST(test_check_nfailures) failed++; } } - fail_unless (sub_nfailed == failed, + ck_assert_msg (sub_nfailed == failed, "Unexpected number of failures received, %d, expected %d.", sub_nfailed, failed); } @@ -141,7 +141,7 @@ END_TEST START_TEST(test_check_ntests_run) { - fail_unless (sub_ntests == nr_of_master_tests, + ck_assert_msg (sub_ntests == nr_of_master_tests, "Unexpected number of tests run, %d.", sub_ntests); } END_TEST @@ -162,7 +162,7 @@ START_TEST(test_check_failure_msgs) fail_if(i - passed > sub_nfailed, NULL); tr = tr_fail_array[i - passed]; - fail_unless(tr != NULL, NULL); + ck_assert_msg(tr != NULL, NULL); got_msg = tr_msg(tr); expected_msg = master_tests[i].msg; if (strcmp(got_msg, expected_msg) != 0) { @@ -191,7 +191,7 @@ START_TEST(test_check_failure_lnos) fail_if(i - passed > sub_nfailed, NULL); tr = tr_fail_array[i - passed]; - fail_unless(tr != NULL, NULL); + ck_assert_msg(tr != NULL, NULL); line_no = master_tests_lineno[i]; if (line_no > 0 && tr_lno(tr) != line_no) { char *emsg = malloc(MAXSTR); @@ -218,8 +218,8 @@ START_TEST(test_check_failure_ftypes) fail_if(i - passed > sub_nfailed, NULL); tr = tr_fail_array[i - passed]; - fail_unless(tr != NULL, NULL); - fail_unless(master_tests[i].failure_type == tr_rtype(tr), + ck_assert_msg(tr != NULL, NULL); + ck_assert_msg(master_tests[i].failure_type == tr_rtype(tr), "Failure type wrong for test %d", i); } } @@ -230,9 +230,9 @@ START_TEST(test_check_failure_lfiles) int i; for (i = 0; i < sub_nfailed; i++) { TestResult *tr = tr_fail_array[i]; - fail_unless(tr != NULL, NULL); - fail_unless(tr_lfile(tr) != NULL, "Bad file name for test %d", i); - fail_unless(strstr(tr_lfile(tr), "check_check_sub.c") != 0, + ck_assert_msg(tr != NULL, NULL); + ck_assert_msg(tr_lfile(tr) != NULL, "Bad file name for test %d", i); + ck_assert_msg(strstr(tr_lfile(tr), "check_check_sub.c") != 0, "Bad file name for test %d", i); } } @@ -269,7 +269,7 @@ END_TEST START_TEST(test_check_all_ftypes) { - fail_unless(master_tests[_i].failure_type == tr_rtype(tr_all_array[_i]), + ck_assert_msg(master_tests[_i].failure_type == tr_rtype(tr_all_array[_i]), "Failure type wrong for test %d", _i); } END_TEST @@ -282,7 +282,7 @@ static void test_fixture_setup(void) START_TEST(test_setup) { - fail_unless (test_fixture_val == 1, + ck_assert_msg (test_fixture_val == 1, "Value not setup or changed across tests correctly"); test_fixture_val = 2; } @@ -295,7 +295,7 @@ static void test_fixture_teardown (void) START_TEST(test_teardown) { - fail_unless (test_fixture_val == 3, + ck_assert_msg (test_fixture_val == 3, "Value not changed correctly in teardown"); } END_TEST diff --git a/tests/check_check_msg.c b/tests/check_check_msg.c index 9a96d6d..b446fdd 100644 --- a/tests/check_check_msg.c +++ b/tests/check_check_msg.c @@ -21,15 +21,15 @@ START_TEST(test_send) tr = receive_test_result(0); teardown_messaging(); - fail_unless (tr != NULL, + ck_assert_msg (tr != NULL, "No test result received"); - fail_unless (tr_ctx(tr) == CK_CTX_TEST, + ck_assert_msg (tr_ctx(tr) == CK_CTX_TEST, "Bad CTX received"); - fail_unless (strcmp(tr_msg(tr), "Oops") == 0, + ck_assert_msg (strcmp(tr_msg(tr), "Oops") == 0, "Bad failure msg received"); - fail_unless (strcmp(tr_lfile(tr), "abc125.c") == 0, + ck_assert_msg (strcmp(tr_lfile(tr), "abc125.c") == 0, "Bad loc file received"); - fail_unless (tr_lno(tr) == 25, + ck_assert_msg (tr_lno(tr) == 25, "Bad loc line received"); if (tr != NULL) free(tr); @@ -52,13 +52,13 @@ START_TEST(test_send_big) tr = receive_test_result(0); teardown_messaging(); - fail_unless (tr != NULL, + ck_assert_msg (tr != NULL, "No test result received"); - fail_unless (tr_ctx(tr) == CK_CTX_TEST, + ck_assert_msg (tr_ctx(tr) == CK_CTX_TEST, "Bad CTX received"); - fail_unless (strcmp(tr_lfile(tr), "abc124.c") == 0, + ck_assert_msg (strcmp(tr_lfile(tr), "abc124.c") == 0, "Bad loc file received"); - fail_unless (tr_lno(tr) == i -1, + ck_assert_msg (tr_lno(tr) == i -1, "Bad loc line received"); if (tr != NULL) free(tr); @@ -78,13 +78,13 @@ START_TEST(test_send_test_error) tr = receive_test_result(1); teardown_messaging(); - fail_unless (tr != NULL, + ck_assert_msg (tr != NULL, "No test result received"); - fail_unless (tr_ctx(tr) == CK_CTX_TEST, + ck_assert_msg (tr_ctx(tr) == CK_CTX_TEST, "Bad CTX received"); - fail_unless (strcmp(tr_lfile(tr), "abc125.c") == 0, + ck_assert_msg (strcmp(tr_lfile(tr), "abc125.c") == 0, "Bad loc file received"); - fail_unless (tr_lno(tr) == 25, + ck_assert_msg (tr_lno(tr) == 25, "Bad loc line received"); if (tr != NULL) free(tr); @@ -105,15 +105,15 @@ START_TEST(test_send_with_passing_teardown) tr = receive_test_result(0); teardown_messaging(); - fail_unless (tr != NULL, + ck_assert_msg (tr != NULL, "No test result received"); - fail_unless (tr_ctx(tr) == CK_CTX_TEST, + ck_assert_msg (tr_ctx(tr) == CK_CTX_TEST, "Bad CTX received"); - fail_unless (tr_msg(tr) == NULL, + ck_assert_msg (tr_msg(tr) == NULL, "Bad failure msg received"); - fail_unless (strcmp(tr_lfile(tr), "abc125.c") == 0, + ck_assert_msg (strcmp(tr_lfile(tr), "abc125.c") == 0, "Bad loc file received"); - fail_unless (tr_lno(tr) == 25, + ck_assert_msg (tr_lno(tr) == 25, "Bad loc line received"); if (tr != NULL) free(tr); @@ -134,15 +134,15 @@ START_TEST(test_send_with_error_teardown) tr = receive_test_result(1); teardown_messaging(); - fail_unless (tr != NULL, + ck_assert_msg (tr != NULL, "No test result received"); - fail_unless (tr_ctx(tr) == CK_CTX_TEARDOWN, + ck_assert_msg (tr_ctx(tr) == CK_CTX_TEARDOWN, "Bad CTX received"); - fail_unless (tr_msg(tr) == NULL, + ck_assert_msg (tr_msg(tr) == NULL, "Bad failure msg received"); - fail_unless (strcmp(tr_lfile(tr), "abc126.c") == 0, + ck_assert_msg (strcmp(tr_lfile(tr), "abc126.c") == 0, "Bad loc file received"); - fail_unless (tr_lno(tr) == 54, + ck_assert_msg (tr_lno(tr) == 54, "Bad loc line received"); if (tr != NULL) free(tr); diff --git a/tests/check_check_pack.c b/tests/check_check_pack.c index c703de0..48169a6 100644 --- a/tests/check_check_pack.c +++ b/tests/check_check_pack.c @@ -26,7 +26,7 @@ START_TEST(test_pack_fmsg) fmsg->msg = (char *) ""; upack (buf, (CheckMsg *) fmsg, &type); - fail_unless (type == CK_MSG_FAIL, + ck_assert_msg (type == CK_MSG_FAIL, "Bad type unpacked for FailMsg"); if (strcmp (fmsg->msg, "Hello, world!") != 0) { @@ -57,7 +57,7 @@ START_TEST(test_pack_loc) lmsg->line = 0; upack (buf, (CheckMsg *) lmsg, &type); - fail_unless (type == CK_MSG_LOC, + ck_assert_msg (type == CK_MSG_LOC, "Bad type unpacked for LocMsg"); if (lmsg->line != 125) { @@ -92,7 +92,7 @@ START_TEST(test_pack_ctx) cmsg.ctx = CK_CTX_TEARDOWN; upack (buf, (CheckMsg *) &cmsg, &type); - fail_unless (type == CK_MSG_CTX, + ck_assert_msg (type == CK_MSG_CTX, "Bad type unpacked for CtxMsg"); if (cmsg.ctx != CK_CTX_SETUP) { @@ -116,10 +116,10 @@ START_TEST(test_pack_len) cmsg.ctx = CK_CTX_TEST; n = pack (CK_MSG_CTX, &buf, (CheckMsg *) &cmsg); - fail_unless (n > 0, "Return val from pack not set correctly"); + ck_assert_msg (n > 0, "Return val from pack not set correctly"); /* Value below may change with different implementations of pack */ - fail_unless (n == 8, "Return val from pack not correct"); + ck_assert_msg (n == 8, "Return val from pack not correct"); n = 0; n = upack (buf, (CheckMsg *) &cmsg, &type); if (n != 8) { @@ -155,7 +155,7 @@ START_TEST(test_pack_fail_limit) fmsg.msg = (char *) "abc"; upack (buf, (CheckMsg *) &fmsg, &type); free (buf); - fail_unless (strcmp (fmsg.msg, "") == 0, + ck_assert_msg (strcmp (fmsg.msg, "") == 0, "Empty string not handled properly"); free (fmsg.msg); @@ -178,7 +178,7 @@ START_TEST(test_pack_loc_limit) pack (CK_MSG_LOC, &buf, (CheckMsg *) &lmsg); lmsg.file = (char *) "abc"; upack (buf, (CheckMsg *) &lmsg, &type); - fail_unless (strcmp (lmsg.file, "") == 0, + ck_assert_msg (strcmp (lmsg.file, "") == 0, "Empty string not handled properly"); free (lmsg.file); lmsg.file = NULL; @@ -211,19 +211,19 @@ START_TEST(test_ppack) close (filedes[1]); rmsg = punpack (filedes[0]); - fail_unless (rmsg != NULL, + ck_assert_msg (rmsg != NULL, "Return value from ppack should always be malloc'ed"); - fail_unless (rmsg->lastctx == CK_CTX_TEST, + ck_assert_msg (rmsg->lastctx == CK_CTX_TEST, "CTX not set correctly in ppack"); - fail_unless (rmsg->fixture_line == -1, + ck_assert_msg (rmsg->fixture_line == -1, "Default fixture loc not correct"); - fail_unless (rmsg->fixture_file == NULL, + ck_assert_msg (rmsg->fixture_file == NULL, "Default fixture loc not correct"); - fail_unless (rmsg->test_line == 10, + ck_assert_msg (rmsg->test_line == 10, "Test line not received correctly"); - fail_unless (strcmp(rmsg->test_file,"abc123.c") == 0, + ck_assert_msg (strcmp(rmsg->test_file,"abc123.c") == 0, "Test file not received correctly"); - fail_unless (strcmp(rmsg->msg, "oops") == 0, + ck_assert_msg (strcmp(rmsg->msg, "oops") == 0, "Failure message not received correctly"); free(rmsg); @@ -248,7 +248,7 @@ START_TEST(test_ppack_noctx) close (filedes[1]); rmsg = punpack (filedes[0]); - fail_unless (rmsg == NULL, + ck_assert_msg (rmsg == NULL, "Result should be NULL with no CTX"); if (rmsg != NULL) @@ -270,11 +270,11 @@ START_TEST(test_ppack_onlyctx) close (filedes[1]); rmsg = punpack (filedes[0]); - fail_unless (rmsg->msg == NULL, + ck_assert_msg (rmsg->msg == NULL, "Result message should be NULL with only CTX"); - fail_unless (rmsg->fixture_line == -1, + ck_assert_msg (rmsg->fixture_line == -1, "Result loc line should be -1 with only CTX"); - fail_unless (rmsg->test_line == -1, + ck_assert_msg (rmsg->test_line == -1, "Result loc line should be -1 with only CTX"); if (rmsg != NULL) @@ -305,10 +305,10 @@ START_TEST(test_ppack_multictx) close (filedes[1]); rmsg = punpack (filedes[0]); - fail_unless (rmsg->test_line == 5, + ck_assert_msg (rmsg->test_line == 5, "Test loc not being preserved on CTX change"); - fail_unless (rmsg->fixture_line == -1, + ck_assert_msg (rmsg->fixture_line == -1, "Fixture not reset on CTX change"); if (rmsg != NULL) free (rmsg); @@ -333,7 +333,7 @@ START_TEST(test_ppack_nofail) close (filedes[1]); rmsg = punpack (filedes[0]); - fail_unless (rmsg->msg == NULL, + ck_assert_msg (rmsg->msg == NULL, "Failure result should be NULL with no failure message"); if (rmsg != NULL) free (rmsg); @@ -367,15 +367,15 @@ START_TEST(test_ppack_big) close (filedes[1]); rmsg = punpack (filedes[0]); - fail_unless (rmsg != NULL, + ck_assert_msg (rmsg != NULL, "Return value from ppack should always be malloc'ed"); - fail_unless (rmsg->lastctx == CK_CTX_TEST, + ck_assert_msg (rmsg->lastctx == CK_CTX_TEST, "CTX not set correctly in ppack"); - fail_unless (rmsg->test_line == 10, + ck_assert_msg (rmsg->test_line == 10, "Test line not received correctly"); - fail_unless (strcmp (rmsg->test_file, lmsg.file) == 0, + ck_assert_msg (strcmp (rmsg->test_file, lmsg.file) == 0, "Test file not received correctly"); - fail_unless (strcmp (rmsg->msg, fmsg.msg) == 0, + ck_assert_msg (strcmp (rmsg->msg, fmsg.msg) == 0, "Failure message not received correctly"); free (rmsg); diff --git a/tests/check_check_selective.c b/tests/check_check_selective.c index b2f6f76..90a5e43 100644 --- a/tests/check_check_selective.c +++ b/tests/check_check_selective.c @@ -82,7 +82,7 @@ START_TEST(test_srunner_run_run_all) NULL, /* NULL tcase name. */ CK_VERBOSE); - fail_unless (srunner_ntests_run(sr) == 3, + ck_assert_msg (srunner_ntests_run(sr) == 3, "Not all tests were executed."); reset_executed (); @@ -98,7 +98,7 @@ START_TEST(test_srunner_run_suite) NULL, /* NULL tcase name. */ CK_VERBOSE); - fail_unless (test_tc11_executed + ck_assert_msg (test_tc11_executed && test_tc12_executed && !test_tc21_executed, "Expected tests were not executed."); @@ -134,7 +134,7 @@ START_TEST(test_srunner_run_tcase) "tcase12", CK_VERBOSE); - fail_unless (!test_tc11_executed + ck_assert_msg (!test_tc11_executed && test_tc12_executed && !test_tc21_executed, "Expected tests were not executed."); @@ -170,7 +170,7 @@ START_TEST(test_srunner_suite_tcase) "tcase21", CK_VERBOSE); - fail_unless (!test_tc11_executed + ck_assert_msg (!test_tc11_executed && !test_tc12_executed && test_tc21_executed, "Expected tests were not executed."); @@ -205,7 +205,7 @@ START_TEST(test_srunner_run_suite_env) setenv ("CK_RUN_SUITE", "suite1", 1); srunner_run_all (sr, CK_VERBOSE); - fail_unless (test_tc11_executed + ck_assert_msg (test_tc11_executed && test_tc12_executed && !test_tc21_executed, "Expected tests were not executed."); @@ -239,7 +239,7 @@ START_TEST(test_srunner_run_tcase_env) setenv ("CK_RUN_CASE", "tcase12", 1); srunner_run_all (sr, CK_VERBOSE); - fail_unless (!test_tc11_executed + ck_assert_msg (!test_tc11_executed && test_tc12_executed && !test_tc21_executed, "Expected tests were not executed."); @@ -274,7 +274,7 @@ START_TEST(test_srunner_suite_tcase_env) setenv ("CK_RUN_CASE", "tcase21", 1); srunner_run_all (sr, CK_VERBOSE); - fail_unless (!test_tc11_executed + ck_assert_msg (!test_tc11_executed && !test_tc12_executed && test_tc21_executed, "Expected tests were not executed."); diff --git a/tests/check_check_sub.c b/tests/check_check_sub.c index eb9ac47..994bdcb 100644 --- a/tests/check_check_sub.c +++ b/tests/check_check_sub.c @@ -28,8 +28,8 @@ START_TEST(test_mark_lno) END_TEST START_TEST(test_pass) { - fail_unless(1 == 1, "This test should pass"); - fail_unless(9999, "This test should pass"); + ck_assert_msg(1 == 1, "This test should pass"); + ck_assert_msg(9999, "This test should pass"); } END_TEST @@ -406,7 +406,7 @@ START_TEST(test_fork1p_pass) if((pid = fork()) < 0) { ck_abort_msg("Failed to fork new process"); } else if (pid > 0) { - fail_unless(1, NULL); + ck_assert_msg(1, NULL); kill(pid, SIGKILL); } else { for (;;) { @@ -442,7 +442,7 @@ START_TEST(test_fork1c_pass) } else if (pid > 0) { check_waitpid_and_exit(pid); } else { - fail_unless(1, NULL); + ck_assert_msg(1, NULL); check_waitpid_and_exit(0); } } @@ -473,7 +473,7 @@ START_TEST(test_fork2_pass) if((pid2 = check_fork()) < 0) { ck_abort_msg("Failed to fork new process"); } else if (pid2 == 0) { - fail_unless(1, NULL); + ck_assert_msg(1, NULL); check_waitpid_and_exit(0); } check_waitpid_and_exit(pid2); @@ -510,21 +510,21 @@ START_TEST(test_srunner) SRunner *sr; s = suite_create("Check Servant3"); - fail_unless(s != NULL, NULL); + ck_assert_msg(s != NULL, NULL); sr = srunner_create(NULL); - fail_unless(sr != NULL, NULL); + ck_assert_msg(sr != NULL, NULL); srunner_add_suite(sr, s); srunner_free(sr); sr = srunner_create(NULL); - fail_unless(sr != NULL, NULL); + ck_assert_msg(sr != NULL, NULL); srunner_add_suite(sr, NULL); srunner_free(sr); s = suite_create("Check Servant3"); - fail_unless(s != NULL, NULL); + ck_assert_msg(s != NULL, NULL); sr = srunner_create(s); - fail_unless(sr != NULL, NULL); + ck_assert_msg(sr != NULL, NULL); srunner_free(sr); } END_TEST diff --git a/tests/check_list.c b/tests/check_list.c index 1a749ea..821e09c 100644 --- a/tests/check_list.c +++ b/tests/check_list.c @@ -11,18 +11,18 @@ START_TEST(test_create) { List *lp = NULL; - fail_unless (list_val(lp) == NULL, + ck_assert_msg (list_val(lp) == NULL, "Current list value should be NULL for NULL list"); lp = check_list_create(); - fail_unless (list_val(lp) == NULL, + ck_assert_msg (list_val(lp) == NULL, "Current list value should be NULL for newly created list"); - fail_unless (list_at_end(lp), + ck_assert_msg (list_at_end(lp), "Newly created list should be at end"); list_advance(lp); - fail_unless (list_at_end(lp), + ck_assert_msg (list_at_end(lp), "Advancing a list at end should produce a list at end"); list_free (lp); } @@ -45,11 +45,11 @@ START_TEST(test_add_end) list_add_end (lp, tval); - fail_unless (list_val (lp) != NULL, + ck_assert_msg (list_val (lp) != NULL, "List current val should not be null after new insertion"); - fail_unless (!list_at_end (lp), + ck_assert_msg (!list_at_end (lp), "List should be at end after new insertion"); - fail_unless (strcmp(tval, (char *) list_val (lp)) == 0, + ck_assert_msg (strcmp(tval, (char *) list_val (lp)) == 0, "List current val should equal newly inserted val"); list_free (lp); } @@ -62,9 +62,9 @@ START_TEST(test_add_front) list_add_front (lp, tval); - fail_unless (list_val (lp) != NULL, + ck_assert_msg (list_val (lp) != NULL, "List current val should not be null after new insertion"); - fail_unless (strcmp(tval, (char *) list_val (lp)) == 0, + ck_assert_msg (strcmp(tval, (char *) list_val (lp)) == 0, "List current val should equal newly inserted val"); list_free (lp); } @@ -79,15 +79,15 @@ START_TEST(test_add_end_and_next) list_add_end (lp, tval1); list_add_end (lp, tval2); list_front(lp); - fail_unless (strcmp (tval1, list_val (lp)) == 0, + ck_assert_msg (strcmp (tval1, list_val (lp)) == 0, "List head val should equal first inserted val"); list_advance (lp); - fail_unless (!list_at_end (lp), + ck_assert_msg (!list_at_end (lp), "List should not be at end after two adds and one next"); - fail_unless (strcmp (tval2, list_val (lp)) == 0, + ck_assert_msg (strcmp (tval2, list_val (lp)) == 0, "List val should equal second inserted val"); list_advance(lp); - fail_unless (list_at_end (lp), + ck_assert_msg (list_at_end (lp), "List should be at and after two adds and two nexts"); list_free (lp); } @@ -103,15 +103,15 @@ START_TEST(test_add_front_and_next) list_add_front (lp, tval1); list_add_front (lp, tval2); list_front(lp); - fail_unless (strcmp (tval2, list_val (lp)) == 0, + ck_assert_msg (strcmp (tval2, list_val (lp)) == 0, "List head val should equal last inserted val"); list_advance (lp); - fail_unless (!list_at_end (lp), + ck_assert_msg (!list_at_end (lp), "List should not be at end after two adds and one next"); - fail_unless (strcmp (tval1, list_val (lp)) == 0, + ck_assert_msg (strcmp (tval1, list_val (lp)) == 0, "List val should equal first inserted val"); list_advance(lp); - fail_unless (list_at_end (lp), + ck_assert_msg (list_at_end (lp), "List should be at and after two adds and two nexts"); list_free (lp); } diff --git a/tests/check_stress.c b/tests/check_stress.c index 903777e..e35cacd 100644 --- a/tests/check_stress.c +++ b/tests/check_stress.c @@ -14,7 +14,7 @@ SRunner *sr; START_TEST(test_pass) { - fail_unless(1,"Shouldn't see this message"); + ck_assert_msg(1,"Shouldn't see this message"); } END_TEST diff --git a/tests/check_thread_stress.c b/tests/check_thread_stress.c index e5fd95d..37df7d6 100644 --- a/tests/check_thread_stress.c +++ b/tests/check_thread_stress.c @@ -15,7 +15,7 @@ sendinfo (void *userdata CK_ATTRIBUTE_UNUSED) unsigned int i; for (i = 0; i < 999; i++) { - fail_unless (1, "Shouldn't see this message"); + ck_assert_msg (1, "Shouldn't see this message"); } return NULL; } diff --git a/tests/ex_log_output.c b/tests/ex_log_output.c index 0b5df28..5eccdbb 100644 --- a/tests/ex_log_output.c +++ b/tests/ex_log_output.c @@ -7,7 +7,7 @@ START_TEST(test_pass) { - fail_unless (1==1, "Shouldn't see this"); + ck_assert_msg (1==1, "Shouldn't see this"); } END_TEST @@ -25,7 +25,7 @@ END_TEST START_TEST(test_pass2) { - fail_unless (1==1, "Shouldn't see this"); + ck_assert_msg (1==1, "Shouldn't see this"); } END_TEST diff --git a/tests/ex_output.c b/tests/ex_output.c index 2af1f8c..baf961b 100644 --- a/tests/ex_output.c +++ b/tests/ex_output.c @@ -8,7 +8,7 @@ START_TEST(test_pass) { - fail_unless (1==1, "Shouldn't see this"); + ck_assert_msg (1==1, "Shouldn't see this"); } END_TEST diff --git a/tests/ex_xml_output.c b/tests/ex_xml_output.c index 9cc0797..a76e609 100644 --- a/tests/ex_xml_output.c +++ b/tests/ex_xml_output.c @@ -7,7 +7,7 @@ START_TEST(test_pass) { - fail_unless (1==1, "Shouldn't see this"); + ck_assert_msg (1==1, "Shouldn't see this"); } END_TEST @@ -25,13 +25,13 @@ END_TEST START_TEST(test_pass2) { - fail_unless (1==1, "Shouldn't see this"); + ck_assert_msg (1==1, "Shouldn't see this"); } END_TEST START_TEST(test_loop) { - fail_unless (_i==1, "Iteration %d failed", _i); + ck_assert_msg (_i==1, "Iteration %d failed", _i); } END_TEST