37#include <gtest/gtest.h>
45#if defined(_MSC_VER) && !defined(__clang__)
47# pragma warning(disable : 4996)
49# pragma GCC diagnostic push
50# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
60 void expect_the_exception(const
char * name, const
std::
string & category)
62 const size_t line = __LINE__ + 3;
69 EXPECT_NE(
dynamic_cast<const E *
>(&e),
nullptr) << name;
72 EXPECT_EQ(e.
type,
"E") << name;
73 EXPECT_EQ(std::string(e.what()),
74 category +
"|" + __FILE__ +
"|" + std::to_string(line)
75 +
"|E|the message") << name;
78 ADD_FAILURE() << name <<
" was not caught as an AlephException";
83#define EXPECT_THE_EXCEPTION(E, category) \
84 expect_the_exception<E>(#E, #category)
89TEST(AlephExceptions, EachIsAnAlephExceptionWithItsCategory)
92 "minimum value is greater than maximum value");
101 "Please send a bug report to leandro.r.leon@gmail.com");
116TEST(AlephExceptions, DefineAlephExceptionDefinesOne)
120 EXPECT_THROW(
ALEPHTHROW(MyAlephError,
"m"), std::runtime_error);
123#undef EXPECT_THE_EXCEPTION
125#if defined(_MSC_VER) && !defined(__clang__)
128# pragma GCC diagnostic pop
Custom exception classes with source location tracking.
#define DEFINE_ALEPH_EXCEPTION(name, category_msg)
Define a new exception.
#define ALEPHTHROW(type, msg)
Macro for throwing an aleph exception.
#define EXPECT_THE_EXCEPTION(E, category)
const std::string file_name
file name where the exception was thrown
const size_t line_number
Line number of source file where the exception was thrown.