8000 r26 | charles.nicholson | 2010-03-22 14:16:24 -0500 (Mon, 22 Mar 2010… · tobscher/unittest-cpp@3fe7f2f · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fe7f2f

Browse files
committed
r26 | charles.nicholson | 2010-03-22 14:16:24 -0500 (Mon, 22 Mar 2010) | 1 line
platform macros for jmp_buf, setjmp, longjmp. Remove unused code, fix shadowed virtual functions (yikes!)
1 parent e92de84 commit 3fe7f2f

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,4 @@
5151

5252
//#define UNITTEST_NO_EXCEPTIONS
5353

54-
5554
#endif

src/HelperMacros.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@
3939
#define UNITTEST_STDVECTOR_LINKAGE(T)
4040
#endif
4141

42+
#ifdef UNITTEST_WIN32
43+
#define UNITTEST_JMPBUF jmp_buf
44+
#define UNITTEST_SETJMP setjmp
45+
#define UNITTEST_LONGJMP longjmp
46+
#elif defined UNITTEST_POSIX
47+
#define UNITTEST_JMPBUF std::jmp_buf
48+
#define UNITTEST_SETJMP setjmp
49+
#define UNITTEST_LONGJMP std::longjmp
50+
#endif
51+
4252
#endif

src/ReportAssert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ UNITTEST_LINKAGE void ReportAssert(char const* description, char const* filename
2929
namespace Detail {
3030

3131
#ifdef UNITTEST_NO_EXCEPTIONS
32-
jmp_buf* GetAssertJmpBuf()
32+
UNITTEST_JMPBUF* GetAssertJmpBuf()
3333
{
34-
static jmp_buf s_jmpBuf;
34+
static UNITTEST_JMPBUF s_jmpBuf;
3535
return &s_jmpBuf;
3636
}
3737
#endif

src/ReportAssertImpl.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define UNITTEST_REPORTASSERTIMPL_H
33

44
#include "../config.h"
5+
#include "HelperMacros.h"
56

67
#ifdef UNITTEST_NO_EXCEPTIONS
78
#include <csetjmp>
@@ -25,18 +26,18 @@ UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults,
2526
UNITTEST_LINKAGE bool AssertExpected();
2627

2728
#ifdef UNITTEST_NO_EXCEPTIONS
28-
UNITTEST_LINKAGE jmp_buf* GetAssertJmpBuf();
29+
UNITTEST_LINKAGE UNITTEST_JMPBUF* GetAssertJmpBuf();
2930

3031
#ifdef UNITTEST_WIN32
3132
#define UNITTEST_SET_ASSERT_JUMP_TARGET() \
3233
__pragma(warning(push)) __pragma(warning(disable:4611)) \
33-
setjmp(*UnitTest::Detail::GetAssertJmpBuf()) \
34+
UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf()) \
3435
__pragma(warning(pop))
3536
#else
36-
#define UNITTEST_SET_ASSERT_JUMP_TARGET() setjmp(*UnitTest::Detail::GetAssertJmpBuf())
37+
#define UNITTEST_SET_ASSERT_JUMP_TARGET() UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf())
3738
#endif
3839

39-
#define UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET() longjmp(*UnitTest::Detail::GetAssertJmpBuf(), 1)
40+
#define UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET() UNITTEST_LONGJMP(*UnitTest::Detail::GetAssertJmpBuf(), 1)
4041
#endif
4142

4243
}

src/tests/TestExceptions.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,6 @@ TEST(CheckArrayEqualFailureOnExceptionIncludesCheckContents)
226226
CHECK(strstr(reporter.lastFailedMessage, "obj"));
227227
}
228228

229-
int g_sideEffect = 0;
230-
float const* FunctionWithSideEffects2()
231-
{
232-
++g_sideEffect;
233-
static float const data[] = {1,2,3,4};
234-
return data;
235-
}
236-
237229
class ThrowingObject2D
238230
{
239231
public:

src/tests/TestTestRunner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class SlowTest : public Test
8181
{
8282
public:
8383
SlowTest() : Test("slow", "somesuite", "filename", 123) {}
84-
virtual void RunImpl(TestResults&) const
84+
virtual void RunImpl() const
8585
{
8686
TimeHelpers::SleepMs(20);
8787
}
@@ -213,7 +213,7 @@ TEST_FIXTURE(TestRunnerFixture, SlowTestWithTimeExemptionPasses)
213213
{
214214
public:
215215
SlowExemptedTest() : Test("slowexempted", "", 0) {}
216-
virtual void RunImpl(TestResults&) const
216+
virtual void RunImpl() const
217217
{
218218
UNITTEST_TIME_CONSTRAINT_EXEMPT();
219219
TimeHelpers::SleepMs(20);

0 commit comments

Comments
 (0)
0