OSDN Git Service

(no commit message)
[ccunit/ccunit.git] / src / ccunit / CCUnitTestResult.h
1 /* -*- mode: C; -*- */
2 /* Copyright (C) 2003 TSUTSUMI Kikuo.
3    This file is part of the CCUnit Library.
4
5    The CCUnit Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public License
7    as published by the Free Software Foundation; either version 2.1 of
8    the License, or (at your option) any later version.
9
10    The CCUnit Library is distributed in the hope that it will be
11    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the CCUnit Library; see the file COPYING.LESSER.
17    If not, write to the Free Software Foundation, Inc., 59 Temple
18    Place - Suite 330, Boston, MA 02111-1307, USA.  
19 */
20
21 /*
22  * $Id$
23  */
24 #ifndef CCUNITTESTRESULT_H
25 #define CCUNITTESTRESULT_H
26
27 #include <ccunit/CCUnitConfig.h>
28 #include <ccunit/CCUnitList.h>
29 #include <ccunit/CCUnitFailure.h>
30 #include <ccunit/CCUnitTestListener.h>
31 #include <ccunit/CCUnitTestCase.h>
32
33 /**
34  * collects the results of a test case.
35  *
36  * @see CCUnitTest
37  */
38 typedef struct CCUnitTestResult
39 {
40   CCUnitList failures;                          /**< failure objects */
41   CCUnitList listeners;                         /**< testCase objects  */
42   size_t runCount;                              /**< number of run test */
43   bool shouldStop;                              /**< test run should stop flag */
44 } CCUnitTestResult;
45
46 /** Construct TestResult */
47 extern CCUnitTestResult* ccunit_newTestResult ();
48
49 /** Destruct TestResult */
50 extern void ccunit_deleteTestResult (CCUnitTestResult* result);
51
52 /**
53  * Adds a failure to the list of failures. The passed in failed
54  * assertion caused the failure.
55  */
56 extern void ccunit_addFailure (CCUnitTestResult* result,
57                                struct CCUnitFailure* failure);
58
59 /**
60  * Registers a TestRunner as TestListener.
61  */
62 extern inline void ccunit_addResultListener (CCUnitTestResult* result,
63                                              CCUnitTestListener* listener);
64
65 /**
66  * Runs a TestCase.
67  *
68  * @param testCase test case to be run.
69  */
70 extern void ccunit_runResult (CCUnitTestResult* result,
71                               struct CCUnitTestCase* testCase);
72
73 /**
74  * Returns an Iterator for the failures.
75  */
76 extern inline CCUnitListIterator* ccunit_failures(CCUnitTestResult* result);
77
78 /**
79  * Gets the number of detected failures.
80  */
81 extern inline size_t ccunit_failureCount (CCUnitTestResult* result);
82
83 /**
84  * Returns whether the entire test was successful or not.
85  */
86 extern inline bool ccunit_wasSuccessful (CCUnitTestResult* result);
87
88 /**
89  * Gets the number of run tests.
90  */
91 extern inline size_t ccunit_runCount (CCUnitTestResult* result);
92
93 #endif