Commit f5cae64e authored by Nikita Ofitserov's avatar Nikita Ofitserov

Update tests while fixing possible UB

std::initializer_list does not own the temporaries created in
its initialization. Therefore, storing it in an independent
stack variable is unsafe.
parent 09cda573
...@@ -842,8 +842,7 @@ TEST_CASE("constructors") ...@@ -842,8 +842,7 @@ TEST_CASE("constructors")
{ {
SECTION("explicit") SECTION("explicit")
{ {
std::initializer_list<json> l; json j(json::initializer_list_t {});
json j(l);
CHECK(j.type() == json::value_t::object); CHECK(j.type() == json::value_t::object);
} }
...@@ -860,8 +859,7 @@ TEST_CASE("constructors") ...@@ -860,8 +859,7 @@ TEST_CASE("constructors")
{ {
SECTION("explicit") SECTION("explicit")
{ {
std::initializer_list<json> l = {json(json::array_t())}; json j(json::initializer_list_t {json(json::array_t())});
json j(l);
CHECK(j.type() == json::value_t::array); CHECK(j.type() == json::value_t::array);
} }
...@@ -876,8 +874,7 @@ TEST_CASE("constructors") ...@@ -876,8 +874,7 @@ TEST_CASE("constructors")
{ {
SECTION("explicit") SECTION("explicit")
{ {
std::initializer_list<json> l = {json(json::object_t())}; json j(json::initializer_list_t {json(json::object_t())});
json j(l);
CHECK(j.type() == json::value_t::array); CHECK(j.type() == json::value_t::array);
} }
...@@ -892,8 +889,7 @@ TEST_CASE("constructors") ...@@ -892,8 +889,7 @@ TEST_CASE("constructors")
{ {
SECTION("explicit") SECTION("explicit")
{ {
std::initializer_list<json> l = {json("Hello world")}; json j(json::initializer_list_t {json("Hello world")});
json j(l);
CHECK(j.type() == json::value_t::array); CHECK(j.type() == json::value_t::array);
} }
...@@ -908,8 +904,7 @@ TEST_CASE("constructors") ...@@ -908,8 +904,7 @@ TEST_CASE("constructors")
{ {
SECTION("explicit") SECTION("explicit")
{ {
std::initializer_list<json> l = {json(true)}; json j(json::initializer_list_t {json(true)});
json j(l);
CHECK(j.type() == json::value_t::array); CHECK(j.type() == json::value_t::array);
} }
...@@ -924,8 +919,7 @@ TEST_CASE("constructors") ...@@ -924,8 +919,7 @@ TEST_CASE("constructors")
{ {
SECTION("explicit") SECTION("explicit")
{ {
std::initializer_list<json> l = {json(1)}; json j(json::initializer_list_t {json(1)});
json j(l);
CHECK(j.type() == json::value_t::array); CHECK(j.type() == json::value_t::array);
} }
...@@ -940,8 +934,7 @@ TEST_CASE("constructors") ...@@ -940,8 +934,7 @@ TEST_CASE("constructors")
{ {
SECTION("explicit") SECTION("explicit")
{ {
std::initializer_list<json> l = {json(1u)}; json j(json::initializer_list_t {json(1u)});
json j(l);
CHECK(j.type() == json::value_t::array); CHECK(j.type() == json::value_t::array);
} }
...@@ -956,8 +949,7 @@ TEST_CASE("constructors") ...@@ -956,8 +949,7 @@ TEST_CASE("constructors")
{ {
SECTION("explicit") SECTION("explicit")
{ {
std::initializer_list<json> l = {json(42.23)}; json j(json::initializer_list_t {json(42.23)});
json j(l);
CHECK(j.type() == json::value_t::array); CHECK(j.type() == json::value_t::array);
} }
...@@ -973,8 +965,7 @@ TEST_CASE("constructors") ...@@ -973,8 +965,7 @@ TEST_CASE("constructors")
{ {
SECTION("explicit") SECTION("explicit")
{ {
std::initializer_list<json> l = {1, 1u, 42.23, true, nullptr, json::object_t(), json::array_t()}; json j(json::initializer_list_t {1, 1u, 42.23, true, nullptr, json::object_t(), json::array_t()});
json j(l);
CHECK(j.type() == json::value_t::array); CHECK(j.type() == json::value_t::array);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment