mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-25 08:17:32 +02:00
Changed the rules of string duplication (fixes #658)
This commit is contained in:
@ -11,11 +11,6 @@ TEST_CASE("JsonArray::operator[]") {
|
||||
JsonArray& _array = _jsonBuffer.createArray();
|
||||
_array.add(0);
|
||||
|
||||
SECTION("SizeIsUnchanged") {
|
||||
_array[0] = "hello";
|
||||
REQUIRE(1U == _array.size());
|
||||
}
|
||||
|
||||
SECTION("int") {
|
||||
_array[0] = 123;
|
||||
REQUIRE(123 == _array[0].as<int>());
|
||||
@ -103,4 +98,22 @@ TEST_CASE("JsonArray::operator[]") {
|
||||
|
||||
REQUIRE(str == _array[0]);
|
||||
}
|
||||
|
||||
SECTION("should not duplicate const char*") {
|
||||
_array[0] = "world";
|
||||
const size_t expectedSize = JSON_ARRAY_SIZE(1);
|
||||
REQUIRE(expectedSize == _jsonBuffer.size());
|
||||
}
|
||||
|
||||
SECTION("should duplicate char*") {
|
||||
_array[0] = const_cast<char*>("world");
|
||||
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
|
||||
REQUIRE(expectedSize == _jsonBuffer.size());
|
||||
}
|
||||
|
||||
SECTION("should duplicate std::string") {
|
||||
_array[0] = std::string("world");
|
||||
const size_t expectedSize = JSON_ARRAY_SIZE(1) + 6;
|
||||
REQUIRE(expectedSize == _jsonBuffer.size());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user