OSDN Git Service

add object assert macro
authortsntsumi <tsntsumi@users.sourceforge.jp>
Sun, 5 Oct 2003 09:56:41 +0000 (09:56 +0000)
committertsntsumi <tsntsumi@users.sourceforge.jp>
Sun, 5 Oct 2003 09:56:41 +0000 (09:56 +0000)
src/ccunit/CCUnitAssert.h

index 8d2c7e4..865efcc 100644 (file)
@@ -99,6 +99,7 @@ typedef unsigned long long u_quad_t;
 
 typedef const char* _ccunit_str_t;             /**< string type */
 typedef const void* _ccunit_ptr_t;             /**< pointer type */
+typedef const void* _ccunit_obj_t;             /**< object type */
 
 /**
  * @name Declare assert test types
@@ -134,6 +135,14 @@ DCL_CCUNIT_ASSERT_TEST_TYPE(quad_t);
 DCL_CCUNIT_ASSERT_TEST_TYPE(u_quad_t);
 #endif
 
+typedef char* (*ccunit_toString_t)(_ccunit_obj_t);
+
+extern void ccunit_assert_test__ccunit_obj_t (const char* file, unsigned int line,
+                                             bool cond, const char* condstr,
+                                             _ccunit_obj_t expect,
+                                             _ccunit_obj_t acutal,
+                                             ccunit_toString_t);
+
 /** @} */
 
 /**
@@ -242,6 +251,16 @@ DCL_CCUNIT_ASSERT_TEST_TYPE(u_quad_t);
                                      ex, ac);                          \
   } while (0)
 
+#define CCUNIT_ASSERT_TEST_OBJ(EXPECT, OP, ACTUAL, TOSTR)              \
+  do {                                                                 \
+    const _ccunit_obj_t ex = (EXPECT);                                 \
+    const _ccunit_obj_t ac = (ACTUAL);                                 \
+    const char* condstr = #OP " (" #EXPECT ", " #ACTUAL ")";           \
+    ccunit_assert_test__ccunit_obj_t (__FILE__, __LINE__,              \
+                                     OP(ex, ac), condstr, ex, ac,      \
+                                     (ccunit_toString_t)TOSTR);        \
+  } while (0)
+
 /** @} */
 
 /**