Skip to content

Commit 72c2581

Browse files
committed
Renamed files with + in them to be alphanumeric and baselined to roughly r2 or http://unittestpp.googlecode.com/svn/trunk/
1 parent a3f957c commit 72c2581

34 files changed

+308
-306
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ endif
3737
test_src = src/tests/Main.cpp \
3838
src/tests/TestAssertHandler.cpp \
3939
src/tests/TestChecks.cpp \
40-
src/tests/TestUnitTest++.cpp \
40+
src/tests/TestUnitTestPP.cpp \
4141
src/tests/TestTest.cpp \
4242
src/tests/TestTestResults.cpp \
4343
src/tests/TestTestRunner.cpp \

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ the terms of the License contained in the file COPYING distributed
77
with this package. This license is the same as the MIT/X Consortium
88
license.
99

10-
See src/tests/TestUnitTest++.cpp for usage.
10+
See src/tests/TestUnitTestPP.cpp for usage.
1111

1212
Authors:
1313
Noel Llopis (llopis@convexhull.com)

TestUnitTest++.vsnet2003.vcproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
RelativePath=".\src\tests\TestTimeConstraintMacro.cpp">
164164
</File>
165165
<File
166-
RelativePath=".\src\tests\TestUnitTest++.cpp">
166+
RelativePath=".\src\tests\TestUnitTestPP.cpp">
167167
</File>
168168
<File
169169
RelativePath=".\src\tests\TestXmlTestReporter.cpp">

TestUnitTest++.vsnet2005.vcproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
>
244244
</File>
245245
<File
246-
RelativePath=".\src\tests\TestUnitTest++.cpp"
246+
RelativePath=".\src\tests\TestUnitTestPP.cpp"
247247
>
248248
</File>
249249
<File

TestUnitTestPP_vs6.dsp

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitTest++.vsnet2003.vcproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
RelativePath=".\src\TimeHelpers.h">
213213
</File>
214214
<File
215-
RelativePath=".\src\UnitTest++.h">
215+
RelativePath=".\src\unittestpp.h">
216216
</File>
217217
<File
218218
RelativePath=".\src\XmlTestReporter.cpp">

UnitTest++.vsnet2005.vcproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
>
302302
</File>
303303
<File
304-
RelativePath=".\src\UnitTest++.h"
304+
RelativePath=".\src\unittestpp.h"
305305
>
306306
</File>
307307
<File

UnitTestPP_vs6.dsp

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/UnitTest++.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ <h3>Packaging</h3>
3131
<p>You'll probably want to keep the generated library in a shared space in source control, so you can reuse it for multiple test projects. A redistributable package of UnitTest++ would consist of the generated library file, and all of the header files in <code>UnitTest++/src/</code> and its per-platform subfolders. The <code>tests</code> directory only contains the unit tests for the library, and need not be included.</p>
3232

3333
<h2>Using UnitTest++</h2>
34-
<p>The source code for UnitTest++ comes with a full test suite written <em>using</em> UnitTest++. This is a great place to learn techniques for testing. There is one sample .cpp file: <code>UnitTest++/src/tests/TestUnitTest++.cpp</code>. It covers most of UnitTest++'s features in an easy-to-grasp context, so start there if you want a quick overview of typical usage.</p>
34+
<p>The source code for UnitTest++ comes with a full test suite written <em>using</em> UnitTest++. This is a great place to learn techniques for testing. There is one sample .cpp file: <code>UnitTest++/src/tests/TestUnitTestPP.cpp</code>. It covers most of UnitTest++'s features in an easy-to-grasp context, so start there if you want a quick overview of typical usage.</p>
3535

3636
<h3>Getting started</h3>
3737
<p>Listed below is a minimal C++ program to run a failing test through UnitTest++.</p>
3838

3939
<pre>
4040
// test.cpp
41-
#include &lt;UnitTest++.h&gt;
41+
#include &lt;unittestpp.h&gt;
4242

4343
TEST(FailSpectacularly)
4444
{
@@ -51,7 +51,7 @@ <h3>Getting started</h3>
5151
}
5252
</pre>
5353

54-
<p><code>UnitTest++.h</code> is a facade header for UnitTest++, so including that should get you all features of the library. All classes and free functions are placed in namespace <code>UnitTest</code>, so you need to either qualify their full names (as with <code>RunAllTests()</code> in the example) or add a <code>using namespace UnitTest;</code> statement in your .cpp files. Note that any mention of UnitTest++ functions and classes in this document assume that the <code>UnitTest</code> namespace has been opened.</p>
54+
<p><code>unittestpp.h</code> is a facade header for UnitTest++, so including that should get you all features of the library. All classes and free functions are placed in namespace <code>UnitTest</code>, so you need to either qualify their full names (as with <code>RunAllTests()</code> in the example) or add a <code>using namespace UnitTest;</code> statement in your .cpp files. Note that any mention of UnitTest++ functions and classes in this document assume that the <code>UnitTest</code> namespace has been opened.</p>
5555

5656
<p>Compiling and linking this program with UnitTest++'s static library into an executable, and running it, will produce the following output (details may vary):</p>
5757

src/DeferredTestReporter.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
#include "DeferredTestReporter.h"
2-
#include "TestDetails.h"
3-
4-
using namespace UnitTest;
5-
6-
void DeferredTestReporter::ReportTestStart(TestDetails const& details)
7-
{
8-
m_results.push_back(DeferredTestResult(details.suiteName, details.testName));
9-
}
10-
11-
void DeferredTestReporter::ReportFailure(TestDetails const& details, char const* failure)
12-
{
13-
DeferredTestResult& r = m_results.back();
14-
r.failed = true;
15-
r.failures.push_back(DeferredTestResult::Failure(details.lineNumber, failure));
16-
r.failureFile = details.filename;
17-
}
18-
19-
void DeferredTestReporter::ReportTestFinish(TestDetails const&, float secondsElapsed)
20-
{
21-
DeferredTestResult& r = m_results.back();
22-
r.timeElapsed = secondsElapsed;
23-
}
24-
25-
DeferredTestReporter::DeferredTestResultList& DeferredTestReporter::GetResults()
26-
{
27-
return m_results;
28-
}
1+
#include "DeferredTestReporter.h"
2+
#include "TestDetails.h"
3+
4+
using namespace UnitTest;
5+
6+
void DeferredTestReporter::ReportTestStart(TestDetails const& details)
7+
{
8+
m_results.push_back(DeferredTestResult(details.suiteName, details.testName));
9+
}
10+
11+
void DeferredTestReporter::ReportFailure(TestDetails const& details, char const* failure)
12+
{
13+
DeferredTestResult& r = m_results.back();
14+
r.failed = true;
15+
r.failures.push_back(DeferredTestResult::Failure(details.lineNumber, failure));
16+
r.failureFile = details.filename;
17+
}
18+
19+
void DeferredTestReporter::ReportTestFinish(TestDetails const&, float secondsElapsed)
20+
{
21+
DeferredTestResult& r = m_results.back();
22+
r.timeElapsed = secondsElapsed;
23+
}
24+
25+
DeferredTestReporter::DeferredTestResultList& DeferredTestReporter::GetResults()
26+
{
27+
return m_results;
28+
}

src/DeferredTestResult.cpp

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
#include "DeferredTestResult.h"
2-
#include "Config.h"
3-
4-
namespace UnitTest
5-
{
6-
7-
DeferredTestResult::DeferredTestResult()
8-
: suiteName("")
9-
, testName("")
10-
, failureFile("")
11-
, timeElapsed(0.0f)
12-
, failed(false)
13-
{
14-
}
15-
16-
DeferredTestResult::DeferredTestResult(char const* suite, char const* test)
17-
: suiteName(suite)
18-
, testName(test)
19-
, failureFile("")
20-
, timeElapsed(0.0f)
21-
, failed(false)
22-
{
23-
}
24-
25-
}
1+
#include "DeferredTestResult.h"
2+
#include "Config.h"
3+
4+
namespace UnitTest
5+
{
6+
7+
DeferredTestResult::DeferredTestResult()
8+
: suiteName("")
9+
, testName("")
10+
, failureFile("")
11+
, timeElapsed(0.0f)
12+
, failed(false)
13+
{
14+
}
15+
16+
DeferredTestResult::DeferredTestResult(char const* suite, char const* test)
17+
: suiteName(suite)
18+
, testName(test)
19+
, failureFile("")
20+
, timeElapsed(0.0f)
21+
, failed(false)
22+
{
23+
}
24+
25+
DeferredTestResult::~DeferredTestResult()
26+
{
27+
}
28+
29+
}

src/TestRunner.cpp

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
1-
#include "TestRunner.h"
2-
#include "TestResults.h"
3-
#include "TestReporter.h"
4-
#include "TestReporterStdout.h"
5-
#include "TimeHelpers.h"
6-
#include "MemoryOutStream.h"
7-
8-
#include <cstring>
9-
10-
11-
namespace UnitTest {
12-
13-
int RunAllTests()
14-
{
15-
TestReporterStdout reporter;
16-
TestRunner runner(reporter);
17-
return runner.RunTestsIf(Test::GetTestList(), NULL, True(), 0);
18-
}
19-
20-
21-
TestRunner::TestRunner(TestReporter& reporter)
22-
: m_reporter(&reporter)
23-
, m_result(new TestResults(&reporter))
24-
, m_timer(new Timer)
25-
{
26-
m_timer->Start();
27-
}
28-
29-
TestRunner::~TestRunner()
30-
{
31-
delete m_result;
32-
delete m_timer;
33-
}
34-
35-
int TestRunner::Finish() const
36-
{
37-
float const secondsElapsed = m_timer->GetTimeInMs() / 1000.0f;
38-
m_reporter->ReportSummary(m_result->GetTotalTestCount(),
39-
m_result->GetFailedTestCount(),
40-
m_result->GetFailureCount(),
41-
secondsElapsed);
42-
43-
return m_result->GetFailureCount();
44-
}
45-
46-
bool TestRunner::IsTestInSuite(const Test* const curTest, char const* suiteName) const
47-
{
48-
using namespace std;
49-
return (suiteName == NULL) || !strcmp(curTest->m_details.suiteName, suiteName);
50-
}
51-
52-
void TestRunner::RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const
53-
{
54-
CurrentTest::Results() = result;
55-
56-
Timer testTimer;
57-
testTimer.Start();
58-
59-
result->OnTestStart(curTest->m_details);
60-
61-
curTest->Run();
62-
63-
int const testTimeInMs = testTimer.GetTimeInMs();
64-
if (maxTestTimeInMs > 0 && testTimeInMs > maxTestTimeInMs && !curTest->m_timeConstraintExempt)
65-
{
66-
MemoryOutStream stream;
67-
stream << "Global time constraint failed. Expected under " << maxTestTimeInMs <<
68-
"ms but took " << testTimeInMs << "ms.";
69-
70-
result->OnTestFailure(curTest->m_details, stream.GetText());
71-
}
72-
73-
result->OnTestFinish(curTest->m_details, testTimeInMs/1000.0f);
74-
}
75-
76-
}
1+
#include "TestRunner.h"
2+
#include "TestResults.h"
3+
#include "TestReporter.h"
4+
#include "TestReporterStdout.h"
5+
#include "TimeHelpers.h"
6+
#include "MemoryOutStream.h"
7+
8+
#include <cstring>
9+
10+
11+
namespace UnitTest {
12+
13+
int RunAllTests()
14+
{
15+
TestReporterStdout reporter;
16+
TestRunner runner(reporter);
17+
return runner.RunTestsIf(Test::GetTestList(), NULL, True(), 0);
18+
}
19+
20+
21+
TestRunner::TestRunner(TestReporter& reporter)
22+
: m_reporter(&reporter)
23+
, m_result(new TestResults(&reporter))
24+
, m_timer(new Timer)
25+
{
26+
m_timer->Start();
27+
}
28+
29+
TestRunner::~TestRunner()
30+
{
31+
delete m_result;
32+
delete m_timer;
33+
}
34+
35+
int TestRunner::Finish() const
36+
{
37+
float const secondsElapsed = static_cast<float>(m_timer->GetTimeInMs() / 1000.0);
38+
m_reporter->ReportSummary(m_result->GetTotalTestCount(),
39+
m_result->GetFailedTestCount(),
40+
m_result->GetFailureCount(),
41+
secondsElapsed);
42+
43+
return m_result->GetFailureCount();
44+
}
45+
46+
bool TestRunner::IsTestInSuite(const Test* const curTest, char const* suiteName) const
47+
{
48+
using namespace std;
49+
return (suiteName == NULL) || !strcmp(curTest->m_details.suiteName, suiteName);
50+
}
51+
52+
void TestRunner::RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const
53+
{
54+
CurrentTest::Results() = result;
55+
56+
Timer testTimer;
57+
testTimer.Start();
58+
59+
result->OnTestStart(curTest->m_details);
60+
61+
curTest->Run();
62+
63+
double const testTimeInMs = testTimer.GetTimeInMs();
64+
if (maxTestTimeInMs > 0 && testTimeInMs > maxTestTimeInMs && !curTest->m_timeConstraintExempt)
65+
{
66+
MemoryOutStream stream;
67+
stream << "Global time constraint failed. Expected under " << maxTestTimeInMs <<
68+
"ms but took " << testTimeInMs << "ms.";
69+
70+
result->OnTestFailure(curTest->m_details, stream.GetText());
71+
}
72+
73+
result->OnTestFinish(curTest->m_details, static_cast<float>(testTimeInMs/1000.0));
74+
}
75+
76+
}

0 commit comments

Comments
 (0)