Fixes for AssertNotNull
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
657767536f
commit
07f215a4fa
|
@ -9,7 +9,7 @@
|
||||||
#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 << "\""; \
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "../extern/catch.hpp"
|
#include "../extern/catch.hpp"
|
||||||
#include "../src/Assert.hpp"
|
#include "../src/Assert.hpp"
|
||||||
void TestWrapper(bool wrapperExpression){Assert(wrapperExpression)}
|
void TestWrapper(bool wrapperExpression){Assert(wrapperExpression)}
|
||||||
|
void TestWrapperNotNull(void* value){AssertNotNull(value)}
|
||||||
|
|
||||||
TEST_CASE("Assert succeeds if true", "[Utilities]") {
|
TEST_CASE("Assert succeeds if true", "[Utilities]") {
|
||||||
REQUIRE_NOTHROW(TestWrapper(true));
|
REQUIRE_NOTHROW(TestWrapper(true));
|
||||||
|
@ -12,3 +13,5 @@ TEST_CASE("Assert throws if false with message", "[Utilities]") {
|
||||||
REQUIRE_THROWS_WITH(TestWrapper(false),
|
REQUIRE_THROWS_WITH(TestWrapper(false),
|
||||||
Catch::Matchers::Equals("ASSERTION FAILED: [AssertTests.cpp (3)] \"wrapperExpression\""));
|
Catch::Matchers::Equals("ASSERTION FAILED: [AssertTests.cpp (3)] \"wrapperExpression\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("AssertNotNull throws if nullptr", "[Utilities]") { REQUIRE_THROWS(TestWrapperNotNull(nullptr)); }
|
||||||
|
|
Loading…
Reference in New Issue