8000 Failed to reproduce issue #813 · java64/ArduinoJson@8ac58ce · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8ac58ce

Browse files
committed
Failed to reproduce issue bblanchon#813
1 parent fa1a40a commit 8ac58ce

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/Misc/std_string.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,42 @@ TEST_CASE("std::string") {
241241
REQUIRE(sizeBefore == sizeAfter);
242242
}
243243
}
244+
245+
class NullString {};
246+
247+
namespace ArduinoJson {
248+
namespace Internals {
249+
template <>
250+
struct StringTraits<NullString> {
251+
typedef const char *duplicate_t;
252+
253+
template <typename Buffer>
254+
static duplicate_t duplicate(const NullString &, Buffer *) {
255+
return NULL;
256+
}
257+
258+
static bool is_null(const NullString &) {
259+
return true;
260+
}
261+
262+
static const bool has_append = false;
263+
static const bool has_equals = false;
264+
static const bool should_duplicate = true;
265+
};
266+
} // namespace Internals
267+
} // namespace ArduinoJson
268+
269+
TEST_CASE("A String that returns null") {
270+
DynamicJsonBuffer jb;
271+
272+
SECTION("JsonBuffer_DontGrowWhenReusingKey") {
273+
JsonObject &object = jb.createObject();
274+
std::string key("hello");
275+
276+
object["hello"] = NullString();
277+
278+
std::string json;
279+
object.printTo(json);
280+
REQUIRE(json == "{\"hello\":null}");
281+
}
282+
}

0 commit comments

Comments
 (0)
0