Merge pull request #718 from simdjson/jkeiser/cmake-werror
Treat warnings as errors
This commit is contained in:
commit
a8e892ba90
|
@ -19,7 +19,7 @@ build_script:
|
|||
- set
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DSIMDJSON_BUILD_STATIC=%SIMDJSON_BUILD_STATIC% -DSIMDJSON_ENABLE_THREADS=%SIMDJSON_ENABLE_THREADS% -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_GENERATOR_PLATFORM=x64 -DSIMDJSON_GOOGLE_BENCHMARKS=OFF ..
|
||||
- cmake -DSIMDJSON_BUILD_STATIC=%SIMDJSON_BUILD_STATIC% -DSIMDJSON_ENABLE_THREADS=%SIMDJSON_ENABLE_THREADS% -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_GENERATOR_PLATFORM=x64 ..
|
||||
- cmake -LH ..
|
||||
- cmake --build . --config %Configuration% --verbose
|
||||
|
||||
|
|
|
@ -51,10 +51,10 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|||
add_library(simdjson-flags INTERFACE)
|
||||
if(MSVC)
|
||||
target_compile_options(simdjson-flags INTERFACE /nologo /D_CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_options(simdjson-flags INTERFACE /W3 /wd4005 /wd4996 /wd4267 /wd4244 /wd4113)
|
||||
target_compile_options(simdjson-flags INTERFACE /WX /W3 /wd4005 /wd4996 /wd4267 /wd4244 /wd4113)
|
||||
else()
|
||||
target_compile_options(simdjson-flags INTERFACE -fPIC)
|
||||
target_compile_options(simdjson-flags INTERFACE -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self)
|
||||
target_compile_options(simdjson-flags INTERFACE -Werror -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self)
|
||||
endif()
|
||||
|
||||
# Optional flags
|
||||
|
|
|
@ -349,8 +349,8 @@ static void twitter_image_sizes(State& state) {
|
|||
auto [media, not_found] = tweet["entities"]["media"];
|
||||
if (!not_found) {
|
||||
for (dom::object image : media.get<dom::array>()) {
|
||||
for (auto [key, size] : image["sizes"].get<dom::object>()) {
|
||||
image_sizes.insert({ size["w"], size["h"] });
|
||||
for (auto size : image["sizes"].get<dom::object>()) {
|
||||
image_sizes.insert({ size.value["w"], size.value["h"] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -455,9 +455,9 @@ static void error_code_twitter_image_sizes(State& state) noexcept {
|
|||
for (dom::element image : images) {
|
||||
auto [sizes, error2] = image["sizes"].get<dom::object>();
|
||||
if (error2) { return; }
|
||||
for (auto [key, size] : sizes) {
|
||||
auto [width, error3] = size["w"].get<uint64_t>();
|
||||
auto [height, error4] = size["h"].get<uint64_t>();
|
||||
for (auto size : sizes) {
|
||||
auto [width, error3] = size.value["w"].get<uint64_t>();
|
||||
auto [height, error4] = size.value["h"].get<uint64_t>();
|
||||
if (error3 || error4) { return; }
|
||||
image_sizes.insert({ width, height });
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ static void parser_parse_error_code(State& state) {
|
|||
dom::parser parser;
|
||||
if (parser.allocate(EMPTY_ARRAY.length())) { return; }
|
||||
for (auto _ : state) {
|
||||
auto [doc, error] = parser.parse(EMPTY_ARRAY);
|
||||
auto error = parser.parse(EMPTY_ARRAY).error();
|
||||
if (error) { return; }
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ BENCHMARK(build_parsed_json);
|
|||
static void document_parse_error_code(State& state) {
|
||||
for (auto _ : state) {
|
||||
dom::parser parser;
|
||||
auto [doc, error] = parser.parse(EMPTY_ARRAY);
|
||||
auto error = parser.parse(EMPTY_ARRAY).error();
|
||||
if (error) { return; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,8 +135,6 @@ int main (int argc, char *argv[]){
|
|||
|
||||
}
|
||||
|
||||
std::min(res.begin(), res.end());
|
||||
|
||||
double min_result = *min_element(res.begin(), res.end());
|
||||
double speedinGBs = (p.size()) / (min_result * 1000000000.0);
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ void simdjson_recurse(stat_t &s, simdjson::dom::element element) {
|
|||
if (element.is<simdjson::dom::array>()) {
|
||||
s.array_count++;
|
||||
auto [array, array_error] = element.get<simdjson::dom::array>();
|
||||
if (array_error) { std::cerr << array_error << std::endl; abort(); }
|
||||
for (auto child : array) {
|
||||
if (child.is<simdjson::dom::array>() || child.is<simdjson::dom::object>()) {
|
||||
simdjson_recurse(s, child);
|
||||
|
@ -81,11 +82,12 @@ void simdjson_recurse(stat_t &s, simdjson::dom::element element) {
|
|||
} else if (element.is<simdjson::dom::object>()) {
|
||||
s.object_count++;
|
||||
auto [object, object_error] = element.get<simdjson::dom::object>();
|
||||
for (auto [key, value] : object) {
|
||||
if (value.is<simdjson::dom::array>() || value.is<simdjson::dom::object>()) {
|
||||
simdjson_recurse(s, value);
|
||||
if (object_error) { std::cerr << object_error << std::endl; abort(); }
|
||||
for (auto field : object) {
|
||||
if (field.value.is<simdjson::dom::array>() || field.value.is<simdjson::dom::object>()) {
|
||||
simdjson_recurse(s, field.value);
|
||||
} else {
|
||||
simdjson_process_atom(s, value);
|
||||
simdjson_process_atom(s, field.value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -255,7 +255,7 @@ bool bench(const char *filename, bool verbose, bool just_data, int repeat_multip
|
|||
std::fill(stats.begin(), stats.end(), 0); // unnecessary
|
||||
for (int i = 0; i < repeat; i++) {
|
||||
unified.start();
|
||||
auto [doc, parse_error] = parser.parse(p);
|
||||
auto parse_error = parser.parse(p).error();
|
||||
if (parse_error)
|
||||
printf("bug\n");
|
||||
unified.end(results);
|
||||
|
|
|
@ -69,6 +69,7 @@ void simdjson_recurse(stat_t &s, simdjson::dom::element element) {
|
|||
if (element.is<simdjson::dom::array>()) {
|
||||
s.array_count++;
|
||||
auto [array, array_error] = element.get<simdjson::dom::array>();
|
||||
if (array_error) { std::cerr << array_error << std::endl; abort(); }
|
||||
for (auto child : array) {
|
||||
if (child.is<simdjson::dom::array>() || child.is<simdjson::dom::object>()) {
|
||||
simdjson_recurse(s, child);
|
||||
|
@ -79,12 +80,13 @@ void simdjson_recurse(stat_t &s, simdjson::dom::element element) {
|
|||
} else if (element.is<simdjson::dom::object>()) {
|
||||
s.object_count++;
|
||||
auto [object, object_error] = element.get<simdjson::dom::object>();
|
||||
for (auto [key, value] : object) {
|
||||
if (object_error) { std::cerr << object_error << std::endl; abort(); }
|
||||
for (auto field : object) {
|
||||
s.string_count++; // for key
|
||||
if (value.is<simdjson::dom::array>() || value.is<simdjson::dom::object>()) {
|
||||
simdjson_recurse(s, value);
|
||||
if (field.value.is<simdjson::dom::array>() || field.value.is<simdjson::dom::object>()) {
|
||||
simdjson_recurse(s, field.value);
|
||||
} else {
|
||||
simdjson_process_atom(s, value);
|
||||
simdjson_process_atom(s, field.value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -127,6 +127,7 @@ nicely with C++17's destructuring syntax. For example:
|
|||
dom::parser parser;
|
||||
padded_string json = R"( { "foo": 1, "bar": 2 } )"_padded;
|
||||
auto [object, error] = parser.parse(json).get<dom::object>();
|
||||
if (error) { cerr << error << endl; return; }
|
||||
for (auto [key, value] : object) {
|
||||
cout << key << " = " << value << endl;
|
||||
}
|
||||
|
|
|
@ -106,10 +106,12 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
|||
#define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wall) \
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wattributes) \
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) \
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type)
|
||||
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable)
|
||||
#define SIMDJSON_PRAGMA(P) _Pragma(#P)
|
||||
#define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
|
||||
#define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_GCC_WARNING(-Wdeprecated-declarations)
|
||||
|
|
|
@ -793,7 +793,7 @@ inline simdjson_result<int64_t> element::get<int64_t>() const noexcept {
|
|||
if(is_uint64()) {
|
||||
uint64_t result = next_tape_value<uint64_t>();
|
||||
// Wrapping max in parens to handle Windows issue: https://stackoverflow.com/questions/11544073/how-do-i-deal-with-the-max-macro-in-windows-h-colliding-with-max-in-std
|
||||
if (result > (std::numeric_limits<int64_t>::max)()) {
|
||||
if (result > uint64_t((std::numeric_limits<int64_t>::max)())) {
|
||||
return NUMBER_OUT_OF_RANGE;
|
||||
}
|
||||
return static_cast<int64_t>(result);
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
namespace simdjson {
|
||||
namespace arm64 {
|
||||
|
||||
NO_SANITIZE_UNDEFINED
|
||||
// We sometimes call trailing_zero on inputs that are zero,
|
||||
// but the algorithms do not end up using the returned value.
|
||||
// Sadly, sanitizers are not smart enough to figure it out.
|
||||
NO_SANITIZE_UNDEFINED
|
||||
really_inline int trailing_zeroes(uint64_t input_num) {
|
||||
#ifdef _MSC_VER
|
||||
unsigned long ret;
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace atomparsing {
|
|||
really_inline uint32_t string_to_uint32(const char* str) { return *reinterpret_cast<const uint32_t *>(str); }
|
||||
|
||||
WARN_UNUSED
|
||||
really_inline bool str4ncmp(const uint8_t *src, const char* atom) {
|
||||
really_inline uint32_t str4ncmp(const uint8_t *src, const char* atom) {
|
||||
uint32_t srcval; // we want to avoid unaligned 64-bit loads (undefined in C/C++)
|
||||
static_assert(sizeof(uint32_t) <= SIMDJSON_PADDING, "SIMDJSON_PADDING must be larger than 4 bytes");
|
||||
std::memcpy(&srcval, src, sizeof(uint32_t));
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace westmere {
|
|||
|
||||
// We sometimes call trailing_zero on inputs that are zero,
|
||||
// but the algorithms do not end up using the returned value.
|
||||
// Sadly, sanitizers are not smart enough to figure it out.
|
||||
// Sadly, sanitizers are not smart enough to figure it out.
|
||||
NO_SANITIZE_UNDEFINED
|
||||
really_inline int trailing_zeroes(uint64_t input_num) {
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
|
|||
std::cout << std::endl;
|
||||
}
|
||||
simdjson::dom::parser parser;
|
||||
auto [doc, err] = parser.parse(p);
|
||||
auto err = parser.parse(p).error();
|
||||
|
||||
rapidjson::Document d;
|
||||
|
||||
|
|
|
@ -54,18 +54,14 @@ namespace number_tests {
|
|||
|
||||
bool small_integers() {
|
||||
std::cout << __func__ << std::endl;
|
||||
char buf[1024];
|
||||
simdjson::dom::parser parser;
|
||||
for (int m = 10; m < 20; m++) {
|
||||
for (int i = -1024; i < 1024; i++) {
|
||||
auto n = sprintf(buf, "%*d", m, i);
|
||||
buf[n] = '\0';
|
||||
fflush(NULL);
|
||||
|
||||
auto [actual, error] = parser.parse(buf, n).get<int64_t>();
|
||||
auto str = std::to_string(i);
|
||||
auto [actual, error] = parser.parse(str).get<int64_t>();
|
||||
if (error) { std::cerr << error << std::endl; return false; }
|
||||
if (actual != i) {
|
||||
std::cerr << "JSON '" << buf << " parsed to " << actual << " instead of " << i << std::endl;
|
||||
std::cerr << "JSON '" << str << "' parsed to " << actual << " instead of " << i << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +198,7 @@ namespace document_tests {
|
|||
std::cout << __func__ << std::endl;
|
||||
simdjson::padded_string badjson = "[7,7,7,7,6,7,7,7,6,7,7,6,[7,7,7,7,6,7,7,7,6,7,7,6,7,7,7,7,7,7,6"_padded;
|
||||
simdjson::dom::parser parser;
|
||||
auto [doc, error] = parser.parse(badjson);
|
||||
auto error = parser.parse(badjson).error();
|
||||
if (!error) {
|
||||
printf("This json should not be valid %s.\n", badjson.data());
|
||||
return false;
|
||||
|
@ -313,16 +309,16 @@ namespace document_tests {
|
|||
fflush(NULL);
|
||||
}
|
||||
counter++;
|
||||
auto [doc1, res1] = parser.parse(rec.c_str(), rec.length());
|
||||
if (res1 != simdjson::error_code::SUCCESS) {
|
||||
auto error = parser.parse(rec.c_str(), rec.length()).error();
|
||||
if (error != simdjson::error_code::SUCCESS) {
|
||||
printf("Something is wrong in skyprophet_test: %s.\n", rec.c_str());
|
||||
printf("Parsing failed. Error is %s\n", simdjson::error_message(res1));
|
||||
printf("Parsing failed. Error is %s\n", simdjson::error_message(error));
|
||||
return false;
|
||||
}
|
||||
auto [doc2, res2] = parser.parse(rec.c_str(), rec.length());
|
||||
if (res2 != simdjson::error_code::SUCCESS) {
|
||||
error = parser.parse(rec.c_str(), rec.length()).error();
|
||||
if (error != simdjson::error_code::SUCCESS) {
|
||||
printf("Something is wrong in skyprophet_test: %s.\n", rec.c_str());
|
||||
printf("Parsing failed. Error is %s\n", simdjson::error_message(res2));
|
||||
printf("Parsing failed. Error is %s\n", simdjson::error_message(error));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +334,7 @@ namespace document_tests {
|
|||
input += "]";
|
||||
}
|
||||
simdjson::dom::parser parser;
|
||||
auto [doc, error] = parser.parse(input);
|
||||
auto error = parser.parse(input).error();
|
||||
if (error) { std::cerr << "Error: " << simdjson::error_message(error) << std::endl; return false; }
|
||||
return true;
|
||||
}
|
||||
|
@ -353,7 +349,6 @@ namespace document_tests {
|
|||
}
|
||||
|
||||
namespace document_stream_tests {
|
||||
|
||||
static simdjson::dom::document_stream parse_many_stream_return(simdjson::dom::parser &parser, simdjson::padded_string &str) {
|
||||
return parser.parse_many(str);
|
||||
}
|
||||
|
@ -367,9 +362,9 @@ namespace document_stream_tests {
|
|||
static bool parse_json_message_issue467(simdjson::padded_string &json, size_t expectedcount) {
|
||||
simdjson::dom::parser parser;
|
||||
size_t count = 0;
|
||||
for (auto [doc, error] : parser.parse_many(json)) {
|
||||
if (error) {
|
||||
std::cerr << "Failed with simdjson error= " << error << std::endl;
|
||||
for (auto doc : parser.parse_many(json)) {
|
||||
if (doc.error()) {
|
||||
std::cerr << "Failed with simdjson error= " << doc.error() << std::endl;
|
||||
return false;
|
||||
}
|
||||
count++;
|
||||
|
@ -973,11 +968,11 @@ namespace dom_api_tests {
|
|||
object sizes;
|
||||
image["sizes"].get<dom::object>().tie(sizes, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0;
|
||||
if (error) { cerr << "Error: " << error << endl; return false; }
|
||||
for (auto [key, size] : sizes) {
|
||||
for (auto size : sizes) {
|
||||
uint64_t width, height;
|
||||
size["w"].get<uint64_t>().tie(width, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0;
|
||||
size.value["w"].get<uint64_t>().tie(width, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0;
|
||||
if (error) { cerr << "Error: " << error << endl; return false; }
|
||||
size["h"].get<uint64_t>().tie(height, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0;
|
||||
size.value["h"].get<uint64_t>().tie(height, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0;
|
||||
if (error) { cerr << "Error: " << error << endl; return false; }
|
||||
image_sizes.insert(make_pair(width, height));
|
||||
}
|
||||
|
@ -1134,8 +1129,8 @@ namespace dom_api_tests {
|
|||
auto [media, not_found] = tweet["entities"]["media"];
|
||||
if (!not_found) {
|
||||
for (object image : media.get<dom::array>()) {
|
||||
for (auto [key, size] : image["sizes"].get<dom::object>()) {
|
||||
image_sizes.insert(make_pair(size["w"], size["h"]));
|
||||
for (auto size : image["sizes"].get<dom::object>()) {
|
||||
image_sizes.insert(make_pair(size.value["w"], size.value["h"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1712,6 +1707,7 @@ namespace format_tests {
|
|||
std::cout << "Running " << __func__ << std::endl;
|
||||
dom::parser parser;
|
||||
auto [value, error] = parser.parse(DOCUMENT)["foo"];
|
||||
if (error) { cerr << error << endl; return false; }
|
||||
ostringstream s;
|
||||
s << value;
|
||||
return assert_minified(s, "1");
|
||||
|
@ -1720,6 +1716,7 @@ namespace format_tests {
|
|||
std::cout << "Running " << __func__ << std::endl;
|
||||
dom::parser parser;
|
||||
auto [value, error] = parser.parse(DOCUMENT)["foo"];
|
||||
if (error) { cerr << error << endl; return false; }
|
||||
ostringstream s;
|
||||
s << minify(value);
|
||||
return assert_minified(s, "1");
|
||||
|
@ -1729,6 +1726,7 @@ namespace format_tests {
|
|||
std::cout << "Running " << __func__ << std::endl;
|
||||
dom::parser parser;
|
||||
auto [value, error] = parser.parse(DOCUMENT)["bar"].get<dom::array>();
|
||||
if (error) { cerr << error << endl; return false; }
|
||||
ostringstream s;
|
||||
s << value;
|
||||
return assert_minified(s, "[1,2,3]");
|
||||
|
@ -1737,6 +1735,7 @@ namespace format_tests {
|
|||
std::cout << "Running " << __func__ << std::endl;
|
||||
dom::parser parser;
|
||||
auto [value, error] = parser.parse(DOCUMENT)["bar"].get<dom::array>();
|
||||
if (error) { cerr << error << endl; return false; }
|
||||
ostringstream s;
|
||||
s << minify(value);
|
||||
return assert_minified(s, "[1,2,3]");
|
||||
|
@ -1746,6 +1745,7 @@ namespace format_tests {
|
|||
std::cout << "Running " << __func__ << std::endl;
|
||||
dom::parser parser;
|
||||
auto [value, error] = parser.parse(DOCUMENT)["baz"].get<dom::object>();
|
||||
if (error) { cerr << error << endl; return false; }
|
||||
ostringstream s;
|
||||
s << value;
|
||||
return assert_minified(s, R"({"a":1,"b":2,"c":3})");
|
||||
|
@ -1754,6 +1754,7 @@ namespace format_tests {
|
|||
std::cout << "Running " << __func__ << std::endl;
|
||||
dom::parser parser;
|
||||
auto [value, error] = parser.parse(DOCUMENT)["baz"].get<dom::object>();
|
||||
if (error) { cerr << error << endl; return false; }
|
||||
ostringstream s;
|
||||
s << minify(value);
|
||||
return assert_minified(s, R"({"a":1,"b":2,"c":3})");
|
||||
|
|
|
@ -28,15 +28,15 @@ namespace parser_load {
|
|||
bool parser_load_capacity() {
|
||||
TEST_START();
|
||||
dom::parser parser(1); // 1 byte max capacity
|
||||
auto [doc, error] = parser.load(TWITTER_JSON);
|
||||
auto error = parser.load(TWITTER_JSON).error();
|
||||
ASSERT_ERROR(error, CAPACITY);
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
bool parser_load_many_capacity() {
|
||||
TEST_START();
|
||||
dom::parser parser(1); // 1 byte max capacity
|
||||
for (auto [doc, error] : parser.load_many(TWITTER_JSON)) {
|
||||
ASSERT_ERROR(error, CAPACITY);
|
||||
for (auto doc : parser.load_many(TWITTER_JSON)) {
|
||||
ASSERT_ERROR(doc.error(), CAPACITY);
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
TEST_FAIL("No documents returned");
|
||||
|
@ -45,22 +45,22 @@ namespace parser_load {
|
|||
bool parser_load_nonexistent() {
|
||||
TEST_START();
|
||||
dom::parser parser;
|
||||
auto [doc, error] = parser.load(NONEXISTENT_FILE);
|
||||
auto error = parser.load(NONEXISTENT_FILE).error();
|
||||
ASSERT_ERROR(error, IO_ERROR);
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
bool parser_load_many_nonexistent() {
|
||||
TEST_START();
|
||||
dom::parser parser;
|
||||
for (auto [doc, error] : parser.load_many(NONEXISTENT_FILE)) {
|
||||
ASSERT_ERROR(error, IO_ERROR);
|
||||
for (auto doc : parser.load_many(NONEXISTENT_FILE)) {
|
||||
ASSERT_ERROR(doc.error(), IO_ERROR);
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
TEST_FAIL("No documents returned");
|
||||
}
|
||||
bool padded_string_load_nonexistent() {
|
||||
TEST_START();
|
||||
auto [str, error] = padded_string::load(NONEXISTENT_FILE);
|
||||
auto error = padded_string::load(NONEXISTENT_FILE).error();
|
||||
ASSERT_ERROR(error, IO_ERROR);
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace parser_load {
|
|||
bool parser_load_chain() {
|
||||
TEST_START();
|
||||
dom::parser parser;
|
||||
auto [val, error] = parser.load(NONEXISTENT_FILE)["foo"].get<uint64_t>();
|
||||
auto error = parser.load(NONEXISTENT_FILE)["foo"].get<uint64_t>().error();
|
||||
ASSERT_ERROR(error, IO_ERROR);
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace parser_load {
|
|||
TEST_START();
|
||||
dom::parser parser;
|
||||
for (auto doc : parser.load_many(NONEXISTENT_FILE)) {
|
||||
auto [val, error] = doc["foo"].get<uint64_t>();
|
||||
auto error = doc["foo"].get<uint64_t>().error();
|
||||
ASSERT_ERROR(error, IO_ERROR);
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ bool validate(const char *dirname) {
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
simdjson::dom::parser parser;
|
||||
auto [doc, errorcode] = parser.parse(p);
|
||||
auto errorcode = parser.parse(p).error();
|
||||
++how_many;
|
||||
printf("%s\n", errorcode == simdjson::error_code::SUCCESS ? "ok" : "invalid");
|
||||
if (contains("EXCLUDE", name)) {
|
||||
|
|
|
@ -179,7 +179,7 @@ bool validate(const char *dirname) {
|
|||
invalid_count = 0;
|
||||
total_count += float_count + int_count + invalid_count;
|
||||
simdjson::dom::parser parser;
|
||||
auto [doc, err] = parser.parse(p);
|
||||
auto err = parser.parse(p).error();
|
||||
bool isok = (err == simdjson::error_code::SUCCESS);
|
||||
if (int_count + float_count + invalid_count > 0) {
|
||||
printf("File %40s %s --- integers: %10zu floats: %10zu invalid: %10zu "
|
||||
|
|
|
@ -44,7 +44,7 @@ bool json_pointer_success_test(const char *json_pointer, std::string_view expect
|
|||
bool json_pointer_success_test(const char *json_pointer) {
|
||||
std::cout << "Running successful JSON pointer test '" << json_pointer << "' ..." << std::endl;
|
||||
dom::parser parser;
|
||||
auto [value, error] = parser.parse(TEST_JSON).at(json_pointer);
|
||||
auto error = parser.parse(TEST_JSON).at(json_pointer).error();
|
||||
if (error) { std::cerr << "Unexpected Error: " << error << std::endl; return false; }
|
||||
return true;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ bool json_pointer_success_test(const char *json_pointer) {
|
|||
bool json_pointer_failure_test(const char *json_pointer, error_code expected_failure_test) {
|
||||
std::cout << "Running invalid JSON pointer test '" << json_pointer << "' ..." << std::endl;
|
||||
dom::parser parser;
|
||||
auto [value, error] = parser.parse(TEST_JSON).at(json_pointer);
|
||||
auto error = parser.parse(TEST_JSON).at(json_pointer).error();
|
||||
ASSERT(error == expected_failure_test);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ void basics_cpp17_1() {
|
|||
dom::parser parser;
|
||||
padded_string json = R"( { "foo": 1, "bar": 2 } )"_padded;
|
||||
auto [object, error] = parser.parse(json).get<dom::object>();
|
||||
if (error) { cerr << error << endl; return; }
|
||||
for (auto [key, value] : object) {
|
||||
cout << key << " = " << value << endl;
|
||||
}
|
||||
|
@ -180,6 +181,7 @@ void performance_1() {
|
|||
}
|
||||
|
||||
#ifdef SIMDJSON_CPLUSPLUS17
|
||||
SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
|
||||
// The web_request part of this is aspirational, so we compile as much as we can here
|
||||
void performance_2() {
|
||||
dom::parser parser(1024*1024); // Never grow past documents > 1MB
|
||||
|
@ -204,6 +206,7 @@ void performance_3() {
|
|||
// ...
|
||||
// }
|
||||
}
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
|
|
|
@ -5,6 +5,7 @@ using namespace std;
|
|||
using namespace simdjson;
|
||||
|
||||
#ifdef SIMDJSON_CPLUSPLUS17
|
||||
SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
|
||||
void basics_error_1() {
|
||||
dom::parser parser;
|
||||
auto json = "1"_padded;
|
||||
|
@ -13,6 +14,7 @@ void basics_error_1() {
|
|||
if (error) { cerr << error << endl; exit(1); }
|
||||
// Use document here now that we've checked for the error
|
||||
}
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
#endif
|
||||
|
||||
void basics_error_2() {
|
||||
|
|
|
@ -348,7 +348,7 @@ bool validate(const char *dirname) {
|
|||
total_string_length = 0;
|
||||
empty_string = 0;
|
||||
simdjson::dom::parser parser;
|
||||
auto [doc, err] = parser.parse(p);
|
||||
auto err = parser.parse(p).error();
|
||||
bool isok = (err == simdjson::error_code::SUCCESS);
|
||||
free(big_buffer);
|
||||
if (good_string > 0) {
|
||||
|
|
Loading…
Reference in New Issue