Tests: add user-defined literal ""_s for std::string

This commit is contained in:
Benoit Blanchon
2024-06-07 09:35:45 +02:00
parent 5b88b2c1f6
commit 45611924f3
55 changed files with 316 additions and 229 deletions

View File

@ -7,6 +7,8 @@
#include <string>
#include "Literals.hpp"
TEST_CASE("JsonDocument::createNestedArray()") {
JsonDocument doc;
@ -23,7 +25,7 @@ TEST_CASE("JsonDocument::createNestedArray()") {
}
SECTION("createNestedArray(std::string)") {
JsonArray array = doc.createNestedArray(std::string("key"));
JsonArray array = doc.createNestedArray("key"_s);
array.add(42);
REQUIRE(doc.as<std::string>() == "{\"key\":[42]}");
}
@ -59,7 +61,7 @@ TEST_CASE("JsonObject::createNestedArray()") {
}
SECTION("createNestedArray(std::string)") {
JsonArray array = object.createNestedArray(std::string("key"));
JsonArray array = object.createNestedArray("key"_s);
array.add(42);
REQUIRE(doc.as<std::string>() == "{\"key\":[42]}");
}
@ -93,7 +95,7 @@ TEST_CASE("JsonVariant::createNestedArray()") {
}
SECTION("createNestedArray(std::string)") {
JsonArray array = variant.createNestedArray(std::string("key"));
JsonArray array = variant.createNestedArray("key"_s);
array.add(42);
REQUIRE(doc.as<std::string>() == "{\"key\":[42]}");
}