OSDN Git Service

Cange Test class to interface
authortsutsumi <>
Tue, 9 Sep 2003 12:41:11 +0000 (12:41 +0000)
committertsutsumi <>
Tue, 9 Sep 2003 12:41:11 +0000 (12:41 +0000)
src/ccunit/CCUnitTest.c
src/ccunit/CCUnitTest.h

index 39f6c36..344481e 100755 (executable)
 
 struct CCUnitTestResult;
 
-static void neverrun (CCUnitTest* test, CCUnitTestResult* result)
+CCUnitTest* ccunit_initTest (CCUnitTest* test,
+                            CCUnitTestType_t type,
+                            ccunit_runtest_func_t run,
+                            ccunit_testdtor_t dtor)
 {
-  assert (false);
-}
-
-static void destroy (CCUnitTest* test)
-{
-  safe_free ((char*)test->name);
-}
-
-CCUnitTest* ccunit_initTest (CCUnitTest* test, const char* name)
-{
-  test->type = ccunitTypeTest;
-  test->name = safe_strdup (name);
-  test->run = neverrun;
-  test->dtor_ = destroy;
+  test->type = type;
+  test->run = run;
+  test->dtor = dtor;
   return test;
 }
 
@@ -55,6 +47,7 @@ void ccunit_deleteTest (CCUnitTest* dt)
 {
   if (!dt)
     return;
-  dt->dtor_ (dt);
+  if (dt->dtor)
+    dt->dtor (dt);
   free (dt);
 }
index 9c7cb97..f50de0b 100755 (executable)
@@ -64,25 +64,29 @@ typedef void (*ccunit_runtest_func_t) (CCUnitTest* test,
 typedef void (*ccunit_testdtor_t) (CCUnitTest* dt);
 
 /**
- * run Test and collect its results.
+ * Run Test and collect its results.
  *
  * @see CCUnitTestResult
  */
 struct CCUnitTest
 {
-  CCUnitTestType_t type;                       /**< test class */
-  const char* name;                            /**< test name  */
+  CCUnitTestType_t type;                       /**< test class type */
   ccunit_runtest_func_t run;                   /**< test run method */
-  ccunit_testdtor_t dtor_;                     /**< test object destructor */
+  ccunit_testdtor_t dtor                     /**< test object destructor */
 };
 
 /**
  * Initialize Test class.
  * @param test test object to initialize.
- * @param name test name.
+ * @param type test type.
+ * @param run run test function.
+ * @param dtor destructor.
  * @return initialized test object.
  */
-extern CCUnitTest* ccunit_initTest (CCUnitTest* test, const char* name);
+extern CCUnitTest* ccunit_initTest (CCUnitTest* test,
+                                   CCUnitTestType_t type,
+                                   ccunit_runtest_func_t run,
+                                   ccunit_testdtor_t dtor);
 
 /**
  * Test class destructor.