mirror of
https://github.com/nlohmann/json.git
synced 2026-09-28 18:50:31 +00:00
Build the enum-keyed map test object instead of parsing it
ci_test_diagnostic_positions failed in unit-enum_keyed_maps_default.cpp:
with JSON_DIAGNOSTIC_POSITIONS, a parsed value adds its byte range to
the exception message ("(bytes 0-7) type must be array, but is
object"), so the exact-message checks did not match. Build the object
in memory, like unit-custom-array-type.cpp does.
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -122,11 +122,14 @@ TEST_CASE("maps with enum keys")
|
||||
|
||||
SECTION("objects are only read for enum keys")
|
||||
{
|
||||
// built rather than parsed, so that the messages do not gain a byte
|
||||
// range with JSON_DIAGNOSTIC_POSITIONS
|
||||
const json j = {{"1", 2}};
|
||||
int_map im;
|
||||
int_umap ium;
|
||||
CHECK_THROWS_WITH_AS(json::parse(R"({"1":2})").get_to(im),
|
||||
CHECK_THROWS_WITH_AS(j.get_to(im),
|
||||
"[json.exception.type_error.302] type must be array, but is object", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(json::parse(R"({"1":2})").get_to(ium),
|
||||
CHECK_THROWS_WITH_AS(j.get_to(ium),
|
||||
"[json.exception.type_error.302] type must be array, but is object", json::type_error&);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user