mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-08-04 10:36:23 -04:00
#ifdef stuff that should only be used with JSON_USE_EXCEPTION.
This commit is contained in:
parent
1ecfc091f7
commit
8751d1528e
@ -228,6 +228,8 @@ TestResult& checkStringEqual(TestResult& result, const Json::String& expected,
|
||||
JsonTest::ToJsonString(actual), __FILE__, \
|
||||
__LINE__, #expected " == " #actual)
|
||||
|
||||
#if JSON_USE_EXCEPTION
|
||||
|
||||
/// \brief Asserts that a given expression throws an exception
|
||||
#define JSONTEST_ASSERT_THROWS(expr) \
|
||||
do { \
|
||||
@ -242,6 +244,8 @@ TestResult& checkStringEqual(TestResult& result, const Json::String& expected,
|
||||
"expected exception thrown: " #expr); \
|
||||
} while (0)
|
||||
|
||||
#endif // JSON_USE_EXCEPTION
|
||||
|
||||
/// \brief Begin a fixture test case.
|
||||
#define JSONTEST_FIXTURE(FixtureType, name) \
|
||||
class Test##FixtureType##name : public FixtureType { \
|
||||
|
@ -1888,7 +1888,7 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, typeChecksThrowExceptions) {
|
||||
JSONTEST_ASSERT_THROWS(objVal.asBool());
|
||||
JSONTEST_ASSERT_THROWS(arrVal.asBool());
|
||||
|
||||
#endif
|
||||
#endif // JSON_USE_EXCEPTION
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE_LOCAL(ValueTest, offsetAccessors) {
|
||||
@ -3323,6 +3323,8 @@ JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithDetailError) {
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithStackLimit) {
|
||||
#if JSON_USE_EXCEPTION
|
||||
|
||||
Json::CharReaderBuilder b;
|
||||
Json::Value root;
|
||||
char const doc[] = R"({ "property" : "value" })";
|
||||
@ -3342,6 +3344,8 @@ JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithStackLimit) {
|
||||
JSONTEST_ASSERT_THROWS(
|
||||
reader->parse(doc, doc + std::strlen(doc), &root, &errs));
|
||||
}
|
||||
|
||||
#endif // JSON_USE_EXCEPTION
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE_LOCAL(CharReaderTest, testOperator) {
|
||||
@ -3961,6 +3965,8 @@ JSONTEST_FIXTURE_LOCAL(IteratorTest, indexes) {
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE_LOCAL(IteratorTest, constness) {
|
||||
#if JSON_USE_EXCEPTION
|
||||
|
||||
Json::Value const v;
|
||||
JSONTEST_ASSERT_THROWS(
|
||||
Json::Value::iterator it(v.begin())); // Compile, but throw.
|
||||
@ -3982,6 +3988,8 @@ JSONTEST_FIXTURE_LOCAL(IteratorTest, constness) {
|
||||
}
|
||||
Json::String expected = R"(" 9","10","11",)";
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, out.str());
|
||||
|
||||
#endif // JSON_USE_EXCEPTION
|
||||
}
|
||||
|
||||
struct RValueTest : JsonTest::TestCase {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user