Added operators == and != for MemberProxy

This commit is contained in:
Benoit Blanchon
2019-07-19 10:27:03 +02:00
parent 7ce1039d7c
commit 795e37278f
4 changed files with 38 additions and 1 deletions

View File

@ -5,6 +5,7 @@
add_executable(ElementProxyTests
add.cpp
clear.cpp
compare.cpp
remove.cpp
set.cpp
size.cpp

View File

@ -0,0 +1,28 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
TEST_CASE("ElementProxy::operator==()") {
DynamicJsonDocument doc(4096);
SECTION("same value") {
doc.add(1);
doc.add(1);
REQUIRE(doc[0] == doc[1]);
REQUIRE_FALSE(doc[0] != doc[1]);
}
SECTION("different values") {
doc.add(1);
doc.add(2);
REQUIRE_FALSE(doc[0] == doc[1]);
REQUIRE(doc[0] != doc[1]);
}
}