mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 03:52:16 +02:00
34 lines
641 B
C++
34 lines
641 B
C++
// ArduinoJson - arduinojson.org
|
|
// Copyright Benoit Blanchon 2014-2020
|
|
// MIT License
|
|
|
|
#include <ArduinoJson.h>
|
|
#include <catch.hpp>
|
|
|
|
using namespace ARDUINOJSON_NAMESPACE;
|
|
|
|
TEST_CASE("ElementProxy::set()") {
|
|
DynamicJsonDocument doc(4096);
|
|
ElementProxy<JsonDocument&> ep = doc[0];
|
|
|
|
SECTION("set(int)") {
|
|
ep.set(42);
|
|
|
|
REQUIRE(doc.as<std::string>() == "[42]");
|
|
}
|
|
|
|
SECTION("set(const char*)") {
|
|
ep.set("world");
|
|
|
|
REQUIRE(doc.as<std::string>() == "[\"world\"]");
|
|
}
|
|
|
|
SECTION("set(char[])") {
|
|
char s[] = "world";
|
|
ep.set(s);
|
|
strcpy(s, "!!!!!");
|
|
|
|
REQUIRE(doc.as<std::string>() == "[\"world\"]");
|
|
}
|
|
}
|