diff --git a/singleheader/simdjson.cpp b/singleheader/simdjson.cpp index 819942e82..97ec9ee7a 100644 --- a/singleheader/simdjson.cpp +++ b/singleheader/simdjson.cpp @@ -1,4 +1,4 @@ -/* auto-generated on 2025-06-04 00:22:10 -0400. Do not edit! */ +/* auto-generated on 2025-06-24 15:13:44 -0400. Do not edit! */ /* including simdjson.cpp: */ /* begin file simdjson.cpp */ #define SIMDJSON_SRC_SIMDJSON_CPP diff --git a/singleheader/simdjson.h b/singleheader/simdjson.h index 8f52a4331..cc3bf0e1f 100644 --- a/singleheader/simdjson.h +++ b/singleheader/simdjson.h @@ -1,4 +1,4 @@ -/* auto-generated on 2025-06-04 00:22:10 -0400. Do not edit! */ +/* auto-generated on 2025-06-24 15:13:44 -0400. Do not edit! */ /* including simdjson.h: */ /* begin file simdjson.h */ #ifndef SIMDJSON_H @@ -4491,7 +4491,7 @@ public: iterator& operator=(const iterator&) noexcept = default; private: simdjson_inline iterator(const internal::tape_ref &tape) noexcept; - internal::tape_ref tape; + internal::tape_ref tape{}; friend class array; }; @@ -4582,7 +4582,7 @@ public: private: simdjson_inline array(const internal::tape_ref &tape) noexcept; - internal::tape_ref tape; + internal::tape_ref tape{}; friend class element; friend struct simdjson_result; template @@ -6220,7 +6220,7 @@ public: private: simdjson_inline element(const internal::tape_ref &tape) noexcept; - internal::tape_ref tape; + internal::tape_ref tape{}; friend class document; friend class object; friend class array; @@ -6391,7 +6391,7 @@ public: private: simdjson_inline iterator(const internal::tape_ref &tape) noexcept; - internal::tape_ref tape; + internal::tape_ref tape{}; friend class object; }; @@ -6526,7 +6526,7 @@ public: private: simdjson_inline object(const internal::tape_ref &tape) noexcept; - internal::tape_ref tape; + internal::tape_ref tape{}; friend class element; friend struct simdjson_result; diff --git a/tests/dom/ranges_test.cpp b/tests/dom/ranges_test.cpp index 84c85ca07..73bec2cd4 100644 --- a/tests/dom/ranges_test.cpp +++ b/tests/dom/ranges_test.cpp @@ -4,21 +4,56 @@ #include "simdjson.h" #include "test_macros.h" +#include "test_main.h" + using namespace simdjson; +namespace ranges_test { -int main(void) { - auto cars_json = R"( [ - { "make": "Toyota", "model": "Camry", "year": 2018, "tire_pressure": [ 40.1, 39.9, 37.7, 40.4 ] }, - { "make": "Kia", "model": "Soul", "year": 2012, "tire_pressure": [ 30.1, 31.0, 28.6, 28.7 ] }, - { "make": "Toyota", "model": "Tercel", "year": 1999, "tire_pressure": [ 29.8, 30.0, 30.2, 30.5 ] } -] )"_padded; - dom::parser parser; - auto justmodel = [](auto car) -> std::string_view { - return car["model"].get_string(); - }; - auto cars = - parser.parse(cars_json).get_array() | std::views::transform(justmodel); + bool printout() { + TEST_START(); + auto cars_json = R"( [ + { "make": "Toyota", "model": "Camry", "year": 2018, "tire_pressure": [ 40.1, 39.9, 37.7, 40.4 ] }, + { "make": "Kia", "model": "Soul", "year": 2012, "tire_pressure": [ 30.1, 31.0, 28.6, 28.7 ] }, + { "make": "Toyota", "model": "Tercel", "year": 1999, "tire_pressure": [ 29.8, 30.0, 30.2, 30.5 ] } + ] )"_padded; + dom::parser parser; + auto justmodel = [](auto car) { return car["model"]; }; + for (auto car : + parser.parse(cars_json).get_array() | std::views::transform(justmodel)) { + std::cout << car << std::endl; + } + TEST_SUCCEED(); + } - const std::vector expected{"Camry", "Soul", "Tercel"}; - return std::ranges::equal(cars, expected) ? EXIT_SUCCESS : EXIT_FAILURE; + bool checkvalues() { + TEST_START(); + auto cars_json = R"( [ + { "make": "Toyota", "model": "Camry", "year": 2018, "tire_pressure": [ 40.1, 39.9, 37.7, 40.4 ] }, + { "make": "Kia", "model": "Soul", "year": 2012, "tire_pressure": [ 30.1, 31.0, 28.6, 28.7 ] }, + { "make": "Toyota", "model": "Tercel", "year": 1999, "tire_pressure": [ 29.8, 30.0, 30.2, 30.5 ] } + ] )"_padded; + dom::parser parser; + auto justmodel = [](auto car) -> std::string_view { + return car["model"].get_string(); + }; + auto cars = + parser.parse(cars_json).get_array() | std::views::transform(justmodel); + + const std::vector expected{"Camry", "Soul", "Tercel"}; + ASSERT_TRUE(std::ranges::equal(cars, expected)); + TEST_SUCCEED(); + } + + bool run() { + return + #if SIMDJSON_EXCEPTIONS + printout() && checkvalues() && + #endif // SIMDJSON_EXCEPTIONS + true; + } + +} // namespace ranges_test + +int main(int argc, char *argv[]) { + return test_main(argc, argv, ranges_test::run); } diff --git a/tests/ondemand/test_ondemand.h b/tests/ondemand/test_ondemand.h index 8fe1c3cc3..2d10e8b85 100644 --- a/tests/ondemand/test_ondemand.h +++ b/tests/ondemand/test_ondemand.h @@ -6,6 +6,7 @@ #include "simdjson.h" #include "cast_tester.h" #include "test_macros.h" +#include "test_main.h" template bool test_ondemand(simdjson::ondemand::parser &parser, const simdjson::padded_string &json, const F& f) { @@ -43,45 +44,5 @@ bool test_ondemand_doc(const simdjson::padded_string &json, const F& f) { const size_t AMAZON_CELLPHONES_NDJSON_DOC_COUNT = 793; #define SIMDJSON_SHOW_DEFINE(x) printf("%s=%s\n", #x, SIMDJSON_STRINGIFY(x)) -template -int test_main(int argc, char *argv[], const F& test_function) { - std::cout << std::unitbuf; - int c; - while ((c = getopt(argc, argv, "a:")) != -1) { - switch (c) { - case 'a': { - const simdjson::implementation *impl = simdjson::get_available_implementations()[optarg]; - if (!impl) { - std::fprintf(stderr, "Unsupported architecture value -a %s\n", optarg); - return EXIT_FAILURE; - } - simdjson::get_active_implementation() = impl; - break; - } - default: - std::fprintf(stderr, "Unexpected argument %c\n", c); - return EXIT_FAILURE; - } - } - - // this is put here deliberately to check that the documentation is correct (README), - // should this fail to compile, you should update the documentation: - if (simdjson::get_active_implementation()->name() == "unsupported") { - std::printf("unsupported CPU\n"); - std::abort(); - } - // We want to know what we are testing. - std::cout << "builtin_implementation -- " << simdjson::builtin_implementation()->name() << std::endl; - std::cout << "------------------------------------------------------------" << std::endl; - - std::cout << "Running tests." << std::endl; - if (test_function()) { - std::cout << "Success!" << std::endl; - return EXIT_SUCCESS; - } else { - std::cerr << "FAILED." << std::endl; - return EXIT_FAILURE; - } -} #endif // ONDEMAND_TEST_ONDEMAND_H diff --git a/tests/test_macros.h b/tests/test_macros.h index 4d5a42d8c..66cf323e3 100644 --- a/tests/test_macros.h +++ b/tests/test_macros.h @@ -139,5 +139,4 @@ simdjson_inline bool assert_iterate_error(T &arr, simdjson::error_code expected, #define RUN_TEST(ACTUAL) do { if (!(ACTUAL)) { return false; } } while (0); #define TEST_FAIL(MESSAGE) do { std::cerr << "FAIL: " << (MESSAGE) << std::endl; return false; } while (0); #define TEST_SUCCEED() do { return true; } while (0); - #endif // TEST_MACROS_H diff --git a/tests/test_main.h b/tests/test_main.h new file mode 100644 index 000000000..24fb1c8a6 --- /dev/null +++ b/tests/test_main.h @@ -0,0 +1,50 @@ +#ifndef TEST_MAIN_H +#define TEST_MAIN_H +#include +#include +#include +#include +#include "simdjson.h" + +// technically not a macro, but we want to share this function across tests for both ondemand and dom. +template +int test_main(int argc, char *argv[], const F& test_function) { + std::cout << std::unitbuf; + int c; + while ((c = getopt(argc, argv, "a:")) != -1) { + switch (c) { + case 'a': { + const simdjson::implementation *impl = simdjson::get_available_implementations()[optarg]; + if (!impl) { + std::fprintf(stderr, "Unsupported architecture value -a %s\n", optarg); + return EXIT_FAILURE; + } + simdjson::get_active_implementation() = impl; + break; + } + default: + std::fprintf(stderr, "Unexpected argument %c\n", c); + return EXIT_FAILURE; + } + } + + // this is put here deliberately to check that the documentation is correct (README), + // should this fail to compile, you should update the documentation: + if (simdjson::get_active_implementation()->name() == "unsupported") { + std::printf("unsupported CPU\n"); + std::abort(); + } + // We want to know what we are testing. + std::cout << "builtin_implementation -- " << simdjson::builtin_implementation()->name() << std::endl; + std::cout << "------------------------------------------------------------" << std::endl; + + std::cout << "Running tests." << std::endl; + if (test_function()) { + std::cout << "Success!" << std::endl; + return EXIT_SUCCESS; + } else { + std::cerr << "FAILED." << std::endl; + return EXIT_FAILURE; + } +} +#endif // TEST_MAIN_H \ No newline at end of file