set.cpp 529 B

12345678910111213141516171819202122232425
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2019
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. using namespace ARDUINOJSON_NAMESPACE;
  7. TEST_CASE("MemberProxy::set()") {
  8. DynamicJsonDocument doc(4096);
  9. MemberProxy<JsonDocument&, const char*> mp = doc["hello"];
  10. SECTION("set(int)") {
  11. mp.set(42);
  12. REQUIRE(doc.as<std::string>() == "{\"hello\":42}");
  13. }
  14. SECTION("set(const char*)") {
  15. mp.set("world");
  16. REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
  17. }
  18. }