Skip to content

Commit 23c7368

Browse files
committed
r5 | charles.nicholson | 2010-03-15 17:46:01 -0500 (Mon, 15 Mar 2010) | 1 line
remove leftover exception test structures, fix ReportAssert for no-exceptions build
1 parent 4f556d6 commit 23c7368

File tree

5 files changed

+33
-38
lines changed

5 files changed

+33
-38
lines changed

src/AssertException.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "AssertException.h"
2+
3+
#ifdef UNITTEST_USE_EXCEPTIONS
4+
25
#include <cstring>
36

47
namespace UnitTest {
@@ -12,11 +15,11 @@ AssertException::AssertException(char const* description, char const* filename,
1215
strcpy(m_filename, filename);
1316
}
1417

15-
AssertException::~AssertException() throw()
18+
AssertException::~AssertException()
1619
{
1720
}
1821

19-
char const* AssertException::what() const throw()
22+
char const* AssertException::what() const
2023
{
2124
return m_description;
2225
}
@@ -32,3 +35,5 @@ int AssertException::LineNumber() const
3235
}
3336

3437
}
38+
39+
#endif

src/AssertException.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
#ifndef UNITTEST_ASSERTEXCEPTION_H
22
#define UNITTEST_ASSERTEXCEPTION_H
33

4-
#include <exception>
4+
#include "Config.h"
5+
6+
#ifdef UNITTEST_USE_EXCEPTIONS
57

8+
#include <exception>
69

710
namespace UnitTest {
811

912
class AssertException : public std::exception
1013
{
1114
public:
1215
AssertException(char const* description, char const* filename, int lineNumber);
13-
virtual ~AssertException() throw();
16+
virtual ~AssertException();
1417

15-
virtual char const* what() const throw();
18+
virtual char const* what() const;
1619

1720
char const* Filename() const;
1821
int LineNumber() const;
@@ -26,3 +29,5 @@ class AssertException : public std::exception
2629
}
2730

2831
#endif
32+
33+
#endif

src/Config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
// uncomment this line to use the custom MemoryOutStream (no deps on std::ostringstream).
2828

2929
#define UNITTEST_USE_CUSTOM_STREAMS
30-
#define UNITTEST_USE_EXCEPTIONS
30+
//#define UNITTEST_USE_EXCEPTIONS
3131

3232
#endif

src/ReportAssert.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
#include "ReportAssert.h"
2-
#include "AssertException.h"
3-
4-
namespace UnitTest {
5-
6-
void ReportAssert(char const* description, char const* filename, int lineNumber)
7-
{
8-
throw AssertException(description, filename, lineNumber);
9-
}
10-
11-
}
1+
#include "ReportAssert.h"
2+
#include "AssertException.h"
3+
4+
namespace UnitTest {
5+
6+
void ReportAssert(char const* description, char const* filename, int lineNumber)
7+
{
8+
(void)description;
9+
(void)filename;
10+
(void)lineNumber;
11+
12+
#ifdef UNITTEST_USE_EXCEPTIONS
13+
throw AssertException(description, filename, lineNumber);
14+
#endif
15+
}
16+
17+
}

src/tests/TestCheckMacros.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,6 @@ TEST(CheckCloseDoesNotHaveSideEffectsWhenFailing)
206206
CHECK_EQUAL(1, g_sideEffect);
207207
}
208208

209-
210-
class ThrowingObject
211-
{
212-
public:
213-
float operator[](int) const
214-
{
215-
throw "Test throw";
216-
}
217-
};
218-
219-
220209
TEST(CheckArrayCloseSucceedsOnEqual)
221210
{
222211
bool failure = true;
@@ -404,16 +393,6 @@ TEST(CheckArrayCloseDoesNotHaveSideEffectsWhenFailing)
404393
CHECK_EQUAL(1, g_sideEffect);
405394
}
406395

407-
class ThrowingObject2D
408-
{
409-
public:
410-
float* operator[](int) const
411-
{
412-
throw "Test throw";
413-
}
414-
};
415-
416-
417396
TEST(CheckArray2DCloseSucceedsOnEqual)
418397
{
419398
bool failure = true;

0 commit comments

Comments
 (0)