Tweaks and fixes for Assert
This commit is contained in:
parent
638a414961
commit
e07e07253d
|
@ -116,6 +116,8 @@ Standard: Cpp11
|
||||||
StatementMacros:
|
StatementMacros:
|
||||||
- Q_UNUSED
|
- Q_UNUSED
|
||||||
- QT_REQUIRE_VERSION
|
- QT_REQUIRE_VERSION
|
||||||
|
- Assert
|
||||||
|
- AssertNotNull
|
||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
...
|
...
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Assert is empty if NO_ASSERT is defined.
|
// Assert is empty if NO_ASSERT is defined.
|
||||||
#define Assert(expr)
|
#define Assert(expr) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AssertNotNull(value) Assert(value != nullptr);
|
#define AssertNotNull(value) Assert(value != nullptr)
|
|
@ -3,9 +3,7 @@
|
||||||
void TestWrapper(bool wrapperExpression) { Assert(wrapperExpression) }
|
void TestWrapper(bool wrapperExpression) { Assert(wrapperExpression) }
|
||||||
void TestWrapperNotNull(void* value) { AssertNotNull(value) }
|
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("Assert throws if false", "[Utilities]") { REQUIRE_THROWS(TestWrapper(false)); }
|
TEST_CASE("Assert throws if false", "[Utilities]") { REQUIRE_THROWS(TestWrapper(false)); }
|
||||||
|
|
||||||
|
@ -15,9 +13,9 @@ TEST_CASE("Assert throws if false with message", "[Utilities]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Multiple asserts", "[Utilities]") {
|
TEST_CASE("Multiple asserts", "[Utilities]") {
|
||||||
Assert(true);
|
Assert(true)
|
||||||
Assert(true);
|
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