Arbutils/tests/ExceptionTests.cpp

23 lines
497 B
C++

#ifdef TESTS_BUILD
#include "../extern/catch.hpp"
#include "../src/Exception.hpp"
using namespace ArbUt;
#ifndef WINDOWS
__attribute__((optnone))
#endif
static void
Thrower() {
throw ArbUt::Exception("foobar");
}
TEST_CASE("Throw exception get stack trace") {
try {
Thrower();
} catch (const ArbUt::Exception& e) {
REQUIRE(e.GetStacktrace(1) == "Stacktrace with depth 1: \n"
"ExceptionTests.cpp[11] Thrower()\n");
}
}
#endif