From 73063e2daba547ccbfb2ce678b141bf5963fc50b Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Sat, 16 Jan 2021 15:08:27 -0500 Subject: [PATCH] This adds a test to explain better the issue 1341: Support conversion of simdjson_result lvalue to dom::element (#1397) * This adds a test to explain better the issue. * Guarding it since it can throw. --- tests/basictests.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/basictests.cpp b/tests/basictests.cpp index 1bb2a321..e55f1548 100644 --- a/tests/basictests.cpp +++ b/tests/basictests.cpp @@ -795,6 +795,12 @@ namespace dom_api_tests { dom::parser parser; dom::object object; ASSERT_SUCCESS( parser.parse(json).get(object) ); +#if SIMDJSON_EXCEPTIONS + // Next three lines are for https://github.com/simdjson/simdjson/issues/1341 + dom::element node = object["a"]; // might throw + auto mylambda = [](dom::element e) { return int64_t(e); }; + ASSERT_EQUAL( mylambda(node), 1 ); +#endif ASSERT_EQUAL( object["a"].get().first, 1 ); ASSERT_EQUAL( object["b"].get().first, 2 ); ASSERT_EQUAL( object["c/d"].get().first, 3 );