StaticJsonDocument.cpp 799 B

1234567891011121314151617181920212223242526272829303132
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2024, Benoit BLANCHON
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. using ArduinoJson::detail::is_base_of;
  7. TEST_CASE("StaticJsonDocument") {
  8. SECTION("is a JsonDocument") {
  9. REQUIRE(is_base_of<JsonDocument, StaticJsonDocument<256>>::value == true);
  10. }
  11. SECTION("deserialize / serialize") {
  12. StaticJsonDocument<256> doc;
  13. deserializeJson(doc, "{\"hello\":\"world\"}");
  14. REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
  15. }
  16. SECTION("copy") {
  17. StaticJsonDocument<256> doc;
  18. doc["hello"] = "world";
  19. auto copy = doc;
  20. REQUIRE(copy.as<std::string>() == "{\"hello\":\"world\"}");
  21. }
  22. SECTION("capacity") {
  23. StaticJsonDocument<256> doc;
  24. REQUIRE(doc.capacity() == 256);
  25. }
  26. }