mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 12:02:14 +02:00
Test that doubles in JsonValue are copied
This commit is contained in:
@ -61,10 +61,16 @@ void JsonValue::operator=(JsonValue const& value)
|
||||
_node->content.asInteger = value._node->content.asInteger;
|
||||
break;
|
||||
|
||||
case JSON_DOUBLE_0_DECIMALS:
|
||||
|
||||
case JSON_OBJECT:
|
||||
case JSON_ARRAY:
|
||||
case JSON_PROXY:
|
||||
setAsProxyTo(value._node);
|
||||
|
||||
default:
|
||||
*_node = *value._node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,12 +59,20 @@ TEST_F(JsonValueTests, CanStoreObject)
|
||||
EXPECT_EQ(innerObject1, (JsonObject) jsonValue1);
|
||||
}
|
||||
|
||||
TEST_F(JsonValueTests, CanCopyInteger)
|
||||
TEST_F(JsonValueTests, IntegerValuesAreCopied)
|
||||
{
|
||||
jsonValue1 = 123;
|
||||
jsonValue2 = jsonValue1;
|
||||
jsonValue1 = 456;
|
||||
|
||||
EXPECT_EQ(456, (int) jsonValue1);
|
||||
EXPECT_EQ(123, (int) jsonValue2);
|
||||
}
|
||||
|
||||
TEST_F(JsonValueTests, DoubleValuesAreCopied)
|
||||
{
|
||||
jsonValue1 = 123.45;
|
||||
jsonValue2 = jsonValue1;
|
||||
jsonValue1 = 456.78;
|
||||
|
||||
EXPECT_EQ(123.45, (double) jsonValue2);
|
||||
}
|
Reference in New Issue
Block a user