Skip to content

Required macro as for loop (with issues fixed) #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 104 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
0e14178
Merge pull request #1 from paleozogt/master
Nov 15, 2012
1420866
Closes #2
pjohnmeyer Jan 26, 2013
7985b39
Merged googlecode branch, closes #3
pjohnmeyer Jan 26, 2013
dca2b86
Setting up an initial .gitattributes to start dealing with line endings
pjohnmeyer Jan 26, 2013
b982592
Fix inadvertent 'crlt' for .vcxproj
pjohnmeyer Jan 26, 2013
4108d5e
Normalized line endings
pjohnmeyer Feb 1, 2013
df208ee
Compare char* with char* to fix OS X build with clang.
Jan 28, 2013
33e90e6
CHECK_EQUAL no longer crashes if string pointers are NULL.
pjohnmeyer Feb 3, 2013
3a5205f
Added test verifying that UNITTEST_TIME_CONSTRAINT works in TEST_FIXT…
pjohnmeyer Feb 3, 2013
79172d0
Refactored SlowTestWithTimeExemptionPass into two tests, defined in t…
pjohnmeyer Feb 3, 2013
0f5e457
Merge pull request #25 from pjohnmeyer/fixCheckEqualExplodesIfNull
pjohnmeyer Feb 3, 2013
8faa479
Merge pull request #26 from pjohnmeyer/fixUnitTestTimeConstraintExemp…
pjohnmeyer Feb 6, 2013
1c714a4
Changed all parameters to TestReporterStdout::ReportSummary to be con…
pjohnmeyer Feb 6, 2013
a695db5
Merge pull request #27 from pjohnmeyer/declarationDefinitionMismatch
pjohnmeyer Feb 6, 2013
4c366ee
Changed sprintf to snprintf in MemoryOutStream::FormatToStream. Remov…
pjohnmeyer Feb 6, 2013
e6c9311
Merge pull request #28 from pjohnmeyer/fixCheckEqualCrashForLargeNumbers
pjohnmeyer Feb 9, 2013
3f5d9bd
Converted integral stream testing to min/max/mid style. Added hard-co…
pjohnmeyer Feb 9, 2013
d598bdd
Merge pull request #29 from pjohnmeyer/removeSizeDependenciesFromTest…
pjohnmeyer Feb 9, 2013
18a9a2f
Fixes compile error with MSC.
rioki Feb 15, 2013
4266528
Adds Visual Studio 2010 project files.
rioki Feb 15, 2013
426d749
Adds .gitignore.
rioki Feb 15, 2013
dff0c44
Merge pull request #31 from rioki/master
pjohnmeyer Feb 16, 2013
af145fb
Add .what() to error message when standard exception is raised in CHECK.
pjohnmeyer Feb 17, 2013
09e6ef7
Add .what() to error message when standard exception is raised in CHE…
pjohnmeyer Feb 17, 2013
c622c65
Add .what() to error message when standard exception is raised in CHE…
pjohnmeyer Feb 17, 2013
bad0e9c
Refactor common logic for CHECK tests into a fixture and add separate…
pjohnmeyer Feb 17, 2013
a94b9a8
Improve CheckFixture method names.
pjohnmeyer Feb 18, 2013
76766c1
Refactor TestExceptions CheckEqual tests to use a fixture and add add…
pjohnmeyer Feb 18, 2013
8e7ed23
Refactor TestExceptions CheckClose tests to use a fixture and add add…
pjohnmeyer Feb 18, 2013
2dadab1
Add .what() to error reporting for std::exceptions in CHECK_ARRAY_CLOSE.
pjohnmeyer Feb 18, 2013
6ea94ee
Add .what() to error reporting for std::exceptions in CHECK_ARRAY_EQUAL.
pjohnmeyer Feb 20, 2013
7a3dcad
Add .what() to error reporting for std::exceptions in CHECK_ARRAY2D_C…
pjohnmeyer Feb 20, 2013
e87a1f3
Group all exception tests into suites and normalize indentation.
pjohnmeyer Feb 20, 2013
0f9b667
Merge pull request #33 from pjohnmeyer/addingWhatToCheckMessages
pjohnmeyer Feb 20, 2013
83a9d97
Change default MemoryOutStream to be a std::ostringstream.
pjohnmeyer Feb 20, 2013
1fa77e1
Add install targets and install path customization.
pjohnmeyer Feb 20, 2013
d1be00a
Revert "Add install targets and install path customization."
pjohnmeyer Feb 20, 2013
a527c4a
Add install targets and install path customization.
pjohnmeyer Feb 20, 2013
d9b212b
Move unittestpp.h to src/UnitTestPP.h and add src/UnitTest++.h.
pjohnmeyer Feb 20, 2013
afa6d87
Move config.h to src/Config.h.
pjohnmeyer Feb 20, 2013
c77b187
Ensure all headers, including platform, are being installed.
pjohnmeyer Feb 20, 2013
d847324
Move src to UnitTest++ and move src/tests to tests.
pjohnmeyer Feb 20, 2013
8879b8c
Rename COPYING to LICENSE; delete NEWS since it was empty anyway.
pjohnmeyer Feb 21, 2013
1daf030
Delete COPYING (previously renamed to LICENSE).
pjohnmeyer Feb 21, 2013
0f3df6f
Rename README to README.md
pjohnmeyer Feb 21, 2013
8bcd6f8
Add Markdown formatting to README.md
pjohnmeyer Feb 21, 2013
3bfb8b6
- Fixed include path in CMakeLists.txt
pjohnmeyer Mar 24, 2013
e3f7e53
Merge pull request #34 from pjohnmeyer/version1.4CompatibilityFixes
pjohnmeyer Mar 24, 2013
3a12a31
Add support and project files for Visual Studio 2012
pjohnmeyer Mar 24, 2013
49f6d85
Add *.bat as eol=crlf.
pjohnmeyer Mar 24, 2013
6c1c587
Add strip_cmake.bat for deleting "extra" files generated by CMake.
pjohnmeyer Mar 24, 2013
5b363d9
Generate new Visual Studio 2010 projects.
pjohnmeyer Mar 24, 2013
87b0e15
Generate new Visual Studio 2008 projects.
pjohnmeyer Mar 24, 2013
ed6d924
Remove old TestUnitTest++ 2010 project files.
pjohnmeyer Mar 24, 2013
f79e71a
Generate new Visual Studio 2005 projects.
pjohnmeyer Mar 24, 2013
44fb013
Remove old Visual Studio 2005 projects.
pjohnmeyer Mar 24, 2013
4a466f8
Generate new Visual Studio 2003 projects.
pjohnmeyer Mar 24, 2013
6daa0b3
Remove missed Visual Studio 2005 file.
pjohnmeyer Mar 24, 2013
f74f15e
Remove old Visual Studio 2003 project files.
pjohnmeyer Mar 24, 2013
dbc44ed
Merge pull request #35 from pjohnmeyer/master
pjohnmeyer Mar 24, 2013
d56123c
Fixed autotools
qdii Mar 29, 2013
6389e93
Added license (MIT)
qdii Mar 29, 2013
b5725ae
Remove COPYING inadvertently merged from #38
pjohnmeyer Apr 11, 2013
c59c754
Add .gitignore for Xcode projects
Apr 17, 2013
9c58d1b
Add a new Xcode 4.6 project
Apr 18, 2013
f01953a
Add UnitTest++ source to the project
Apr 18, 2013
093ef7e
Add a target for TestUnitTest++
Apr 18, 2013
5bc3ff8
Update TestUnitTest++ to use existing code
Apr 18, 2013
5b3fc9e
Merge pull request #40 from chris-frederick/xcode_project
pjohnmeyer May 3, 2013
488b03c
Remove old docs folder.
pjohnmeyer May 9, 2013
117e485
Add https://github.com/unittest-cpp/unittest-cpp.wiki.git as submodul…
pjohnmeyer May 9, 2013
a205841
Add Documentation, Pre-requisites, and Downloading instructions to ma…
pjohnmeyer May 9, 2013
17b1a45
Add link to contributor graph under 'Contributors'.
pjohnmeyer May 9, 2013
c9b2005
Incorporate new commits in wiki.
pjohnmeyer May 9, 2013
b2de87d
Incorporate latest wiki docs.
pjohnmeyer May 9, 2013
a77b61a
Merge pull request #41 from pjohnmeyer/documentationUpdates
pjohnmeyer May 9, 2013
b4539f4
Fix spelling error in README
pjohnmeyer May 9, 2013
4ab7aa4
Add changes required to compile with MS VC6
martinmoene May 9, 2013
c42e68b
Add 'empty' builds directory per the wiki. (The folder is not actuall…
pjohnmeyer May 9, 2013
a4686b2
Merge remote-tracking branch 'remotes/upstream/master'
martinmoene May 9, 2013
d684f5e
Adapt MemoryOutStream for VC6 __int64 type
martinmoene May 10, 2013
3f301ee
Integrating test failure in to QtCreator IDE build errors
Jun 9, 2013
de52aa1
Merge pull request #43 from martinmoene/master
pjohnmeyer Jul 2, 2013
49764ce
Fix autotools configuration
magicant Jul 20, 2013
9ad680a
Merge pull request #46 from lijoantony/master
pjohnmeyer Jul 22, 2013
aa78440
Merge pull request #48 from magicant/autotools
pjohnmeyer Jul 22, 2013
e76d25a
Replace absolute paths with relative paths in Visual Studio project f…
pjohnmeyer Aug 24, 2013
472b528
Fix crash bug in msvc
warmist Jan 6, 2014
eba7e6d
Merge pull request #53 from warmist/patch-1
pjohnmeyer Jan 16, 2014
a2639ea
fix broken tests
nlap Jun 5, 2014
bd3b6e2
keep absolute path
nlap Jun 5, 2014
d482831
Merge branch 'novawave-master'
pjohnmeyer Jun 28, 2014
9218ffc
Reformatted code from #54.
pjohnmeyer Jun 28, 2014
856d881
Introducing additional functionality to allow client code to stop a u…
ohz10 Oct 11, 2014
c8522b0
Bug Fix: ensure we stop unit test execution when an unexpected except…
ohz10 Oct 12, 2014
0526331
Introducing additional functionality to allow client code to stop a unit
ohz10 Oct 17, 2014
dc065a3
Revert "Bug Fix: ensure we stop unit test execution when an unexpecte…
ohz10 Oct 21, 2014
bb339cf
Revert "Introducing additional functionality to allow client code to …
ohz10 Oct 21, 2014
6e4a1a5
Use for loop to achieve REQUIRE with no parens
pjohnmeyer Nov 5, 2014
61676e5
This commit addresses two issues:
ohz10 Dec 7, 2014
e75f66b
Eliminating 'unused exception variable' warnings.
ohz10 May 18, 2015
cf5c33f
Merge with upstream master.
ohz10 May 28, 2015
4f90f7c
Merge branch 'upstream' into develop
ohz10 May 28, 2015
f5a778b
Merge branch 'develop' into RequiredMacroAsForLoop
ohz10 May 28, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions UnitTest++/CheckMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
if (!UnitTest::Check(value)) \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \
}) \
UT_CATCH (UnitTest::AssertException, , \
{ \
UT_THROW(); \
}) \
UT_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream message; \
Expand All @@ -61,6 +65,10 @@
({ \
UnitTest::CheckEqual(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UT_CATCH (UnitTest::AssertException, , \
{ \
UT_THROW(); \
}) \
UT_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream message; \
Expand All @@ -81,6 +89,10 @@
({ \
UnitTest::CheckClose(*UnitTest::CurrentTest::Results(), expected, actual, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UT_CATCH (UnitTest::AssertException, , \
{ \
UT_THROW(); \
}) \
UT_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream message; \
Expand All @@ -101,6 +113,10 @@
({ \
UnitTest::CheckArrayEqual(*UnitTest::CurrentTest::Results(), expected, actual, count, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UT_CATCH (UnitTest::AssertException, , \
{ \
UT_THROW(); \
}) \
UT_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream message; \
Expand All @@ -121,6 +137,10 @@
({ \
UnitTest::CheckArrayClose(*UnitTest::CurrentTest::Results(), expected, actual, count, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UT_CATCH (UnitTest::AssertException, , \
{ \
UT_THROW(); \
}) \
UT_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream message; \
Expand All @@ -141,6 +161,10 @@
({ \
UnitTest::CheckArray2DClose(*UnitTest::CurrentTest::Results(), expected, actual, rows, columns, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UT_CATCH (UnitTest::AssertException, , \
{ \
UT_THROW(); \
}) \
UT_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream message; \
Expand Down
18 changes: 18 additions & 0 deletions UnitTest++/RequireMacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef UNITTEST_REQUIREMACROS_H
#define UNITTEST_REQUIREMACROS_H

#include "RequiredCheckTestReporter.h"

#ifdef REQUIRE
#error UnitTest++ redefines REQUIRE
#endif

#ifndef UNITTEST_NO_EXCEPTIONS
#define REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(UnitTest::CurrentTest::Results()); decoratedReporter.next(); )
#endif

#ifdef UNITTEST_NO_EXCEPTIONS
#define REQUIRE
#endif

#endif
29 changes: 29 additions & 0 deletions UnitTest++/RequiredCheckTestReporter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "RequiredCheckTestReporter.h"

#include "CurrentTest.h"
#include "TestResults.h"

namespace UnitTest {

RequiredCheckTestReporter::RequiredCheckTestReporter(TestResults* results)
: m_results(results)
, m_throwingReporter(0)
, m_continue(0)
{
if(m_results)
{
m_throwingReporter.setDecorated(m_results->m_testReporter);
m_results->m_testReporter = &m_throwingReporter;
}
}

RequiredCheckTestReporter::~RequiredCheckTestReporter()
{
if(m_results) m_results->m_testReporter = m_throwingReporter.getDecorated();
}

bool RequiredCheckTestReporter::next()
{
return m_continue++ == 0;
}
}
29 changes: 29 additions & 0 deletions UnitTest++/RequiredCheckTestReporter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H
#define UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H

#include "HelperMacros.h"
#include "ThrowingTestReporter.h"

namespace UnitTest {

class TestResults;

// This RAII class decorates the current TestReporter with
// a version that throws after reporting a failure.
class UNITTEST_LINKAGE RequiredCheckTestReporter
{
public:
explicit RequiredCheckTestReporter(TestResults* results);
~RequiredCheckTestReporter();

bool next();

private:
TestResults* m_results;
ThrowingTestReporter m_throwingReporter;
int m_continue;
};
}

#endif

4 changes: 4 additions & 0 deletions UnitTest++/TestResults.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace UnitTest {

class RequiredCheckTestReporter;
class TestReporter;
class TestDetails;

Expand All @@ -21,6 +22,9 @@ class UNITTEST_LINKAGE TestResults
int GetFailedTestCount() const;
int GetFailureCount() const;

private:
friend class RequiredCheckTestReporter;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have avoided using friend here and introduced a getter/setter instead. I wanted to avoid signature changes to existing classes exported in shared libraries. (This is admittedly probably a silly concern, and I'm happy to change this).


private:
TestReporter* m_testReporter;
int m_totalTestCount;
Expand Down
51 changes: 51 additions & 0 deletions UnitTest++/ThrowingTestReporter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "ThrowingTestReporter.h"
#include "AssertException.h"

namespace UnitTest {

ThrowingTestReporter::ThrowingTestReporter(TestReporter* decoratedReporter)
: m_decoratedReporter(decoratedReporter)
{
}

//virtual
ThrowingTestReporter::~ThrowingTestReporter()
{
}

//virtual
void ThrowingTestReporter::ReportTestStart(TestDetails const& test)
{
if(m_decoratedReporter) m_decoratedReporter->ReportTestStart(test);
}

//virtual
void ThrowingTestReporter::ReportFailure(TestDetails const& test, char const* failure)
{
if(m_decoratedReporter) m_decoratedReporter->ReportFailure(test, failure);
throw AssertException();
}

//virtual
void ThrowingTestReporter::ReportTestFinish(TestDetails const& test, float secondsElapsed)
{
if(m_decoratedReporter) m_decoratedReporter->ReportTestFinish(test, secondsElapsed);
}

//virtual
void ThrowingTestReporter::ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed)
{
if(m_decoratedReporter) m_decoratedReporter->ReportSummary(totalTestCount, failedTestCount, failureCount, secondsElapsed);
}

TestReporter* ThrowingTestReporter::getDecorated() const
{
return m_decoratedReporter;
}

void ThrowingTestReporter::setDecorated(TestReporter* reporter)
{
m_decoratedReporter = reporter;
}

}
29 changes: 29 additions & 0 deletions UnitTest++/ThrowingTestReporter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef UNITTEST_THROWINGTESTREPORTER_H
#define UNITTEST_THROWINGTESTREPORTER_H

#include "TestReporter.h"

namespace UnitTest {

// A TestReporter that throws when ReportFailure is called. Otherwise it
// forwards the calls to a decorated TestReporter
class ThrowingTestReporter : public TestReporter
{
public:
explicit ThrowingTestReporter(TestReporter* reporter);

virtual ~ThrowingTestReporter();
virtual void ReportTestStart(TestDetails const& test);
virtual void ReportFailure(TestDetails const& test, char const* failure);
virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed);
virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed);

TestReporter* getDecorated() const;
void setDecorated(TestReporter* reporter);

private:
TestReporter* m_decoratedReporter;
};
}

#endif
1 change: 1 addition & 0 deletions UnitTest++/UnitTestPP.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Config.h"
#include "TestMacros.h"
#include "CheckMacros.h"
#include "RequireMacros.h"
#include "TestRunner.h"
#include "TimeConstraint.h"
#include "ReportAssert.h"
Expand Down
Loading