mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Fixed return value of JsonObject::set() (issue #350)
This commit is contained in:
@@ -107,3 +107,21 @@ TEST_(StoreObjectSubscript) {
|
||||
|
||||
EXPECT_EQ(42, _object["a"]);
|
||||
}
|
||||
|
||||
TEST_(ShouldReturnTrue_WhenAllocationSucceeds) {
|
||||
StaticJsonBuffer<JSON_OBJECT_SIZE(1) + 15> jsonBuffer;
|
||||
JsonObject& obj = jsonBuffer.createObject();
|
||||
|
||||
bool result = obj.set(String("hello"), String("world"));
|
||||
|
||||
ASSERT_TRUE(result);
|
||||
}
|
||||
|
||||
TEST_(ShouldReturnFalse_WhenAllocationFails) {
|
||||
StaticJsonBuffer<JSON_OBJECT_SIZE(1) + 10> jsonBuffer;
|
||||
JsonObject& obj = jsonBuffer.createObject();
|
||||
|
||||
bool result = obj.set(String("hello"), String("world"));
|
||||
|
||||
ASSERT_FALSE(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user