MarkOates / blast

0 stars 0 forks source link

Include Base Class Headers in Generated Derived Classes #7

Closed MarkOates closed 6 years ago

MarkOates commented 6 years ago

Now Including Derived Includes

Generated classes have parent classes https://github.com/MarkOates/blast/pull/6, however, their dependent #include header files are needed as well. This PR adds that feature and includes them when they are detected, or raises an exception if a dependency definition is not present.

New Testing Macro

✨ Also ✨, new to any of my projects, is this convenient testing macro that checks that 1) an error is thrown 2) with the expected message. The macro looks like this:

#define ASSERT_THROW_WITH_MESSAGE(code, raised_exception_type, raised_exception_message) \
  try { code; FAIL() << "Expected " # raised_exception_type; } \
  catch ( raised_exception_type const &err ) { EXPECT_EQ(err.what(), std::string( raised_exception_message )); } \
  catch (...) { FAIL() << "Expected " # raised_exception_type; }

Usage might look something like this:

ASSERT_THROW_WITH_MESSAGE(Foo.some_func(-9999), std::runtime_error, "Assigned value out of allowed range");