Skip to content

Commit 7b9e3a1

Browse files
committed
r22 | charles.nicholson | 2010-03-18 18:39:32 -0500 (Thu, 18 Mar 2010) | 1 line
negate config flags and comment them out by default; this allows command-line preprocessor symbol injection to control flags. Useful for having a master copy of utpp that build with different flags for different compilers/platforms
1 parent 909f4b2 commit 7b9e3a1

24 files changed

Lines changed: 65 additions & 51 deletions

config.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,29 @@
2727
#define UNITTEST_MINGW
2828
#endif
2929

30-
// by default, MemoryOutStream is implemented in terms of std::ostringstream, which can be expensive.
31-
// uncomment this line to use the custom MemoryOutStream (no deps on std::ostringstream).
3230

33-
#define UNITTEST_USE_CUSTOM_STREAMS
34-
#define UNITTEST_USE_DEFERRED_REPORTER
35-
#define UNITTEST_USE_EXCEPTIONS
31+
// MemoryOutStream is a custom reimplementation of parts of std::ostringstream.
32+
// Uncomment this line to have MemoryOutStream implemented in terms of std::ostringstream.
33+
// This is useful if you are using the CHECK macros on objects that have something like this defined:
34+
// std::ostringstream& operator<<(std::ostringstream& s, const YourObject& value)
35+
36+
//#define UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
37+
38+
39+
// DeferredTestReporter uses the STL to collect test results for subsequent export by reporters like
40+
// XmlTestReporter. If you don't want to use this functionality, uncomment this line and no STL
41+
// headers or code will be compiled into UnitTest++
42+
43+
//#define UNITTEST_NO_DEFERRED_REPORTER
44+
45+
46+
// By default, asserts that you report via UnitTest::ReportAssert() abort the current test and
47+
// continue to the next one by throwing an exception, which unwinds the stack naturally, destroying
48+
// all auto variables on its way back down. If you don't want to (or can't) use exceptions for your
49+
// platform/compiler, uncomment this line. All exception code will be removed from UnitTest++,
50+
// assert recovery will be done via setjmp/longjmp, and NO correct stack unwinding will happen!
51+
52+
//#define UNITTEST_NO_EXCEPTIONS
53+
3654

3755
#endif

src/AssertException.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "AssertException.h"
22

3-
#ifdef UNITTEST_USE_EXCEPTIONS
3+
#ifndef UNITTEST_NO_EXCEPTIONS
44

55
namespace UnitTest {
66

src/AssertException.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define UNITTEST_ASSERTEXCEPTION_H
33

44
#include "../config.h"
5-
#ifdef UNITTEST_USE_EXCEPTIONS
5+
#ifndef UNITTEST_NO_EXCEPTIONS
66

77
#include "HelperMacros.h"
88
#include <exception>

src/CheckMacros.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@
114114
UNITTEST_MULTILINE_MACRO_END
115115

116116

117-
// CHECK_THROW and CHECK_ASSERT only exist when UNITTEST_USE_EXCEPTIONS is defined (see Config.h)
118-
#ifdef UNITTEST_USE_EXCEPTIONS
117+
// CHECK_THROW and CHECK_ASSERT only exist when UNITTEST_NO_EXCEPTIONS isn't defined (see config.h)
118+
#ifndef UNITTEST_NO_EXCEPTIONS
119119
#define CHECK_THROW(expression, ExpectedExceptionType) \
120120
UNITTEST_MULTILINE_MACRO_BEGIN \
121121
bool caught_ = false; \
@@ -134,4 +134,4 @@
134134
UnitTest::Detail::ExpectAssert(false); \
135135
UNITTEST_MULTILINE_MACRO_END
136136
#endif
137-
#endif
137+
#endif

src/DeferredTestReporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "../config.h"
2-
#ifdef UNITTEST_USE_DEFERRED_REPORTER
2+
#ifndef UNITTEST_NO_DEFERRED_REPORTER
33

44
#include "DeferredTestReporter.h"
55
#include "TestDetails.h"

src/DeferredTestReporter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "../config.h"
55

6-
#ifdef UNITTEST_USE_DEFERRED_REPORTER
6+
#ifndef UNITTEST_NO_DEFERRED_REPORTER
77

88
#include "TestReporter.h"
99
#include "DeferredTestResult.h"

src/DeferredTestResult.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "../config.h"
2-
#ifdef UNITTEST_USE_DEFERRED_REPORTER
2+
#ifndef UNITTEST_NO_DEFERRED_REPORTER
33

44
#include "DeferredTestResult.h"
55
#include <cstring>

src/DeferredTestResult.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define UNITTEST_DEFERREDTESTRESULT_H
33

44
#include "../config.h"
5-
#ifdef UNITTEST_USE_DEFERRED_REPORTER
5+
#ifndef UNITTEST_NO_DEFERRED_REPORTER
66

77
#include "HelperMacros.h"
88
#include <string>

src/ExceptionMacros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "../config.h"
55

6-
#ifdef UNITTEST_USE_EXCEPTIONS
6+
#ifndef UNITTEST_NO_EXCEPTIONS
77
#define UT_TRY(x) try x
88
#define UT_THROW(x) throw x
99
#define UT_CATCH(ExceptionType, ExceptionName, CatchBody) catch(ExceptionType& ExceptionName) CatchBody

src/ExecuteTest.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "AssertException.h"
1010
#include "CurrentTest.h"
1111

12-
#ifndef UNITTEST_USE_EXCEPTIONS
12+
#ifdef UNITTEST_NO_EXCEPTIONS
1313
#include "ReportAssertImpl.h"
1414
#endif
1515

@@ -25,7 +25,7 @@ void ExecuteTest(T& testObject, TestDetails const& details, bool isMockTest)
2525
if (isMockTest == false)
2626
CurrentTest::Details() = &details;
2727

28-
#ifndef UNITTEST_USE_EXCEPTIONS
28+
#ifdef UNITTEST_NO_EXCEPTIONS
2929
if (UNITTEST_SET_ASSERT_JUMP_TARGET() == 0)
3030
{
3131
#endif
@@ -49,7 +49,7 @@ void ExecuteTest(T& testObject, TestDetails const& details, bool isMockTest)
4949
({
5050
CurrentTest::Results()->OnTestFailure(details, "Unhandled exception: test crashed");
5151
})
52-
#ifndef UNITTEST_USE_EXCEPTIONS
52+
#ifdef UNITTEST_NO_EXCEPTIONS
5353
}
5454
#endif
5555
}

0 commit comments

Comments
 (0)