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,7 @@
#include <catch.hpp>
#include "Allocators.hpp"
#include "Literals.hpp"
TEST_CASE("JsonArray::operator[]") {
SpyingAllocator spy;
@ -129,7 +130,7 @@ TEST_CASE("JsonArray::operator[]") {
}
SECTION("should duplicate std::string") {
array[0] = std::string("world");
array[0] = "world"_s;
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("world")),
@ -150,7 +151,7 @@ TEST_CASE("JsonArray::operator[]") {
array.add("hello");
array[0].set(vla);
REQUIRE(std::string("world") == array[0]);
REQUIRE("world"_s == array[0]);
}
SECTION("operator=(VLA)") {
@ -161,7 +162,7 @@ TEST_CASE("JsonArray::operator[]") {
array.add("hello");
array[0] = vla;
REQUIRE(std::string("world") == array[0]);
REQUIRE("world"_s == array[0]);
}
#endif