From a1cdf9bf63831308c2a6eabfb2435b9dee6100b0 Mon Sep 17 00:00:00 2001 From: Daniel Parker Date: Mon, 11 Nov 2024 17:27:23 -0500 Subject: [PATCH] incremental parsing example and tests --- test/corelib/src/json_parser_tests.cpp | 6 ++++-- test/corelib/src/json_reader_tests.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/corelib/src/json_parser_tests.cpp b/test/corelib/src/json_parser_tests.cpp index 9e65772bd..4d78b2118 100644 --- a/test/corelib/src/json_parser_tests.cpp +++ b/test/corelib/src/json_parser_tests.cpp @@ -235,7 +235,8 @@ TEST_CASE("test_incremental_parsing") { SECTION("Array of strings") { - std::vector chunks = {"[fal", "se, ", "t", "rue", ", null", ",", "1", "234", ",\"Hello ", "World\"", "]"}; + std::vector chunks = {"[fal", "se, ", "t", "rue", ", null", ",", "1", "234", ",\"Hello ", "World\",", + "0.", "1234", "]"}; std::size_t index = 0; auto read_chunk = [&](jsoncons::parser_input& input, std::error_code& /*ec*/) -> bool @@ -265,12 +266,13 @@ TEST_CASE("test_incremental_parsing") json j = decoder.get_result(); REQUIRE(j.is_array()); - REQUIRE(j.size() == 5); + REQUIRE(j.size() == 6); CHECK_FALSE(j[0].as()); CHECK(j[1].as()); CHECK(j[2].is_null()); CHECK(j[3].as() == 1234); CHECK(j[4].as() == "Hello World"); + CHECK(j[5].as() == 0.1234); } } diff --git a/test/corelib/src/json_reader_tests.cpp b/test/corelib/src/json_reader_tests.cpp index 5cb668002..8da23c2ac 100644 --- a/test/corelib/src/json_reader_tests.cpp +++ b/test/corelib/src/json_reader_tests.cpp @@ -33,7 +33,7 @@ TEST_CASE("test json_reader buffered read") CHECK(j.as() == str); } - /*SECTION("number with split buffer") + SECTION("number with split buffer") { std::string str(stream_source::default_max_buffer_size-7, 'a'); std::string neg_num("-123456789.123456789"); @@ -111,7 +111,7 @@ TEST_CASE("test json_reader buffered read") REQUIRE(j.is_array()); REQUIRE(j.size() == 2); CHECK(j[1].is_null()); - }*/ + } } void test_json_reader_error(const std::string& text, const std::error_code& ec)