OSDN Git Service

Changed to use a global variable though delivered a pointer to the second argument...
authortsutsumi <>
Sat, 14 Aug 2010 09:22:18 +0000 (09:22 +0000)
committertsutsumi <>
Sat, 14 Aug 2010 09:22:18 +0000 (09:22 +0000)
src/ccunit/CCUnitAssert.c

index 8ddbb3f..46eab3c 100644 (file)
  */
 
 extern jmp_buf _ccunit_runTest_env;
+extern CCUnitTestFailure* _ccunit_testFailure;
 
 void ccunit_assert (const char* file, unsigned int line,
                    bool cond, const char* condstr)
 {
-  CCUnitTestFailure* f;
   if (cond)
     return;
-  f = ccunit_newTestFailure (file, line, condstr, NULL, NULL);
-  longjmp (_ccunit_runTest_env, (int)f);
+  _ccunit_testFailure = ccunit_newTestFailure (file, line, condstr, NULL, NULL);
+  longjmp (_ccunit_runTest_env, 1);
 }
 
 /**
@@ -156,12 +156,11 @@ DEF_VALUE_TO_STRING(_ccunit_ptr_t, 24);
       {                                                                        \
        const char* ex = TYP ## _to_string (expect);                    \
        const char* ac = TYP ## _to_string (actual);                    \
-       CCUnitTestFailure* f;                                           \
-       f = ccunit_newTestFailure (file, line, condstr, ex, ac);        \
-       safe_free ((char*)ex);                                          \
-       safe_free ((char*)ac);                                          \
-       assert (f != NULL);                                             \
-       longjmp (_ccunit_runTest_env, (int)f);                          \
+       _ccunit_testFailure = ccunit_newTestFailure (file, line, condstr, ex, ac); \
+       safe_free (ex);                                                 \
+       safe_free (ac);                                                 \
+       assert (_ccunit_testFailure != NULL);                           \
+       longjmp (_ccunit_runTest_env, 1);                               \
       }                                                                        \
   }
 
@@ -181,12 +180,11 @@ void ccunit_assert_test__ccunit_obj_t (const char* file,
                  : to_string (expect));
       char* ac = (!to_string ? _ccunit_ptr_t_to_string (actual)
                  : to_string (actual));
-      CCUnitTestFailure* f;
-      f = ccunit_newTestFailure (file, line, condstr, ex, ac);
+      _ccunit_testFailure = ccunit_newTestFailure (file, line, condstr, ex, ac);
       safe_free (ex);
       safe_free (ac);
-      assert (f != NULL);
-      longjmp (_ccunit_runTest_env, (int)f);
+      assert (_ccunit_testFailure != NULL);
+      longjmp (_ccunit_runTest_env, 1);
     }
 }