clear.cpp 680 B

123456789101112131415161718192021222324252627282930
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2025, Benoit BLANCHON
  3. // MIT License
  4. #include <ArduinoJson/Memory/ResourceManager.hpp>
  5. #include <ArduinoJson/Strings/StringAdapters.hpp>
  6. #include <catch.hpp>
  7. using namespace ArduinoJson::detail;
  8. TEST_CASE("ResourceManager::clear()") {
  9. ResourceManager resources;
  10. SECTION("Discards allocated variants") {
  11. resources.allocVariant();
  12. resources.clear();
  13. REQUIRE(resources.size() == 0);
  14. }
  15. SECTION("Discards allocated strings") {
  16. resources.saveString(adaptString("123456789"));
  17. REQUIRE(resources.size() == sizeofString(9));
  18. resources.clear();
  19. REQUIRE(resources.size() == 0);
  20. }
  21. }