mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
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.
This commit is contained in:
@@ -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<uint64_t>().first, 1 );
|
||||
ASSERT_EQUAL( object["b"].get<uint64_t>().first, 2 );
|
||||
ASSERT_EQUAL( object["c/d"].get<uint64_t>().first, 3 );
|
||||
|
||||
Reference in New Issue
Block a user