diff options
Diffstat (limited to 'libtests')
-rw-r--r-- | libtests/json_handler.cc | 6 | ||||
-rw-r--r-- | libtests/qtest/json_handler/json_handler.out | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/libtests/json_handler.cc b/libtests/json_handler.cc index 57185c98..2d3f9862 100644 --- a/libtests/json_handler.cc +++ b/libtests/json_handler.cc @@ -77,6 +77,7 @@ make_all_handler() auto h5s = std::make_shared<JSONHandler>(); h->addDictKeyHandler("five", h5s); h5s->addArrayHandlers(print_json, make_print_message("array end"), h5); + h5s->addFallbackHandler(h5); auto h6 = std::make_shared<JSONHandler>(); h6->addDictHandlers(print_json, make_print_message("dict end")); auto h6a = std::make_shared<JSONHandler>(); @@ -109,6 +110,11 @@ test_all() "six": {"a": {"b": "quack", "Q": "baaa"}, "b": "moo"} })"); h->handle(".", j); + std::cerr << "-- fallback --" << std::endl; + j = JSON::parse(R"({ + "five": "not-array" +})"); + h->handle(".", j); } static void diff --git a/libtests/qtest/json_handler/json_handler.out b/libtests/qtest/json_handler/json_handler.out index f076d4ee..4f340b85 100644 --- a/libtests/qtest/json_handler/json_handler.out +++ b/libtests/qtest/json_handler/json_handler.out @@ -63,6 +63,12 @@ .three: bool: true .two: number: 3.14 .: json: dict end +-- fallback -- +.: json: { + "five": "not-array" +} +.five: string: not-array +.: json: dict end -- errors -- bad type at top: JSON handler: value at . is not of expected type .: json: { |