OSDN Git Service

rename CCUnitTestCase to CCUnitTestFunc
authortsutsumi <>
Fri, 20 Aug 2010 07:33:36 +0000 (07:33 +0000)
committertsutsumi <>
Fri, 20 Aug 2010 07:33:36 +0000 (07:33 +0000)
src/ccunit/CCUnitTestFunc.c [new file with mode: 0755]
src/ccunit/CCUnitTestFunc.h [new file with mode: 0755]
src/ccunit/Makefile.am

diff --git a/src/ccunit/CCUnitTestFunc.c b/src/ccunit/CCUnitTestFunc.c
new file mode 100755 (executable)
index 0000000..99b7f6d
--- /dev/null
@@ -0,0 +1,56 @@
+/* Copyright (C) 2003, 2010 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+/**@file
+ * TestFunc module implementation.
+ */
+
+#include <ccunit/CCUnitTestFunc.h>
+
+/**
+ * @addtogroup CCUnitTestFunc
+ * @{
+ */
+
+CCUnitTestFunc* ccunit_newTestFunc (const char* name,
+                                   const char* desc,
+                                   void (*runTest)())
+{
+  CCUnitTestFunc* f = calloc (1, sizeof (*f));
+  if (!f)
+    return NULL;
+  f->name = safe_strdup (name);
+  f->desc = !desc ? safe_strdup (name) : strdup (desc);
+  f->runTest = runTest;
+  return f;
+}
+
+void ccunit_deleteTestFunc (CCUnitTestFunc* f)
+{
+  if (!f)
+    return;
+  safe_free (f->name);
+  safe_free (f->desc);
+  free (f);
+}
+
+/** @} */
diff --git a/src/ccunit/CCUnitTestFunc.h b/src/ccunit/CCUnitTestFunc.h
new file mode 100755 (executable)
index 0000000..d061608
--- /dev/null
@@ -0,0 +1,123 @@
+/* -*- mode: C; -*- */
+/* Copyright (C) 2003, 2010 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+/** @file
+ * TestCase function module.
+ */
+
+#ifndef CCUNITTESTFUNC_H
+#define CCUNITTESTFUNC_H
+
+#include <ccunit/CCUnitConfig.h>
+
+/**
+ * @ingroup CCUnitTestCase
+ * @defgroup CCUnitTestFunc TestFunc
+ *
+ * A single test object.
+ *
+ * This class is used to implement a simple test func.
+ *
+ * @{
+ */
+
+/**
+ * A single test function object.
+ *
+ * For each test implement a function which interacts with the
+ * case. Verify the expected results with assertions specified by
+ * calling CCUNIT_ASSERT on the expression you want to test:
+ * 
+ * @code
+ * void testAdd ()
+ * {
+ *   int result = value1 + value2;
+ *   CCUNIT_ASSERT (result == 5);
+ * }
+ *
+ * ...
+ * int main ()
+ * {
+ *   CCUnitTestResult* r;
+ *   CCUnitTestCase* c = ccunit_newTestCase ("math test");
+ *   CCUnitTestFunc* f = ccunit_newTestFunc ("testAdd", "add test", testAdd);
+ *   ccunit_addTestFunc (c, f);
+ *   r = ccunit_runTestCase (c);
+ *   return 0;
+ * }
+ * @endcode
+ *
+ * @see CCUnitTestCase, CCUnitTestSuite, CCUnitMakeSuite
+ * 
+ * @ingroup WritingTestCase
+ */
+typedef struct CCUnitTestFunc
+{
+  const char* name;                            /**< test func name */
+  const char* desc;                            /**< test description */
+  void (*runTest) ();                          /**< run test function */
+} CCUnitTestFunc;
+
+/**
+ * Create new test function.
+ * @param name function name.
+ * @param desc function description.
+ * @param runTest run test function.
+ * @return new test function object.
+ * @ingroup WritingTestCase
+ */
+extern CCUnitTestFunc* ccunit_newTestFunc (const char* name,
+                                          const char* desc,
+                                          void (*runTest)());
+
+/**
+ * Create new test function.
+ * @param name func name.
+ * @param desc func description.
+ * @param func run test function.
+ * @return new test func.
+ * @ingroup WritingTestCase
+ */
+extern inline CCUnitTestFunc* ccunit_newTestFunc (const char* name,
+                                                 const char* desc,
+                                                 void (*func)());
+#define CCUNIT_NEWTESTFUNC(FUNC) ccunit_newTestFunc (#FUNC, NULL, FUNC)
+
+/**
+ * Delete test function.
+ * @param f deleting function.
+ * @ingroup WritingTestCase
+ */
+extern void ccunit_deleteTestFunc (CCUnitTestFunc* f);
+
+/**
+ * Delete test function.
+ * @param f deleting function.
+ * @ingroup WritingTestCase
+ */
+extern inline void ccunit_deleteTestFunc (CCUnitTestFunc* f);
+
+/** @} */
+
+#endif /* !CCUNITTESTFUNC_H */
index c3ee51c..36051aa 100755 (executable)
@@ -1,5 +1,5 @@
 ## Process this file with automake to produce Makefile.in
-##   Copyright (C) 2003 TSUTSUMI Kikuo.
+##   Copyright (C) 2003, 2010 TSUTSUMI Kikuo.
 ##   This file is part of the CCUnit Library.
 ##
 ##   The CCUnit Library is free software; you can redistribute it and/or
@@ -41,8 +41,8 @@ libccunit_la_SOURCES = \
        CCUnitTestCase.h \
        CCUnitTestFailure.c \
        CCUnitTestFailure.h \
-       CCUnitTestFixture.c \
-       CCUnitTestFixture.h \
+       CCUnitTestFunc.c \
+       CCUnitTestFunc.h \
        CCUnitTestListener.h \
        CCUnitTestResult.c \
        CCUnitTestResult.h \