Merge pull request #736 from Smoothieware/development/test-framework
[clinton/Smoothieware.git] / src / testframework / easyunit / testresult.cpp
1 /*
2 EasyUnit : Simple C++ Unit testing framework
3 Copyright (C) 2004 Barthelemy Dagenais
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 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 this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Barthelemy Dagenais
20 barthelemy@prologique.com
21 */
22
23 #include "testresult.h"
24
25
26 TestResult::TestResult()
27 {
28 }
29
30
31 TestResult::~TestResult()
32 {
33 }
34
35 int TestResult::getTotalSuccesses() const
36 {
37 return totalSuccesses_;
38 }
39
40 int TestResult::getTotalErrors() const
41 {
42 return totalErrors_;
43 }
44
45 int TestResult::getTotalFailures() const
46 {
47 return totalFailures_;
48 }
49
50
51 int TestResult::getSuccesses() const
52 {
53 return successes_;
54 }
55
56 int TestResult::getFailures() const
57 {
58 return failures_;
59 }
60
61 int TestResult::getErrors() const
62 {
63 return errors_;
64 }
65
66 int TestResult::getTestCaseCount() const
67 {
68 return testCaseCount_;
69 }
70
71 int TestResult::getTestRanCount() const
72 {
73 return testRanCount_;
74 }
75
76 int TestResult::getTestCaseRanCount() const
77 {
78 return testCaseRanCount_;
79 }
80
81 TestCase* TestResult::getTestCases() const
82 {
83 return testCases_;
84 }
85
86 void TestResult::setTestCases(TestCase *testCases, int testCaseCount)
87 {
88 testCases_ = testCases;
89 testCaseCount_ = testCaseCount;
90 }
91
92 void TestResult::addResult(TestCase *testCase)
93 {
94 int tcSuccesses = testCase->getSuccessesCount();
95 int tcErrors = testCase->getErrorsCount();
96 int tcFailures = testCase->getFailuresCount();
97
98 testCaseRanCount_++;
99
100 totalSuccesses_ += tcSuccesses;
101 totalErrors_ += tcErrors;
102 totalFailures_ += tcFailures;
103 testRanCount_ += testCase->getTestsCount();
104
105 if (tcErrors == 0 && tcFailures == 0) {
106 successes_++;
107 }
108 else if (tcErrors > 0) {
109 errors_++;
110 }
111 else {
112 failures_++;
113 }
114 }
115
116
117