mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 04:52:22 +02:00
Tests: add user-defined literal ""_s
for std::string
This commit is contained in:
@ -5,6 +5,8 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
#if defined(__clang__)
|
||||
# define CONFLICTS_WITH_BUILTIN_OPERATOR
|
||||
#endif
|
||||
@ -111,7 +113,7 @@ TEST_CASE("unsigned char[]") {
|
||||
deserializeJson(doc, "{\"hello\":\"world\"}");
|
||||
JsonVariant variant = doc.as<JsonVariant>();
|
||||
|
||||
REQUIRE(std::string("world") == variant[key]);
|
||||
REQUIRE("world"_s == variant[key]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -122,7 +124,7 @@ TEST_CASE("unsigned char[]") {
|
||||
deserializeJson(doc, "{\"hello\":\"world\"}");
|
||||
const JsonVariant variant = doc.as<JsonVariant>();
|
||||
|
||||
REQUIRE(std::string("world") == variant[key]);
|
||||
REQUIRE("world"_s == variant[key]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -160,7 +162,7 @@ TEST_CASE("unsigned char[]") {
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj[key] = "world";
|
||||
|
||||
REQUIRE(std::string("world") == obj["hello"]);
|
||||
REQUIRE("world"_s == obj["hello"]);
|
||||
}
|
||||
|
||||
SECTION("JsonObject::operator[] const") {
|
||||
@ -170,7 +172,7 @@ TEST_CASE("unsigned char[]") {
|
||||
deserializeJson(doc, "{\"hello\":\"world\"}");
|
||||
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
REQUIRE(std::string("world") == obj[key]);
|
||||
REQUIRE("world"_s == obj[key]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -203,7 +205,7 @@ TEST_CASE("unsigned char[]") {
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj["hello"] = value;
|
||||
|
||||
REQUIRE(std::string("world") == obj["hello"]);
|
||||
REQUIRE("world"_s == obj["hello"]);
|
||||
}
|
||||
|
||||
SECTION("set()") {
|
||||
@ -213,7 +215,7 @@ TEST_CASE("unsigned char[]") {
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj["hello"].set(value);
|
||||
|
||||
REQUIRE(std::string("world") == obj["hello"]);
|
||||
REQUIRE("world"_s == obj["hello"]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +227,7 @@ TEST_CASE("unsigned char[]") {
|
||||
JsonArray arr = doc.to<JsonArray>();
|
||||
arr.add(value);
|
||||
|
||||
REQUIRE(std::string("world") == arr[0]);
|
||||
REQUIRE("world"_s == arr[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,7 +240,7 @@ TEST_CASE("unsigned char[]") {
|
||||
arr.add("hello");
|
||||
arr[0].set(value);
|
||||
|
||||
REQUIRE(std::string("world") == arr[0]);
|
||||
REQUIRE("world"_s == arr[0]);
|
||||
}
|
||||
|
||||
SECTION("operator=") {
|
||||
@ -249,7 +251,7 @@ TEST_CASE("unsigned char[]") {
|
||||
arr.add("hello");
|
||||
arr[0] = value;
|
||||
|
||||
REQUIRE(std::string("world") == arr[0]);
|
||||
REQUIRE("world"_s == arr[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user