Prevent memory leak when exception is thrown in adl_serializer::to_json (#3901)

Co-authored-by: barcode <barcode@example.com>
This commit is contained in:
Raphael Grimm
2023-03-08 13:43:45 +01:00
committed by GitHub
parent fe4b66355c
commit bbe337c3a3
15 changed files with 1321 additions and 1167 deletions

View File

@@ -1076,19 +1076,19 @@ TEST_CASE("value conversion")
SECTION("number_float_t")
{
auto n = j.get<json::number_float_t>();
CHECK(json(n).m_value.number_float == Approx(j.m_value.number_float));
CHECK(json(n).m_data.m_value.number_float == Approx(j.m_data.m_value.number_float));
}
SECTION("float")
{
auto n = j.get<float>();
CHECK(json(n).m_value.number_float == Approx(j.m_value.number_float));
CHECK(json(n).m_data.m_value.number_float == Approx(j.m_data.m_value.number_float));
}
SECTION("double")
{
auto n = j.get<double>();
CHECK(json(n).m_value.number_float == Approx(j.m_value.number_float));
CHECK(json(n).m_data.m_value.number_float == Approx(j.m_data.m_value.number_float));
}
SECTION("exception in case of a non-string type")
@@ -1126,19 +1126,19 @@ TEST_CASE("value conversion")
SECTION("number_float_t")
{
json::number_float_t const n = j;
CHECK(json(n).m_value.number_float == Approx(j.m_value.number_float));
CHECK(json(n).m_data.m_value.number_float == Approx(j.m_data.m_value.number_float));
}
SECTION("float")
{
float const n = j;
CHECK(json(n).m_value.number_float == Approx(j.m_value.number_float));
CHECK(json(n).m_data.m_value.number_float == Approx(j.m_data.m_value.number_float));
}
SECTION("double")
{
double const n = j;
CHECK(json(n).m_value.number_float == Approx(j.m_value.number_float));
CHECK(json(n).m_data.m_value.number_float == Approx(j.m_data.m_value.number_float));
}
}
#endif
@@ -1151,7 +1151,7 @@ TEST_CASE("value conversion")
SECTION("binary_t")
{
json::binary_t const b = j.get<json::binary_t>();
CHECK(*json(b).m_value.binary == *j.m_value.binary);
CHECK(*json(b).m_data.m_value.binary == *j.m_data.m_value.binary);
}
SECTION("get_binary()")
@@ -1159,14 +1159,14 @@ TEST_CASE("value conversion")
SECTION("non-const")
{
auto& b = j.get_binary();
CHECK(*json(b).m_value.binary == *j.m_value.binary);
CHECK(*json(b).m_data.m_value.binary == *j.m_data.m_value.binary);
}
SECTION("non-const")
{
const json j_const = j;
const auto& b = j_const.get_binary();
CHECK(*json(b).m_value.binary == *j.m_value.binary);
CHECK(*json(b).m_data.m_value.binary == *j.m_data.m_value.binary);
}
}
@@ -1258,7 +1258,7 @@ TEST_CASE("value conversion")
SECTION("binary_t")
{
json::binary_t const b = j;
CHECK(*json(b).m_value.binary == *j.m_value.binary);
CHECK(*json(b).m_data.m_value.binary == *j.m_data.m_value.binary);
}
}
#endif