add regression test

This commit is contained in:
Niels Lohmann 2021-07-15 09:02:24 +02:00 committed by Chaoya Li
parent 8b643e4362
commit 97eb6414e4

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);
}
}
}