More fixes for Assert.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
2d4cc2cd80
commit
aa1b90554f
|
@ -6,14 +6,12 @@
|
||||||
|
|
||||||
#ifndef NO_ASSERT
|
#ifndef NO_ASSERT
|
||||||
#define Assert(expr) \
|
#define Assert(expr) \
|
||||||
{ \
|
if (!(expr)) { \
|
||||||
if (!(expr)) { \
|
std::stringstream ss; \
|
||||||
std::stringstream ss; \
|
ss << "ASSERTION FAILED: [" << __FILENAME__ << " (" << __LINE__ << ")] \""; \
|
||||||
ss << "ASSERTION FAILED: [" << __FILENAME__ << " (" << __LINE__ << ")] \""; \
|
ss << #expr << "\""; \
|
||||||
ss << #expr << "\""; \
|
throw std::logic_error(ss.str()); \
|
||||||
throw std::logic_error(ss.str()); \
|
}
|
||||||
} \
|
|
||||||
};
|
|
||||||
#else
|
#else
|
||||||
// Assert is empty if NO_ASSERT is defined.
|
// Assert is empty if NO_ASSERT is defined.
|
||||||
#define Assert(expr)
|
#define Assert(expr)
|
||||||
|
|
|
@ -14,4 +14,11 @@ TEST_CASE("Assert throws if false with message", "[Utilities]") {
|
||||||
Catch::Matchers::Equals("ASSERTION FAILED: [AssertTests.cpp (3)] \"wrapperExpression\""));
|
Catch::Matchers::Equals("ASSERTION FAILED: [AssertTests.cpp (3)] \"wrapperExpression\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Multiple asserts", "[Utilities]") {
|
||||||
|
Assert(true);
|
||||||
|
Assert(true);
|
||||||
|
Assert(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("AssertNotNull throws if nullptr", "[Utilities]") { REQUIRE_THROWS(TestWrapperNotNull(nullptr)); }
|
TEST_CASE("AssertNotNull throws if nullptr", "[Utilities]") { REQUIRE_THROWS(TestWrapperNotNull(nullptr)); }
|
||||||
|
|
Loading…
Reference in New Issue