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