forked from bblanchon/ArduinoJson
Fixed MemberProxy::set(char[]) not duplicating the string (fixes #1191)
This commit is contained in:
@ -8,6 +8,7 @@ HEAD
|
||||
* Added example `JsonFilterExample.ino`
|
||||
* Changed the array subscript operator to automatically add missing elements
|
||||
* Fixed "deprecated-copy" warning on GCC 9 (fixes #1184)
|
||||
* Fixed `MemberProxy::set(char[])` not duplicating the string (issue #1191)
|
||||
|
||||
v6.14.1 (2020-01-27)
|
||||
-------
|
||||
|
@ -23,4 +23,12 @@ TEST_CASE("ElementProxy::add()") {
|
||||
|
||||
REQUIRE(doc.as<std::string>() == "[[\"world\"]]");
|
||||
}
|
||||
|
||||
SECTION("set(char[])") {
|
||||
char s[] = "world";
|
||||
ep.add(s);
|
||||
strcpy(s, "!!!!!");
|
||||
|
||||
REQUIRE(doc.as<std::string>() == "[[\"world\"]]");
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,12 @@ TEST_CASE("ElementProxy::set()") {
|
||||
|
||||
REQUIRE(doc.as<std::string>() == "[\"world\"]");
|
||||
}
|
||||
|
||||
SECTION("set(char[])") {
|
||||
char s[] = "world";
|
||||
ep.set(s);
|
||||
strcpy(s, "!!!!!");
|
||||
|
||||
REQUIRE(doc.as<std::string>() == "[\"world\"]");
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,12 @@ TEST_CASE("MemberProxy::set()") {
|
||||
|
||||
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
|
||||
}
|
||||
|
||||
SECTION("set(char[])") { // issue #1191
|
||||
char s[] = "world";
|
||||
mp.set(s);
|
||||
strcpy(s, "!!!!!");
|
||||
|
||||
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
|
||||
}
|
||||
}
|
||||
|
@ -107,8 +107,7 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >,
|
||||
}
|
||||
|
||||
template <typename TValue>
|
||||
FORCE_INLINE typename enable_if<!is_array<TValue>::value, bool>::type set(
|
||||
const TValue &value) {
|
||||
FORCE_INLINE bool set(const TValue &value) {
|
||||
return getOrAddUpstreamMember().set(value);
|
||||
}
|
||||
|
||||
@ -116,7 +115,7 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >,
|
||||
// set(const char*) const
|
||||
// set(const __FlashStringHelper*) const
|
||||
template <typename TChar>
|
||||
FORCE_INLINE bool set(const TChar *value) {
|
||||
FORCE_INLINE bool set(TChar *value) {
|
||||
return getOrAddUpstreamMember().set(value);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user