is.cpp 572 B

12345678910111213141516171819202122232425262728
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2018
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. TEST_CASE("JsonObject::is<T>()") {
  7. DynamicJsonDocument doc;
  8. JsonObject obj = doc.to<JsonObject>();
  9. obj["int"] = 42;
  10. obj["str"] = "hello";
  11. SECTION("is<int>(const char*)") {
  12. REQUIRE(true == obj.is<int>("int"));
  13. REQUIRE(false == obj.is<int>("str"));
  14. }
  15. #if HAS_VARIABLE_LENGTH_ARRAY
  16. SECTION("is<T>(VLA)") {
  17. int i = 16;
  18. char vla[i];
  19. strcpy(vla, "int");
  20. REQUIRE(true == obj.is<int>(vla));
  21. }
  22. #endif
  23. }