From 65f9822542f66332e0d71ab08f005cdedf2d119b Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 7 Jun 2023 09:57:28 -0400 Subject: [PATCH] Adding tests for issue 2017 (#2018) --- tests/dom/basictests.cpp | 12 +++++++++++- tests/ondemand/ondemand_number_tests.cpp | 17 ++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/dom/basictests.cpp b/tests/dom/basictests.cpp index 8da62bacc..ee2423f34 100644 --- a/tests/dom/basictests.cpp +++ b/tests/dom/basictests.cpp @@ -66,6 +66,15 @@ namespace number_tests { return true; } + bool issue2017() { + TEST_START(); + simdjson::dom::parser parser; + simdjson::padded_string docdata = R"({"score":0.8825149536132812})"_padded; + double score; + ASSERT_SUCCESS(parser.parse(docdata)["score"].get_double().get(score)); + ASSERT_EQUAL(score, 0.8825149536132812); + TEST_SUCCEED(); + } bool small_integers() { std::cout << __func__ << std::endl; @@ -377,7 +386,8 @@ namespace number_tests { } bool run() { - return truncated_borderline() && + return issue2017() && + truncated_borderline() && specific_tests() && ground_truth() && small_integers() && diff --git a/tests/ondemand/ondemand_number_tests.cpp b/tests/ondemand/ondemand_number_tests.cpp index 04ed56743..a8db2c24c 100644 --- a/tests/ondemand/ondemand_number_tests.cpp +++ b/tests/ondemand/ondemand_number_tests.cpp @@ -333,6 +333,8 @@ namespace number_tests { TEST_SUCCEED(); } + + bool get_root_number_tests() { TEST_START(); ondemand::parser parser; @@ -389,8 +391,21 @@ namespace number_tests { TEST_SUCCEED(); } + bool issue2017() { + TEST_START(); + ondemand::parser parser; + ondemand::document doc; + padded_string docdata = R"({"score":0.8825149536132812})"_padded; + ASSERT_SUCCESS(parser.iterate(docdata).get(doc)); + double score; + ASSERT_SUCCESS(doc["score"].get_double().get(score)); + ASSERT_EQUAL(score, 0.8825149536132812); + TEST_SUCCEED(); + } + bool run() { - return issue_1898() && + return issue2017() && + issue_1898() && issue1878() && get_root_number_tests() && get_number_tests()&&