Fix comparisons operators with const JsonDocument&

This commit is contained in:
Benoit Blanchon
2022-04-05 10:12:17 +02:00
parent bf5d0c790c
commit 8d9504239b
3 changed files with 30 additions and 3 deletions

View File

@ -75,3 +75,29 @@ TEST_CASE("StaticJsonDocument::operator==(const DynamicJsonDocument&)") {
REQUIRE(doc1 != doc2);
}
}
TEST_CASE("JsonDocument::operator==(const JsonDocument&)") {
StaticJsonDocument<256> doc1;
StaticJsonDocument<256> doc2;
const JsonDocument& ref1 = doc1;
const JsonDocument& ref2 = doc2;
SECTION("Empty") {
REQUIRE(ref1 == ref2);
REQUIRE_FALSE(ref1 != ref2);
}
SECTION("With same object") {
doc1["hello"] = "world";
doc2["hello"] = "world";
REQUIRE(ref1 == ref2);
REQUIRE_FALSE(ref1 != ref2);
}
SECTION("With different object") {
doc1["hello"] = "world";
doc2["world"] = "hello";
REQUIRE_FALSE(ref1 == ref2);
REQUIRE(ref1 != ref2);
}
}