add regression tests

This commit is contained in:
Niels Lohmann 2021-09-02 08:32:19 +02:00
parent 666b0310f5
commit 3a4f5a8a9c
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69

View File

@ -181,6 +181,13 @@ class sax_no_exception : public nlohmann::detail::json_sax_dom_parser<json>
std::string* sax_no_exception::error_string = nullptr;
/////////////////////////////////////////////////////////////////////
// for #2982
/////////////////////////////////////////////////////////////////////
template<class T>
class my_allocator : public std::allocator<T>
{};
TEST_CASE("regression tests 2")
{
@ -679,6 +686,15 @@ TEST_CASE("regression tests 2")
test3[json::json_pointer(p)] = json::object();
CHECK(test3.dump() == "{\"/root\":{}}");
}
SECTION("issue #2982 - to_{binary format} does not provide a mechanism for specifying a custom allocator for the returned type")
{
std::vector<std::uint8_t, my_allocator<std::uint8_t>> my_vector;
json j = {1, 2, 3, 4};
json::to_cbor(j, my_vector);
json k = json::from_cbor(my_vector);
CHECK(j == k);
}
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP