CreatureLib/tests/ExceptionTests.cpp

18 lines
479 B
C++
Raw Normal View History

#ifdef TESTS_BUILD
#include <cstring>
#include "../extern/catch.hpp"
#include "../src/Library/Exceptions/CreatureException.hpp"
TEST_CASE("When throwing exception, what() is readable", "[Utilities]") {
bool hasCaught = false;
try {
2020-07-26 15:41:11 +00:00
THROW_CREATURE("foobar");
} catch (const std::exception& e) {
hasCaught = true;
INFO(e.what());
2020-07-26 15:41:11 +00:00
REQUIRE(std::string(e.what()) == "[ExceptionTests.cpp:9] foobar");
}
REQUIRE(hasCaught);
}
#endif