#include "../extern/doctest.hpp" #include "../src/Assert.hpp" void TestWrapper(bool wrapperExpression) { Assert(wrapperExpression) } void TestWrapperNotNull(void* value) { AssertNotNull(value) } TEST_CASE("Assert succeeds if true") { REQUIRE_NOTHROW(TestWrapper(true)); } TEST_CASE("Assert throws if false") { REQUIRE_THROWS(TestWrapper(false)); } TEST_CASE("Assert throws if false with message") { try { TestWrapper(false); } catch (const ArbUt::Exception& e) { REQUIRE(strcmp(e.what(), "ASSERTION FAILED: [AssertTests.cpp (3)] \"wrapperExpression\"") == 0); return; } throw ArbUt::Exception("Didn't throw."); } TEST_CASE("Multiple asserts") { Assert(true) Assert(true) Assert(true) } TEST_CASE("AssertNotNull throws if nullptr") { REQUIRE_THROWS(TestWrapperNotNull(nullptr)); } TEST_CASE("Assert for each") { auto i = {10, 500, 2300, 454}; AssertForEach(i, item > 0) }