mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-08-04 10:36:23 -04:00
Merge 8751d1528ec530d00d2d7617d42581ddfb4ca771 into ca98c98457b1163cca1f7d8db62827c115fec6d1
This commit is contained in:
commit
f16ff00c60
33
BUILD.bazel
33
BUILD.bazel
@ -1,7 +1,29 @@
|
|||||||
licenses(["unencumbered"]) # Public Domain or MIT
|
licenses(["unencumbered"]) # Public Domain or MIT
|
||||||
|
|
||||||
|
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
|
||||||
|
|
||||||
exports_files(["LICENSE"])
|
exports_files(["LICENSE"])
|
||||||
|
|
||||||
|
bool_flag(
|
||||||
|
name = "use_exception",
|
||||||
|
build_setting_default = False,
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "use_exception_cfg",
|
||||||
|
flag_values = {":use_exception": "true"},
|
||||||
|
)
|
||||||
|
|
||||||
|
bool_flag(
|
||||||
|
name = "has_int64",
|
||||||
|
build_setting_default = True,
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "has_int64_cfg",
|
||||||
|
flag_values = {":has_int64": "true"},
|
||||||
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "jsoncpp",
|
name = "jsoncpp",
|
||||||
srcs = [
|
srcs = [
|
||||||
@ -22,10 +44,13 @@ cc_library(
|
|||||||
"include/json/version.h",
|
"include/json/version.h",
|
||||||
"include/json/writer.h",
|
"include/json/writer.h",
|
||||||
],
|
],
|
||||||
copts = [
|
defines = select({
|
||||||
"-DJSON_USE_EXCEPTION=0",
|
":use_exception_cfg": ["JSON_USE_EXCEPTION=1"],
|
||||||
"-DJSON_HAS_INT64",
|
"//conditions:default": ["JSON_USE_EXCEPTION=0"],
|
||||||
],
|
}) + select({
|
||||||
|
":has_int64_cfg": ["JSON_HAS_INT64"],
|
||||||
|
"//conditions:default": [],
|
||||||
|
}),
|
||||||
includes = ["include"],
|
includes = ["include"],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [":private"],
|
deps = [":private"],
|
||||||
|
@ -12,3 +12,8 @@ module(
|
|||||||
version = "1.9.7",
|
version = "1.9.7",
|
||||||
compatibility_level = 1,
|
compatibility_level = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
bazel_dep(
|
||||||
|
name = "bazel_skylib",
|
||||||
|
version = "1.7.1",
|
||||||
|
)
|
||||||
|
@ -11,10 +11,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Json {
|
|
||||||
class Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
Json::CharReaderBuilder builder;
|
Json::CharReaderBuilder builder;
|
||||||
|
|
||||||
@ -45,10 +41,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||||||
|
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
const auto data_str = reinterpret_cast<const char*>(data);
|
const auto data_str = reinterpret_cast<const char*>(data);
|
||||||
|
#if JSON_USE_EXCEPTION
|
||||||
try {
|
try {
|
||||||
|
#endif // JSON_USE_EXCEPTION
|
||||||
reader->parse(data_str, data_str + size, &root, nullptr);
|
reader->parse(data_str, data_str + size, &root, nullptr);
|
||||||
|
#if JSON_USE_EXCEPTION
|
||||||
} catch (Json::Exception const&) {
|
} catch (Json::Exception const&) {
|
||||||
}
|
}
|
||||||
|
#endif // JSON_USE_EXCEPTION
|
||||||
// Whether it succeeded or not doesn't matter.
|
// Whether it succeeded or not doesn't matter.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,8 @@ TestResult& checkStringEqual(TestResult& result, const Json::String& expected,
|
|||||||
JsonTest::ToJsonString(actual), __FILE__, \
|
JsonTest::ToJsonString(actual), __FILE__, \
|
||||||
__LINE__, #expected " == " #actual)
|
__LINE__, #expected " == " #actual)
|
||||||
|
|
||||||
|
#if JSON_USE_EXCEPTION
|
||||||
|
|
||||||
/// \brief Asserts that a given expression throws an exception
|
/// \brief Asserts that a given expression throws an exception
|
||||||
#define JSONTEST_ASSERT_THROWS(expr) \
|
#define JSONTEST_ASSERT_THROWS(expr) \
|
||||||
do { \
|
do { \
|
||||||
@ -242,6 +244,8 @@ TestResult& checkStringEqual(TestResult& result, const Json::String& expected,
|
|||||||
"expected exception thrown: " #expr); \
|
"expected exception thrown: " #expr); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#endif // JSON_USE_EXCEPTION
|
||||||
|
|
||||||
/// \brief Begin a fixture test case.
|
/// \brief Begin a fixture test case.
|
||||||
#define JSONTEST_FIXTURE(FixtureType, name) \
|
#define JSONTEST_FIXTURE(FixtureType, name) \
|
||||||
class Test##FixtureType##name : public FixtureType { \
|
class Test##FixtureType##name : public FixtureType { \
|
||||||
|
@ -1888,7 +1888,7 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, typeChecksThrowExceptions) {
|
|||||||
JSONTEST_ASSERT_THROWS(objVal.asBool());
|
JSONTEST_ASSERT_THROWS(objVal.asBool());
|
||||||
JSONTEST_ASSERT_THROWS(arrVal.asBool());
|
JSONTEST_ASSERT_THROWS(arrVal.asBool());
|
||||||
|
|
||||||
#endif
|
#endif // JSON_USE_EXCEPTION
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONTEST_FIXTURE_LOCAL(ValueTest, offsetAccessors) {
|
JSONTEST_FIXTURE_LOCAL(ValueTest, offsetAccessors) {
|
||||||
@ -3323,6 +3323,8 @@ JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithDetailError) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithStackLimit) {
|
JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithStackLimit) {
|
||||||
|
#if JSON_USE_EXCEPTION
|
||||||
|
|
||||||
Json::CharReaderBuilder b;
|
Json::CharReaderBuilder b;
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
char const doc[] = R"({ "property" : "value" })";
|
char const doc[] = R"({ "property" : "value" })";
|
||||||
@ -3342,6 +3344,8 @@ JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithStackLimit) {
|
|||||||
JSONTEST_ASSERT_THROWS(
|
JSONTEST_ASSERT_THROWS(
|
||||||
reader->parse(doc, doc + std::strlen(doc), &root, &errs));
|
reader->parse(doc, doc + std::strlen(doc), &root, &errs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // JSON_USE_EXCEPTION
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONTEST_FIXTURE_LOCAL(CharReaderTest, testOperator) {
|
JSONTEST_FIXTURE_LOCAL(CharReaderTest, testOperator) {
|
||||||
@ -3961,6 +3965,8 @@ JSONTEST_FIXTURE_LOCAL(IteratorTest, indexes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSONTEST_FIXTURE_LOCAL(IteratorTest, constness) {
|
JSONTEST_FIXTURE_LOCAL(IteratorTest, constness) {
|
||||||
|
#if JSON_USE_EXCEPTION
|
||||||
|
|
||||||
Json::Value const v;
|
Json::Value const v;
|
||||||
JSONTEST_ASSERT_THROWS(
|
JSONTEST_ASSERT_THROWS(
|
||||||
Json::Value::iterator it(v.begin())); // Compile, but throw.
|
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",)";
|
Json::String expected = R"(" 9","10","11",)";
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, out.str());
|
JSONTEST_ASSERT_STRING_EQUAL(expected, out.str());
|
||||||
|
|
||||||
|
#endif // JSON_USE_EXCEPTION
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RValueTest : JsonTest::TestCase {};
|
struct RValueTest : JsonTest::TestCase {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user