Skip to content

Commit cd5566c

Browse files
committed
Add a test for #1922
1 parent 52d8a65 commit cd5566c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

extras/tests/JsonVariant/converters.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,16 @@ TEST_CASE("ConverterNeedsWriteableRef") {
152152
CHECK(ConverterNeedsWriteableRef<JsonArray>::value == true);
153153
CHECK(ConverterNeedsWriteableRef<JsonArrayConst>::value == false);
154154
}
155+
156+
namespace ArduinoJson {
157+
void convertToJson(char c, JsonVariant var) {
158+
char buf[] = {c, 0};
159+
var.set(buf);
160+
}
161+
} // namespace ArduinoJson
162+
163+
TEST_CASE("Convert char to string") { // issue #1922
164+
StaticJsonDocument<64> doc;
165+
doc.set('a');
166+
REQUIRE(doc.as<std::string>() == "a");
167+
}

0 commit comments

Comments
 (0)