OSDN Git Service

add allocate error check
[ccunit/ccunit.git] / src / ccunit / CCUnitTestCase.c
1 /* Copyright (C) 2003 TSUTSUMI Kikuo.
2    This file is part of the CCUnit Library.
3
4    The CCUnit Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public License
6    as published by the Free Software Foundation; either version 2.1 of
7    the License, or (at your option) any later version.
8
9    The CCUnit Library is distributed in the hope that it will be
10    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the CCUnit Library; see the file COPYING.LESSER.
16    If not, write to the Free Software Foundation, Inc., 59 Temple
17    Place - Suite 330, Boston, MA 02111-1307, USA.  
18 */
19
20 /*
21  * $Id$
22  */
23 /**@file
24  * TestCase module implementation.
25  */
26
27 #include <CCUnit/CCUnitTestCase.h>
28
29 /**
30  * @addtogroup CCUnitTestCase
31  * @{
32  */
33
34 CCUnitTestCase* ccunit_newTestCase (const char* name,
35                                     const char* desc,
36                                     void (*runTest)())
37 {
38   CCUnitTestCase* testCase = calloc (1, sizeof (*testCase));
39   if (!testCase)
40     return NULL;
41   testCase->name = safe_strdup (name);
42   testCase->desc = !desc ? safe_strdup (name) : strdup (desc);
43   testCase->runTest = runTest;
44   return testCase;
45 }
46
47 void ccunit_deleteTestCase (CCUnitTestCase* testCase)
48 {
49   if (!testCase)
50     return;
51   safe_free ((char*)testCase->name);
52   safe_free ((char*)testCase->desc);
53   free (testCase);
54 }
55
56 /** @} */