3 EasyUnit : Simple C++ Unit testing framework
4 Copyright (C) 2004 Barthelemy Dagenais
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 barthelemy@prologique.com
26 #include "testresult.h"
33 TestCase::TestCase(const SimpleString
& name
, TestResult
*testResult
)
34 : name_(name
), testResult_(testResult
)
42 void TestCase::addTest(Test
*test
)
48 tests_
->setNext(tests_
);
53 tests_
->setNext(tmp
->getNext());
60 Test
* TestCase::getTests() const
65 test
= test
->getNext();
73 Test
*test
= tests_
->getNext();
79 testResult_
->addResult(this);
82 int TestCase::getTestsCount() const
87 int TestCase::getFailuresCount() const
89 return failuresCount_
;
92 int TestCase::getSuccessesCount() const
94 return successesCount_
;
97 int TestCase::getErrorsCount() const
102 bool TestCase::ran() const
107 const SimpleString
& TestCase::getName() const
112 void TestCase::updateCount(Test
*test
)
114 if (test
->getErrorsCount() > 0) {
117 else if (test
->getFailuresCount() > 0) {
125 TestCase
* TestCase::getNext() const
127 return nextTestCase_
;
130 void TestCase::setNext(TestCase
*testCase
)
132 nextTestCase_
= testCase
;
135 void TestCase::runTests(Test
*test
)
138 for (int i
= 0; i
<testsCount_
; i
++) {
143 test
= test
->getNext();
150 void TestCase::runTest(Test
*test
)
157 void TestCase::runTest(Test
*test
)
162 catch (std::exception
&e
) {
163 test
->addTestPartResult(new TestPartResult(test
,"",-1,e
.what(),error
));
166 test
->addTestPartResult(new TestPartResult(test
,"",-1,"Unexpected error occured",error
));