forked from bblanchon/ArduinoJson
Added operators ==
and !=
for MemberProxy
This commit is contained in:
@ -4,7 +4,7 @@ ArduinoJson: change log
|
|||||||
HEAD
|
HEAD
|
||||||
----
|
----
|
||||||
|
|
||||||
* Added operators `==` and `!=` for `JsonDocument` and `MemberProxy`
|
* Added operators `==` and `!=` for `JsonDocument`, `ElementProxy`, and `MemberProxy`
|
||||||
|
|
||||||
v6.11.2 (2019-07-08)
|
v6.11.2 (2019-07-08)
|
||||||
-------
|
-------
|
||||||
|
@ -47,6 +47,14 @@ class ElementProxy : public VariantOperators<ElementProxy<TArray> >,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE bool operator==(VariantConstRef rhs) const {
|
||||||
|
return static_cast<VariantConstRef>(getUpstreamElement()) == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE bool operator!=(VariantConstRef rhs) const {
|
||||||
|
return static_cast<VariantConstRef>(getUpstreamElement()) != rhs;
|
||||||
|
}
|
||||||
|
|
||||||
FORCE_INLINE void clear() const {
|
FORCE_INLINE void clear() const {
|
||||||
getUpstreamElement().clear();
|
getUpstreamElement().clear();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
add_executable(ElementProxyTests
|
add_executable(ElementProxyTests
|
||||||
add.cpp
|
add.cpp
|
||||||
clear.cpp
|
clear.cpp
|
||||||
|
compare.cpp
|
||||||
remove.cpp
|
remove.cpp
|
||||||
set.cpp
|
set.cpp
|
||||||
size.cpp
|
size.cpp
|
||||||
|
28
test/ElementProxy/compare.cpp
Normal file
28
test/ElementProxy/compare.cpp
Normal 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]);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user