diff --git a/tests/ondemand/ondemand_readme_examples.cpp b/tests/ondemand/ondemand_readme_examples.cpp index 7809b2bf2..702a27396 100644 --- a/tests/ondemand/ondemand_readme_examples.cpp +++ b/tests/ondemand/ondemand_readme_examples.cpp @@ -764,7 +764,7 @@ bool basics_1() { TEST_START(); ondemand::parser parser; - auto json = padded_string::load("twitter.json"); + auto json = padded_string::load("twitter.json"); // this is a simdjson_result ondemand::document doc = parser.iterate(json); // load and parse a file simdjson_unused auto unused_doc = doc.get_object(); diff --git a/tests/ondemand/ondemand_twitter_tests.cpp b/tests/ondemand/ondemand_twitter_tests.cpp index cf50ea120..00416aaf7 100644 --- a/tests/ondemand/ondemand_twitter_tests.cpp +++ b/tests/ondemand/ondemand_twitter_tests.cpp @@ -20,6 +20,26 @@ namespace twitter_tests { TEST_SUCCEED(); } #if SIMDJSON_EXCEPTIONS + bool twitter_result_example() { + TEST_START(); + simdjson_result json = padded_string::load(TWITTER_JSON); + ondemand::parser parser; + auto doc = parser.iterate(json); + for (ondemand::object tweet : doc["statuses"]) { + uint64_t id = tweet["id"]; + std::string_view text = tweet["text"]; + std::string_view screen_name = tweet["user"]["screen_name"]; + uint64_t retweets = tweet["retweet_count"]; + uint64_t favorites = tweet["favorite_count"]; + (void) id; + (void) text; + (void) retweets; + (void) favorites; + (void) screen_name; + } + TEST_SUCCEED(); + } + bool twitter_example() { TEST_START(); padded_string json; @@ -182,6 +202,7 @@ namespace twitter_tests { twitter_default_profile() && twitter_image_sizes() && #if SIMDJSON_EXCEPTIONS + twitter_result_example() && twitter_count_exception() && twitter_example() && twitter_default_profile_exception() &&