RawJson() accepts any kind of string and obeys to duplication rules

This commit is contained in:
Benoit Blanchon
2018-01-18 09:43:37 +01:00
parent 7e4fcb0868
commit bae179ed67
20 changed files with 163 additions and 123 deletions

View File

@ -84,7 +84,7 @@ TEST_CASE("JsonArray::add()") {
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should duplicate char*") {
SECTION("should duplicate char*") {
_array.add(const_cast<char*>("world"));
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
REQUIRE(expectedSize == _jsonBuffer.size());
@ -95,4 +95,16 @@ TEST_CASE("JsonArray::add()") {
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should not duplicate RawJson(const char*)") {
_array.add(RawJson("{}"));
const size_t expectedSize = JSON_ARRAY_SIZE(1);
REQUIRE(expectedSize == _jsonBuffer.size());
}
SECTION("should duplicate RawJson(char*)") {
_array.add(RawJson(const_cast<char*>("{}")));
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 3;
REQUIRE(expectedSize == _jsonBuffer.size());
}
}