Skip to content
Snippets Groups Projects
Commit b2f50e2c authored by Daniel Hornung's avatar Daniel Hornung
Browse files

ENH: New GTest macro, fixed typo.

parent 4796d431
No related branches found
No related tags found
2 merge requests!14ENH: New functions getEnumNameFromValue() and getEnumValueFromName(),!12F consolidation
...@@ -29,20 +29,38 @@ ...@@ -29,20 +29,38 @@
* @author Timm Fitschen * @author Timm Fitschen
* @date 2021-07-07 * @date 2021-07-07
*/ */
#define EXPECT_THROW_MESSAGE(statement, exeption_type, message) \ #define EXPECT_THROW_MESSAGE(statement, exception_type, message) \
EXPECT_THROW( \ EXPECT_THROW( \
try { statement; } catch (const exeption_type &e) { \ try { statement; } catch (const exception_type &e) { \
EXPECT_EQ(std::string(e.what()), message); \ EXPECT_EQ(std::string(e.what()), message); \
throw; \ throw; \
}, \ }, \
exeption_type) exception_type)
#define ASSERT_THROW_MESSAGE(statement, exeption_type, message) \ #define ASSERT_THROW_MESSAGE(statement, exception_type, message) \
ASSERT_THROW( \ ASSERT_THROW( \
try { statement; } catch (const exeption_type &e) { \ try { statement; } catch (const exception_type &e) { \
ASSERT_EQ(std::string(e.what()), message); \ ASSERT_EQ(std::string(e.what()), message); \
throw; \ throw; \
}, \ }, \
exeption_type) exception_type)
#define EXPECT_THROW_STARTS_WITH(statement, exception_type, pattern) \
EXPECT_THROW( \
try { statement; } catch (const exception_type &e) { \
auto pat_s = std::string(pattern); \
EXPECT_EQ(std::string(e.what()).substr(0, pat_s.size()), \
pat_s); \
throw; \
}, \
exception_type)
#define ASSERT_THROW_STARTS_WITH(statement, exception_type, message) \
ASSERT_THROW( \
try { statement; } catch (const exception_type &e) { \
auto pat_s = std::string(pattern); \
ASSERT_EQ(std::string(e.what()).substr(0, pat_s.size()), \
pat_s); \
throw; \
}, \
exception_type)
#define EXPECT_NULL(statement) \ #define EXPECT_NULL(statement) \
if (statement != nullptr) { \ if (statement != nullptr) { \
FAIL() << "Should be a nullptr"; \ FAIL() << "Should be a nullptr"; \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment