improved test coverage

parent b27a142e
......@@ -38,7 +38,7 @@ TEST_CASE("capacity")
SECTION("boolean")
{
json j = true;
json j_const(j);
const json j_const(j);
SECTION("result of empty")
{
......@@ -56,7 +56,7 @@ TEST_CASE("capacity")
SECTION("string")
{
json j = "hello world";
json j_const(j);
const json j_const(j);
SECTION("result of empty")
{
......@@ -76,7 +76,7 @@ TEST_CASE("capacity")
SECTION("empty array")
{
json j = json::array();
json j_const(j);
const json j_const(j);
SECTION("result of empty")
{
......@@ -94,7 +94,7 @@ TEST_CASE("capacity")
SECTION("filled array")
{
json j = {1, 2, 3};
json j_const(j);
const json j_const(j);
SECTION("result of empty")
{
......@@ -115,7 +115,7 @@ TEST_CASE("capacity")
SECTION("empty object")
{
json j = json::object();
json j_const(j);
const json j_const(j);
SECTION("result of empty")
{
......@@ -133,7 +133,7 @@ TEST_CASE("capacity")
SECTION("filled object")
{
json j = {{"one", 1}, {"two", 2}, {"three", 3}};
json j_const(j);
const json j_const(j);
SECTION("result of empty")
{
......@@ -151,8 +151,8 @@ TEST_CASE("capacity")
SECTION("number (integer)")
{
json j = 23;
json j_const(j);
json j = -23;
const json j_const(j);
SECTION("result of empty")
{
......@@ -170,7 +170,7 @@ TEST_CASE("capacity")
SECTION("number (unsigned)")
{
json j = 23u;
json j_const(j);
const json j_const(j);
SECTION("result of empty")
{
......@@ -188,7 +188,7 @@ TEST_CASE("capacity")
SECTION("number (float)")
{
json j = 23.42;
json j_const(j);
const json j_const(j);
SECTION("result of empty")
{
......@@ -206,7 +206,7 @@ TEST_CASE("capacity")
SECTION("null")
{
json j = nullptr;
json j_const(j);
const json j_const(j);
SECTION("result of empty")
{
......@@ -227,7 +227,7 @@ TEST_CASE("capacity")
SECTION("boolean")
{
json j = true;
json j_const(j);
const json j_const(j);
SECTION("result of size")
{
......@@ -247,7 +247,7 @@ TEST_CASE("capacity")
SECTION("string")
{
json j = "hello world";
json j_const(j);
const json j_const(j);
SECTION("result of size")
{
......@@ -269,7 +269,7 @@ TEST_CASE("capacity")
SECTION("empty array")
{
json j = json::array();
json j_const(j);
const json j_const(j);
SECTION("result of size")
{
......@@ -289,7 +289,7 @@ TEST_CASE("capacity")
SECTION("filled array")
{
json j = {1, 2, 3};
json j_const(j);
const json j_const(j);
SECTION("result of size")
{
......@@ -312,7 +312,7 @@ TEST_CASE("capacity")
SECTION("empty object")
{
json j = json::object();
json j_const(j);
const json j_const(j);
SECTION("result of size")
{
......@@ -332,7 +332,7 @@ TEST_CASE("capacity")
SECTION("filled object")
{
json j = {{"one", 1}, {"two", 2}, {"three", 3}};
json j_const(j);
const json j_const(j);
SECTION("result of size")
{
......@@ -352,8 +352,8 @@ TEST_CASE("capacity")
SECTION("number (integer)")
{
json j = 23;
json j_const(j);
json j = -23;
const json j_const(j);
SECTION("result of size")
{
......@@ -373,7 +373,7 @@ TEST_CASE("capacity")
SECTION("number (unsigned)")
{
json j = 23u;
json j_const(j);
const json j_const(j);
SECTION("result of size")
{
......@@ -393,7 +393,7 @@ TEST_CASE("capacity")
SECTION("number (float)")
{
json j = 23.42;
json j_const(j);
const json j_const(j);
SECTION("result of size")
{
......@@ -413,7 +413,7 @@ TEST_CASE("capacity")
SECTION("null")
{
json j = nullptr;
json j_const(j);
const json j_const(j);
SECTION("result of size")
{
......@@ -436,7 +436,7 @@ TEST_CASE("capacity")
SECTION("boolean")
{
json j = true;
json j_const(j);
const json j_const(j);
SECTION("result of max_size")
{
......@@ -448,7 +448,7 @@ TEST_CASE("capacity")
SECTION("string")
{
json j = "hello world";
json j_const(j);
const json j_const(j);
SECTION("result of max_size")
{
......@@ -462,7 +462,7 @@ TEST_CASE("capacity")
SECTION("empty array")
{
json j = json::array();
json j_const(j);
const json j_const(j);
SECTION("result of max_size")
{
......@@ -474,7 +474,7 @@ TEST_CASE("capacity")
SECTION("filled array")
{
json j = {1, 2, 3};
json j_const(j);
const json j_const(j);
SECTION("result of max_size")
{
......@@ -489,7 +489,7 @@ TEST_CASE("capacity")
SECTION("empty object")
{
json j = json::object();
json j_const(j);
const json j_const(j);
SECTION("result of max_size")
{
......@@ -501,7 +501,7 @@ TEST_CASE("capacity")
SECTION("filled object")
{
json j = {{"one", 1}, {"two", 2}, {"three", 3}};
json j_const(j);
const json j_const(j);
SECTION("result of max_size")
{
......@@ -513,8 +513,8 @@ TEST_CASE("capacity")
SECTION("number (integer)")
{
json j = 23;
json j_const(j);
json j = -23;
const json j_const(j);
SECTION("result of max_size")
{
......@@ -526,7 +526,7 @@ TEST_CASE("capacity")
SECTION("number (unsigned)")
{
json j = 23u;
json j_const(j);
const json j_const(j);
SECTION("result of max_size")
{
......@@ -538,7 +538,7 @@ TEST_CASE("capacity")
SECTION("number (float)")
{
json j = 23.42;
json j_const(j);
const json j_const(j);
SECTION("result of max_size")
{
......@@ -550,7 +550,7 @@ TEST_CASE("capacity")
SECTION("null")
{
json j = nullptr;
json j_const(j);
const json j_const(j);
SECTION("result of max_size")
{
......
......@@ -88,7 +88,7 @@ TEST_CASE("lexicographical comparison operators")
json j_values =
{
nullptr, nullptr,
17, 42,
-17, 42,
8u, 13u,
3.14159, 23.42,
"foo", "bar",
......@@ -125,6 +125,8 @@ TEST_CASE("lexicographical comparison operators")
{
CAPTURE(i);
CAPTURE(j);
CAPTURE(j_values[i]);
CAPTURE(j_values[j]);
// check precomputed values
CHECK( (j_values[i] == j_values[j]) == expected[i][j] );
}
......@@ -172,11 +174,11 @@ TEST_CASE("lexicographical comparison operators")
{
{false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true},
{false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true},
{false, false, false, true, false, false, false, true, true, true, false, false, true, true, true, true},
{false, false, false, true, true, true, true, true, true, true, false, false, true, true, true, true},
{false, false, false, false, false, false, false, false, true, true, false, false, true, true, true, true},
{false, false, true, true, false, true, false, true, true, true, false, false, true, true, true, true},
{false, false, true, true, false, false, false, true, true, true, false, false, true, true, true, true},
{false, false, true, true, true, true, false, true, true, true, false, false, true, true, true, true},
{false, false, false, true, false, true, false, true, true, true, false, false, true, true, true, true},
{false, false, false, true, false, false, false, true, true, true, false, false, true, true, true, true},
{false, false, false, true, true, true, false, true, true, true, false, false, true, true, true, true},
{false, false, false, true, false, false, false, false, true, true, false, false, true, true, true, true},
{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
{false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false},
......@@ -194,6 +196,8 @@ TEST_CASE("lexicographical comparison operators")
{
CAPTURE(i);
CAPTURE(j);
CAPTURE(j_values[i]);
CAPTURE(j_values[j]);
// check precomputed values
CHECK( (j_values[i] < j_values[j]) == expected[i][j] );
}
......
......@@ -77,6 +77,7 @@ TEST_CASE("constructors")
auto t = json::value_t::boolean;
json j(t);
CHECK(j.type() == t);
CHECK(j == false);
}
SECTION("string")
......@@ -84,6 +85,7 @@ TEST_CASE("constructors")
auto t = json::value_t::string;
json j(t);
CHECK(j.type() == t);
CHECK(j == "");
}
SECTION("number_integer")
......@@ -91,6 +93,7 @@ TEST_CASE("constructors")
auto t = json::value_t::number_integer;
json j(t);
CHECK(j.type() == t);
CHECK(j == 0);
}
SECTION("number_unsigned")
......@@ -98,6 +101,7 @@ TEST_CASE("constructors")
auto t = json::value_t::number_unsigned;
json j(t);
CHECK(j.type() == t);
CHECK(j == 0);
}
SECTION("number_float")
......@@ -105,6 +109,7 @@ TEST_CASE("constructors")
auto t = json::value_t::number_float;
json j(t);
CHECK(j.type() == t);
CHECK(j == 0.0);
}
}
......
......@@ -47,5 +47,10 @@ TEST_CASE("version information")
{"minor", 1},
{"patch", 1}
}));
CHECK(j.find("platform") != j.end());
CHECK(j.at("compiler").find("family") != j.at("compiler").end());
CHECK(j.at("compiler").find("version") != j.at("compiler").end());
CHECK(j.at("compiler").find("c++") != j.at("compiler").end());
}
}
......@@ -271,9 +271,13 @@ TEST_CASE("modifiers")
j.push_back({"key2", "bar"});
CHECK(j == json({{"key1", 1}, {"key2", "bar"}}));
json k = {{"key1", 1}};
CHECK_THROWS_AS(k.push_back({1, 2, 3, 4}), json::type_error&);
CHECK_THROWS_WITH(k.push_back({1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object");
// invalid values (no string/val pair)
CHECK_THROWS_AS(j.push_back({1}), json::type_error&);
CHECK_THROWS_WITH(j.push_back({1}), "[json.exception.type_error.308] cannot use push_back() with object");
CHECK_THROWS_AS(j.push_back({1,2}), json::type_error&);
CHECK_THROWS_WITH(j.push_back({1, 2}), "[json.exception.type_error.308] cannot use push_back() with object");
CHECK_THROWS_AS(j.push_back({1, 2, 3, 4}), json::type_error&);
CHECK_THROWS_WITH(j.push_back({1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object");
}
}
}
......
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