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;
}
{
if (!dt)
return;
- dt->dtor_ (dt);
+ if (dt->dtor)
+ dt->dtor (dt);
free (dt);
}
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.