+ more test cases

This commit is contained in:
Niels 2014-12-28 15:41:33 +01:00
parent a68b4cafa2
commit 75b2f4098d

View file

@ -436,6 +436,10 @@ TEST_CASE("object")
{
JSON noobject = 1;
const JSON noobject_const = noobject;
CHECK_THROWS_AS(noobject.at("foo"), std::domain_error);
CHECK_THROWS_AS(noobject.at(std::string("foo")), std::domain_error);
CHECK_THROWS_AS(noobject_const.at("foo"), std::domain_error);
CHECK_THROWS_AS(noobject_const.at(std::string("foo")), std::domain_error);
CHECK_THROWS_AS(noobject["foo"], std::domain_error);
CHECK_THROWS_AS(noobject[std::string("foo")], std::domain_error);
CHECK_THROWS_AS(noobject_const[std::string("foo")], std::domain_error);
@ -1048,6 +1052,100 @@ TEST_CASE("number (float)")
}
}
TEST_CASE("Comparisons")
{
JSON j1 = {0, 1, 2, 3, 4};
JSON j2 = {{"foo", "bar"}, {"baz", "bam"}};
JSON j3 = true;
JSON j4 = nullptr;
JSON j5 = 42;
JSON j6 = 23.42;
CHECK((j1 == j1) == true);
CHECK((j1 == j2) == false);
CHECK((j1 == j3) == false);
CHECK((j1 == j4) == false);
CHECK((j1 == j5) == false);
CHECK((j1 == j6) == false);
CHECK((j2 == j1) == false);
CHECK((j2 == j2) == true);
CHECK((j2 == j3) == false);
CHECK((j2 == j4) == false);
CHECK((j2 == j5) == false);
CHECK((j2 == j6) == false);
CHECK((j3 == j1) == false);
CHECK((j3 == j2) == false);
CHECK((j3 == j3) == true);
CHECK((j3 == j4) == false);
CHECK((j3 == j5) == false);
CHECK((j3 == j6) == false);
CHECK((j4 == j1) == false);
CHECK((j4 == j2) == false);
CHECK((j4 == j3) == false);
CHECK((j4 == j4) == true);
CHECK((j4 == j5) == false);
CHECK((j4 == j6) == false);
CHECK((j5 == j1) == false);
CHECK((j5 == j2) == false);
CHECK((j5 == j3) == false);
CHECK((j5 == j4) == false);
CHECK((j5 == j5) == true);
CHECK((j5 == j6) == false);
CHECK((j6 == j1) == false);
CHECK((j6 == j2) == false);
CHECK((j6 == j3) == false);
CHECK((j6 == j4) == false);
CHECK((j6 == j5) == false);
CHECK((j6 == j6) == true);
CHECK((j1 != j1) == false);
CHECK((j1 != j2) == true);
CHECK((j1 != j3) == true);
CHECK((j1 != j4) == true);
CHECK((j1 != j5) == true);
CHECK((j1 != j6) == true);
CHECK((j2 != j1) == true);
CHECK((j2 != j2) == false);
CHECK((j2 != j3) == true);
CHECK((j2 != j4) == true);
CHECK((j2 != j5) == true);
CHECK((j2 != j6) == true);
CHECK((j3 != j1) == true);
CHECK((j3 != j2) == true);
CHECK((j3 != j3) == false);
CHECK((j3 != j4) == true);
CHECK((j3 != j5) == true);
CHECK((j3 != j6) == true);
CHECK((j4 != j1) == true);
CHECK((j4 != j2) == true);
CHECK((j4 != j3) == true);
CHECK((j4 != j4) == false);
CHECK((j4 != j5) == true);
CHECK((j4 != j6) == true);
CHECK((j5 != j1) == true);
CHECK((j5 != j2) == true);
CHECK((j5 != j3) == true);
CHECK((j5 != j4) == true);
CHECK((j5 != j5) == false);
CHECK((j5 != j6) == true);
CHECK((j6 != j1) == true);
CHECK((j6 != j2) == true);
CHECK((j6 != j3) == true);
CHECK((j6 != j4) == true);
CHECK((j6 != j5) == true);
CHECK((j6 != j6) == false);
}
TEST_CASE("Parser")
{
SECTION("null")