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

@ -6,6 +6,8 @@
#include <catch.hpp>
#include "Allocators.hpp"
#include "Literals.hpp"
TEST_CASE("JsonVariant::set(JsonVariant)") {
KillswitchAllocator killswitch;
SpyingAllocator spyingAllocator(&killswitch);
@ -72,7 +74,7 @@ TEST_CASE("JsonVariant::set(JsonVariant)") {
}
SECTION("stores std::string by copy") {
var1.set(std::string("hello!!"));
var1.set("hello!!"_s);
spyingAllocator.clearLog();
var2.set(var1);
@ -106,7 +108,7 @@ TEST_CASE("JsonVariant::set(JsonVariant)") {
}
SECTION("stores Serialized<std::string> by copy") {
var1.set(serialized(std::string("hello!!")));
var1.set(serialized("hello!!"_s));
spyingAllocator.clearLog();
var2.set(var1);
@ -117,7 +119,7 @@ TEST_CASE("JsonVariant::set(JsonVariant)") {
}
SECTION("fails gracefully if raw string allocation fails") {
var1.set(serialized(std::string("hello!!")));
var1.set(serialized("hello!!"_s));
killswitch.on();
spyingAllocator.clearLog();