as.cpp 484 B

12345678910111213141516171819
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2024, Benoit BLANCHON
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <stdint.h>
  6. #include <catch.hpp>
  7. TEST_CASE("JsonVariantConst::as<T>()") {
  8. JsonDocument doc;
  9. JsonVariantConst var = doc.to<JsonVariant>();
  10. doc.set("hello");
  11. REQUIRE(var.as<bool>() == true);
  12. REQUIRE(var.as<long>() == 0L);
  13. REQUIRE(var.as<const char*>() == std::string("hello"));
  14. REQUIRE(var.as<std::string>() == std::string("hello"));
  15. }