Reworks ensure and throw to not fully depend on macros anymore.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-11-21 12:27:46 +01:00
parent ea5c824d34
commit 1be055760a
5 changed files with 117 additions and 23 deletions

View File

@@ -4,6 +4,8 @@
using namespace ArbUt;
static void Thrower() { throw ArbUt::Exception("foobar"); }
static void ThrowerWithMacro() { THROW("foobar"); }
static void ThrowerWithMacroAndParameters([[maybe_unused]] int i) { THROW("foobar", ' ', i); }
TEST_CASE("Throw exception get stack trace") {
try {
@@ -16,4 +18,20 @@ TEST_CASE("Throw exception get stack trace") {
}
}
TEST_CASE("Throw exception with macro, check message") {
try {
ThrowerWithMacro();
} catch (const ArbUt::Exception& e) {
REQUIRE_EQ(std::string(e.what()), "[ExceptionTests.cpp:7] \"foobar\"");
}
}
TEST_CASE("Throw exception with macro and parameters, check message") {
try {
ThrowerWithMacroAndParameters(684);
} catch (const ArbUt::Exception& e) {
REQUIRE_EQ(std::string(e.what()), "[ExceptionTests.cpp:8] \"foobar 684\"");
}
}
#endif