forked from bblanchon/ArduinoJson
Removed implicit conversion in comparison operators (issue #998)
This commit is contained in:
1 parent
4eb8074358
commit
630107ae8a
14 files changed
+397
-147
No files matched your search
@@ -6,6 +6,7 @@ add_executable(MiscTests
|
||||
conflicts.cpp
|
||||
FloatParts.cpp
|
||||
StreamReader.cpp
|
||||
StringAdapters.cpp
|
||||
StringWriter.cpp
|
||||
TypeTraits.cpp
|
||||
unsigned_char.cpp
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2019
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
using namespace ARDUINOJSON_NAMESPACE;
|
||||
|
||||
TEST_CASE("ConstRamStringAdapter") {
|
||||
SECTION("null") {
|
||||
ConstRamStringAdapter adapter(NULL);
|
||||
|
||||
REQUIRE(adapter.compare("bravo") < 0);
|
||||
REQUIRE(adapter.compare(NULL) == 0);
|
||||
|
||||
REQUIRE(adapter.equals(NULL));
|
||||
REQUIRE_FALSE(adapter.equals("charlie"));
|
||||
}
|
||||
|
||||
SECTION("non-null") {
|
||||
ConstRamStringAdapter adapter("bravo");
|
||||
|
||||
REQUIRE(adapter.compare(NULL) > 0);
|
||||
REQUIRE(adapter.compare("alpha") > 0);
|
||||
REQUIRE(adapter.compare("bravo") == 0);
|
||||
REQUIRE(adapter.compare("charlie") < 0);
|
||||
|
||||
REQUIRE(adapter.equals("bravo"));
|
||||
REQUIRE_FALSE(adapter.equals("charlie"));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("StlString") {
|
||||
std::string str("bravo");
|
||||
StlStringAdapter adapter(str);
|
||||
|
||||
REQUIRE(adapter.compare(NULL) > 0);
|
||||
REQUIRE(adapter.compare("alpha") > 0);
|
||||
REQUIRE(adapter.compare("bravo") == 0);
|
||||
REQUIRE(adapter.compare("charlie") < 0);
|
||||
|
||||
REQUIRE(adapter.equals("bravo"));
|
||||
REQUIRE_FALSE(adapter.equals("charlie"));
|
||||
}
|
||||
Reference in new issue
Block a user