• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cpputest / cpputest / 3845444899

pending completion
3845444899

Pull #1738

github

GitHub
Merge 3cd307953 into fd25857ee
Pull Request #1738: Ensure that exception specifications match for delete overloads

6744 of 6790 relevant lines covered (99.32%)

18892.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.87
/src/CppUTest/TestTestingFixture.cpp
1
/*
2
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *     * Redistributions of source code must retain the above copyright
8
 *       notice, this list of conditions and the following disclaimer.
9
 *     * Redistributions in binary form must reproduce the above copyright
10
 *       notice, this list of conditions and the following disclaimer in the
11
 *       documentation and/or other materials provided with the distribution.
12
 *     * Neither the name of the <organization> nor the
13
 *       names of its contributors may be used to endorse or promote products
14
 *       derived from this software without specific prior written permission.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
17
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
20
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27

28
#include "CppUTest/TestHarness.h"
29
#include "CppUTest/TestTestingFixture.h"
30

31
bool TestTestingFixture::lineOfCodeExecutedAfterCheck = false;
32

33
TestTestingFixture::TestTestingFixture()
329✔
34
{
35
    output_ = new StringBufferTestOutput();
329✔
36
    result_ = new TestResult(*output_);
329✔
37
    genTest_ = new ExecFunctionTestShell();
329✔
38
    registry_ = new TestRegistry();
329✔
39
    ownsExecFunction_ = false;
329✔
40

41
    registry_->setCurrentRegistry(registry_);
329✔
42
    registry_->addTest(genTest_);
329✔
43

44
    lineOfCodeExecutedAfterCheck = false;
329✔
45
}
329✔
46

47
void TestTestingFixture::flushOutputAndResetResult()
2✔
48
{
49
     output_->flush();
2✔
50
     delete result_;
2✔
51
     result_ = new TestResult(*output_);
2✔
52
}
2✔
53

54
TestTestingFixture::~TestTestingFixture()
394✔
55
{
56
    registry_->setCurrentRegistry(NULLPTR);
328✔
57
    clearExecFunction();
328✔
58
    delete registry_;
328✔
59
    delete result_;
328✔
60
    delete output_;
328✔
61
    delete genTest_;
328✔
62
}
394✔
63

64
void TestTestingFixture::clearExecFunction()
554✔
65
{
66
    if (genTest_->testFunction_ && ownsExecFunction_)
554✔
67
        delete genTest_->testFunction_;
174✔
68
}
554✔
69

70
void TestTestingFixture::addTest(UtestShell * test)
19✔
71
{
72
    registry_->addTest(test);
19✔
73
}
19✔
74

75
void TestTestingFixture::setTestFunction(void(*testFunction)())
175✔
76
{
77
    clearExecFunction();
175✔
78

79
    genTest_->testFunction_ = new ExecFunctionWithoutParameters(testFunction);
175✔
80
    ownsExecFunction_ = true;
175✔
81
}
175✔
82

83
void TestTestingFixture::setTestFunction(ExecFunction* testFunction)
51✔
84
{
85
    clearExecFunction();
51✔
86

87
    genTest_->testFunction_ = testFunction;
51✔
88

89
    ownsExecFunction_ = false;
51✔
90
}
51✔
91

92
void TestTestingFixture::setSetup(void(*setupFunction)())
2✔
93
{
94
    genTest_->setup_ = setupFunction;
2✔
95
}
2✔
96

97
void TestTestingFixture::setTeardown(void(*teardownFunction)())
3✔
98
{
99
    genTest_->teardown_ = teardownFunction;
3✔
100
}
3✔
101

102
void TestTestingFixture::installPlugin(TestPlugin* plugin)
14✔
103
{
104
    registry_->installPlugin(plugin);
14✔
105
}
14✔
106

107
void TestTestingFixture::setRunTestsInSeperateProcess()
11✔
108
{
109
    registry_->setRunTestsInSeperateProcess();
11✔
110
}
11✔
111

112
void TestTestingFixture::setOutputVerbose()
1✔
113
{
114
    output_->verbose(TestOutput::level_verbose);
1✔
115
}
1✔
116

117
void TestTestingFixture::runTestWithMethod(void(*method)())
90✔
118
{
119
    setTestFunction(method);
90✔
120
    runAllTests();
90✔
121
}
89✔
122

123
void TestTestingFixture::runAllTests()
210✔
124
{
125
    registry_->runAllTests(*result_);
210✔
126
}
207✔
127

128
size_t TestTestingFixture::getFailureCount()
191✔
129
{
130
    return result_->getFailureCount();
191✔
131
}
132

133
size_t TestTestingFixture::getCheckCount()
9✔
134
{
135
    return result_->getCheckCount();
9✔
136
}
137

138
size_t TestTestingFixture::getTestCount()
1✔
139
{
140
    return result_->getTestCount();
1✔
141
}
142

143
size_t TestTestingFixture::getIgnoreCount()
4✔
144
{
145
    return result_->getIgnoredCount();
4✔
146
}
147

148
TestRegistry* TestTestingFixture::getRegistry()
29✔
149
{
150
    return registry_;
29✔
151
}
152

153
bool TestTestingFixture::hasTestFailed()
1✔
154
{
155
    return genTest_->hasFailed();
1✔
156
}
157

158
void TestTestingFixture::assertPrintContains(const SimpleString& contains)
141✔
159
{
160
    STRCMP_CONTAINS(contains.asCharString(), getOutput().asCharString());
141✔
161
}
141✔
162

163
void TestTestingFixture::assertPrintContainsNot(const SimpleString& contains)
2✔
164
{
165
    CHECK(! getOutput().contains(contains));
2✔
166
}
2✔
167

168

169
const SimpleString& TestTestingFixture::getOutput()
146✔
170
{
171
    return output_->getOutput();
146✔
172
}
173

174
size_t TestTestingFixture::getRunCount()
3✔
175
{
176
          return result_->getRunCount();
3✔
177
}
178

179
void TestTestingFixture::lineExecutedAfterCheck()
1✔
180
{
181
    lineOfCodeExecutedAfterCheck = true;
1✔
182
}
1✔
183

184
void TestTestingFixture::checkTestFailsWithProperTestLocation(const char* text, const char* file, size_t line)
160✔
185
{
186
    if (getFailureCount() != 1)
160✔
187
      FAIL_LOCATION(StringFromFormat("Expected one test failure, but got %d amount of test failures", (int) getFailureCount()).asCharString(), file, line);
×
188

189
    STRCMP_CONTAINS_LOCATION(text, output_->getOutput().asCharString(), "", file, line);
160✔
190

191
    if (lineOfCodeExecutedAfterCheck)
160✔
192
      FAIL_LOCATION("The test should jump/throw on failure and not execute the next line. However, the next line was executed.", file, line);
×
193
}
160✔
194

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc