Add safe bool idiom in JsonString

This commit is contained in:
Benoit Blanchon
2021-10-22 17:19:14 +02:00
parent 8418845c8d
commit acfa174333
5 changed files with 55 additions and 7 deletions

View File

@ -14,6 +14,23 @@ TEST_CASE("JsonString") {
CHECK(s.isStatic() == true);
}
SECTION("Compare null with boolean") {
JsonString s;
CHECK(bool(s) == false);
CHECK(false == bool(s));
CHECK(bool(s) != true);
CHECK(true != bool(s));
}
SECTION("Compare non-null with boolean") {
JsonString s("hello");
CHECK(bool(s) == true);
CHECK(true == bool(s));
CHECK(bool(s) != false);
CHECK(false != bool(s));
}
SECTION("Compare null with null") {
JsonString a, b;