mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 07:14:45 +02:00
add tests to check that exceptions are thrown for wrong types
* Add JSONTEST_ASSERT_THROWS macro to test if an expression throws an exceptions. * add JSONTEST_FIXTURE(ValueTest, typeChecksThrowExceptions)
This commit is contained in:

committed by
Christopher Dunn

parent
7ebdabc059
commit
97c77b4a86
@@ -241,6 +241,20 @@ TestResult &checkStringEqual(TestResult &result,
|
||||
__LINE__, \
|
||||
#expected " == " #actual)
|
||||
|
||||
/// \brief Asserts that a given expression throws an exception
|
||||
#define JSONTEST_ASSERT_THROWS(expr) \
|
||||
{ \
|
||||
bool _threw = false; \
|
||||
try { \
|
||||
expr; \
|
||||
} catch (...) { \
|
||||
_threw = true; \
|
||||
} \
|
||||
if (!_threw) \
|
||||
result_->addFailure(__FILE__, __LINE__, \
|
||||
"expected exception thrown: " #expr); \
|
||||
}
|
||||
|
||||
/// \brief Begin a fixture test case.
|
||||
#define JSONTEST_FIXTURE(FixtureType, name) \
|
||||
class Test##FixtureType##name : public FixtureType { \
|
||||
|
Reference in New Issue
Block a user