add regression test

This commit is contained in:
Niels Lohmann 2021-07-15 09:02:24 +02:00
parent c9c5c016a2
commit db98073930
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69

View File

@ -594,4 +594,30 @@ TEST_CASE("regression tests 2")
}
}
}
SECTION("issue #2865 - ASAN detects memory leaks")
{
// the code below is expected to not leak memory
{
nlohmann::json o;
std::string s = "bar";
nlohmann::to_json(o["foo"], s);
nlohmann::json p = o;
// call to_json with a non-null JSON value
nlohmann::to_json(p["foo"], s);
}
{
nlohmann::json o;
std::string s = "bar";
nlohmann::to_json(o["foo"], s);
// call to_json with a non-null JSON value
nlohmann::to_json(o["foo"], s);
}
}
}