]> granicus.if.org Git - check/commitdiff
Applied ANSI C99 patch (#1047014)
authorhugo303 <hugo303@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Thu, 4 Nov 2004 12:42:51 +0000 (12:42 +0000)
committerhugo303 <hugo303@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Thu, 4 Nov 2004 12:42:51 +0000 (12:42 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@190 64e312b2-a51f-0410-8e61-82d0ca0eb02a

check/ChangeLog
check/src/check.c
check/src/check.h.in
check/tests/check_check_master.c
check/tests/check_check_sub.c

index af5febdf600c835b48f9b679551e7b1bdd26d654..4a8416e89668e8ce7b39be12e892a2aa162d4310 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-04 hugo303
+
+       * src/check.c, src/check.h.in, tests/check_check_master.c,
+       tests/check_check_sub.c: Applied ANSI C99 patch (#1047014)
+
 2004-08-20 hugo303
 
        * doc/tutorial.sgml: Updated with new features.
index 78e29eb0314de53522cc7f580909716d410338f2..be64765334b437cd62cda5fc9df92b6ecdac3569 100644 (file)
@@ -170,17 +170,19 @@ void _mark_point (const char *file, int line)
 }
 
 void _fail_unless (int result, const char *file,
-                   int line, const char * msg, ...)
+                   int line, const char *expr, ...)
 {
-  if (msg == NULL)
-    eprintf ("_fail_unless() called with NULL msg",__FILE__,__LINE__);
-
+  const char *msg;
+    
   send_loc_info (get_send_key(), file, line);
   if (!result) {
     va_list ap;
     char buf[BUFSIZ];
-
-    va_start(ap,msg);
+    
+    va_start(ap,expr);
+    msg = (const char*)va_arg(ap, char *);
+    if (msg == NULL)
+      msg = expr;
     vsnprintf(buf, BUFSIZ, msg, ap);
     va_end(ap);
     send_failure_info (get_send_key(), buf);
index 78ad17abaaeb22152885e5046fa1a83e8624fee9..07c893b077353abb98675972aab250c6efe0ca19 100644 (file)
@@ -155,21 +155,21 @@ static void __testname (void)\
 
 
 /* Fail the test case unless expr is true */
-#define fail_unless(expr, msg, args...)\
+#define fail_unless(expr, ...)\
         _fail_unless(expr, __FILE__, __LINE__,\
-        msg ? msg : "Assertion '"#expr"' failed", ##args)
+        "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL)
 
 /* Fail the test case if expr is true */
-#define fail_if(expr, msg, args...)\
+#define fail_if(expr, ...)\
         _fail_unless(!(expr), __FILE__, __LINE__,\
-        msg ?msg :"Assertion '"#expr"' failed", ##args)
+        "Assertion '"#expr"' failed", ## __VA_ARGS__, NULL)
 
 /* Always fail */
-#define fail(msg, args...) _fail_unless(0, __FILE__, __LINE__, msg, ##args)
+#define fail(...) _fail_unless(0, __FILE__, __LINE__, "Failed" , ## __VA_ARGS__, NULL)
 
 /* Non macro version of #fail_unless, with more complicated interface */
 void _fail_unless (int result, const char *file,
-                   int line, const char *msg, ...);
+                   int line, const char *expr, ...);
 
 /* Mark the last point reached in a unit test
    
index ab65326286f60d7059fa2a30ba57476f3e157af1..bd61acab5bb74d4c7aa96f49ca7858062b77ea4c 100644 (file)
@@ -14,14 +14,14 @@ TestResult **tr_all_array;
 
 START_TEST(test_check_nfailures)
 {
-  fail_unless (sub_nfailed == 16,
+  fail_unless (sub_nfailed == 19,
                "Unexpected number of failures received, %d.", sub_nfailed);
 }
 END_TEST
 
 START_TEST(test_check_ntests_run)
 {
-  fail_unless (sub_ntests == 18,
+  fail_unless (sub_ntests == 21,
                "Unexpected number of tests run, %d.", sub_ntests);
 }
 END_TEST
@@ -37,10 +37,13 @@ START_TEST(test_check_failure_msgs)
     /*    "Test passed", */
     "This test should fail",
     "Assertion '2 == 3' failed",
+    "Assertion '4 == 5' failed",
     "Assertion '2 != 3' failed",
+    "Assertion '4 != 5' failed",
     "3 != 4",
     "5 != 6",
     "7 == 7",
+    "Failed",
     "Received signal 11",
     "Received signal 8",
     "Received signal 8",
@@ -81,6 +84,9 @@ START_TEST(test_check_failure_lnos)
     -1,
     -1,
     -1,
+    -1,
+    -1,
+    -1,
     -1};
   
   for (i = 0; i < sub_nfailed; i++) {
@@ -109,6 +115,9 @@ START_TEST(test_check_failure_ftypes)
     CK_FAILURE,
     CK_FAILURE,
     CK_FAILURE,
+    CK_FAILURE,
+    CK_FAILURE,
+    CK_FAILURE,
     CK_ERROR,
     CK_ERROR,
     CK_ERROR,
@@ -150,6 +159,9 @@ START_TEST(test_check_failure_tcnames)
     "Simple Tests",
     "Simple Tests",
     "Simple Tests",
+    "Simple Tests",
+    "Simple Tests",
+    "Simple Tests",
     "Signal Tests",
     "Signal Tests",
     "Signal Tests",
@@ -183,10 +195,13 @@ START_TEST(test_check_all_msgs)
     "Passed",
     "This test should fail",
     "Assertion '2 == 3' failed",
+    "Assertion '4 == 5' failed",
     "Assertion '2 != 3' failed",
+    "Assertion '4 != 5' failed",
     "3 != 4",
     "5 != 6",
     "7 == 7",
+    "Failed",
     "Received signal 11",
     "Received signal 8",
     "Received signal 8",
@@ -223,6 +238,9 @@ START_TEST(test_check_all_ftypes)
     CK_FAILURE,
     CK_FAILURE,
     CK_FAILURE,
+    CK_FAILURE,
+    CK_FAILURE,    
+    CK_FAILURE,
     CK_ERROR,
     CK_ERROR,
     CK_ERROR,
index 8c82e7df7310012e64c4c8183e5b026d9961985f..1ec9058fac467778078c476993aac7de3a026279 100644 (file)
@@ -48,12 +48,26 @@ START_TEST(test_fail_null_msg)
 }
 END_TEST
 
+
+START_TEST(test_fail_no_msg)
+{
+  fail_unless(4 == 5);
+}
+END_TEST
+
 START_TEST(test_fail_if_null_msg)
 {
   fail_if(2 != 3, NULL);
 }
 END_TEST
 
+
+START_TEST(test_fail_if_no_msg)
+{
+  fail_if(4 != 5);
+}
+END_TEST
+
 START_TEST(test_fail_vararg_msg_1)
 {
   int x = 3;
@@ -78,6 +92,12 @@ START_TEST(test_fail_vararg_msg_3)
 }
 END_TEST
 
+START_TEST(test_fail_empty)
+{
+  fail();
+}
+END_TEST
+
 START_TEST(test_segv)
 {
   raise (SIGSEGV);
@@ -170,10 +190,13 @@ Suite *make_sub_suite(void)
   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_simple, test_fail_no_msg);
   tcase_add_test (tc_simple, test_fail_if_null_msg);
+  tcase_add_test (tc_simple, test_fail_if_no_msg);
   tcase_add_test (tc_simple, test_fail_vararg_msg_1);
   tcase_add_test (tc_simple, test_fail_vararg_msg_2);
   tcase_add_test (tc_simple, test_fail_vararg_msg_3);
+  tcase_add_test (tc_simple, test_fail_empty);
   tcase_add_test (tc_signal, test_segv);
   tcase_add_test (tc_signal, test_fpe);
   tcase_add_test (tc_signal, test_mark_point);