8000 Use new RequiredCheckException for REQUIRE · unittest-cpp/unittest-cpp@40b8f0b · GitHub
[go: up one dir, main page]

Skip to content

Commit 40b8f0b

Browse files
committed
Use new RequiredCheckException for REQUIRE
Rather than re-using AssertException, it felt more correct to create a new special-purpose exception.
1 parent 74ca0c3 commit 40b8f0b

File tree

5 files changed

+84
-43
lines changed

5 files changed

+84
-43
lines changed

UnitTest++/CheckMacros.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "ExceptionMacros.h"
66
#include "Checks.h"
77
#include "AssertException.h"
8+
#include "RequiredCheckException.h"
89
#include "MemoryOutStream.h"
910
#include "TestDetails.h"
1011
#include "CurrentTest.h"
@@ -41,7 +42,7 @@
4142
if (!UnitTest::Check(value)) \
4243
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \
4344
}) \
44-
UT_CA 10000 TCH (UnitTest::AssertException, , \
45+
UT_CATCH (UnitTest::RequiredCheckException, , \
4546
{ \
4647
UT_THROW(); \
4748
}) \
@@ -65,7 +66,7 @@
6566
({ \
6667
UnitTest::CheckEqual(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
6768
}) \
68-
UT_CATCH (UnitTest::AssertException, , \
69+
UT_CATCH (UnitTest::RequiredCheckException, , \
6970
{ \
7071
UT_THROW(); \
7172
}) \
@@ -89,7 +90,7 @@
8990
({ \
9091
UnitTest::CheckClose(*UnitTest::CurrentTest::Results(), expected, actual, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
9192
}) \
92-
UT_CATCH (UnitTest::AssertException, , \
93+
UT_CATCH (UnitTest::RequiredCheckException, , \
9394
{ \
9495
UT_THROW(); \
9596
}) \
@@ -113,7 +114,7 @@
113114
({ \
114115
UnitTest::CheckArrayEqual(*UnitTest::CurrentTest::Results(), expected, actual, count, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
115116
}) \
116-
UT_CATCH (UnitTest::AssertException, , \
117+
UT_CATCH (UnitTest::RequiredCheckException, , \
117118
{ \
118119
UT_THROW(); \
119120
}) \
@@ -137,7 +138,7 @@
137138
({ \
138139
UnitTest::CheckArrayClose(*UnitTest::CurrentTest::Results(), expected, actual, count, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
139140
}) \
140-
UT_CATCH (UnitTest::AssertException, , \
141+
UT_CATCH (UnitTest::RequiredCheckException, , \
141142
{ \
142143
UT_THROW(); \
143144
}) \
@@ -161,7 +162,7 @@
161162
({ \
162163
UnitTest::CheckArray2DClose(*UnitTest::CurrentTest::Results(), expected, actual, rows, columns, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
163164
}) \
164-
UT_CATCH (UnitTest::AssertException, , \
165+
UT_CATCH (UnitTest::RequiredCheckException, , \
165166
{ \
166167
UT_THROW(); \
167168
}) \

UnitTest++/RequiredCheckException.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "RequiredCheckException.h"
2+
3+
#ifndef UNITTEST_NO_EXCEPTIONS
4+
5+
namespace UnitTest {
6+
7+
RequiredCheckException::RequiredCheckException()
8+
{
9+
}
10+
11+
RequiredCheckException::~RequiredCheckException() throw()
12+
{
13+
}
14+
15+
}
16+
17+
#endif

UnitTest++/RequiredCheckException.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef UNITTEST_REQUIREDCHECKEXCEPTION_H
2+
#define UNITTEST_REQUIREDCHECKEXCEPTION_H
3+
4+
#include "Config.h"
5+
#ifndef UNITTEST_NO_EXCEPTIONS
6+
7+
#include "HelperMacros.h"
8+
#include <exception>
9+
10+
namespace UnitTest {
11+
12+
class UNITTEST_LINKAGE RequiredCheckException : public std::exception
13+
{
14+
public:
15+
RequiredCheckException();
16+
virtual ~RequiredCheckException() throw();
17+
};
18+
19+
}
20+
21+
#endif
22+
23+
#endif

UnitTest++/ThrowingTestReporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "ThrowingTestReporter.h"
2-
#include "AssertException.h"
2+
#include "RequiredCheckException.h"
33

44
namespace UnitTest {
55

@@ -21,7 +21,7 @@ namespace UnitTest {
2121
void ThrowingTestReporter::ReportFailure(TestDetails const& test, char const* failure)
2222
{
2323
if(m_decoratedReporter) m_decoratedReporter->ReportFailure(test, failure);
24-
throw AssertException();
24+
throw RequiredCheckException();
2525
}
2626

2727
//virtual

0 commit comments

Comments
 (0)
0