+2004-08-17 hugo303
+
+ * src/check.h.in tests/check_check_master.c tests/check_check_sub.c:
+ Applied fail_if (#709167) patch.
+
2004-08-16 hugo303
* doc/tutorial.sgml: Applied 'newbies' patch #995028 for autoconf doc.
#define fail_unless(expr,msg)\
_fail_unless(expr,__FILE__,__LINE__, msg ? msg : "Assertion '"#expr"' failed")
+/* Fail the test case if expr is true */
+#define fail_if(expr, msg)\
+ _fail_unless(!(expr),__FILE__,__LINE__,msg ?msg :"Assertion '"#expr"' failed")
+
/* Non macro version of #fail_unless, with more complicated interface */
void _fail_unless (int result, const char *file, int line, const char *msg);
START_TEST(test_check_nfailures)
{
- fail_unless (sub_nfailed == 11, "Unexpected number of failures received");
+ fail_unless (sub_nfailed == 12, "Unexpected number of failures received");
}
END_TEST
START_TEST(test_check_ntests_run)
{
- fail_unless (sub_ntests == 12, "Unexpected number of tests run");
+ fail_unless (sub_ntests == 14, "Unexpected number of tests run");
}
END_TEST
"Early exit with return value 1",
/* "Test passed", */
"This test should fail",
+ /* "Test passed", */
+ "This test should fail",
"Assertion '2==3' failed",
"Received signal 11",
"Received signal 8",
-1,
-1,
-1,
+ -1,
-1};
for (i = 0; i < sub_nfailed; i++) {
CK_ERROR,
CK_FAILURE,
CK_FAILURE,
+ CK_FAILURE,
CK_ERROR,
CK_ERROR,
CK_ERROR,
"Simple Tests",
"Simple Tests",
"Simple Tests",
+ "Simple Tests",
+ "Simple Tests",
"Signal Tests",
"Signal Tests",
"Signal Tests",
"Early exit with return value 1",
"Passed",
"This test should fail",
+ "Passed",
+ "This test should fail",
"Assertion '2==3' failed",
"Received signal 11",
"Received signal 8",
CK_ERROR,
CK_PASS,
CK_FAILURE,
+ CK_PASS,
+ CK_FAILURE,
CK_FAILURE,
CK_ERROR,
CK_ERROR,
}
END_TEST
+START_TEST(test_fail_if_pass)
+{
+ fail_if(1==2, "This test should pass");
+ fail_if(0, "This test should pass");
+}
+END_TEST
+
+START_TEST(test_fail_if_fail)
+{
+ fail_if(1==1, "This test should fail");
+}
+END_TEST
+
START_TEST(test_segv)
{
raise (SIGSEGV);
tcase_add_test (tc_simple, test_mark_lno);
tcase_add_test (tc_simple, test_pass);
tcase_add_test (tc_simple, test_fail);
+ tcase_add_test (tc_simple, test_fail_if_pass);
+ tcase_add_test (tc_simple, test_fail_if_fail);
tcase_add_test (tc_simple, test_fail_null_msg);
tcase_add_test (tc_signal, test_segv);
tcase_add_test (tc_signal, test_fpe);