Files
ArduinoJson/extras/tests/JsonArray/clear.cpp
T

26 lines
576 B
C++
Raw Normal View History

2021-06-26 11:23:40 +02:00
// ArduinoJson - https://arduinojson.org
2026-03-02 15:22:38 +01:00
// Copyright © 2014-2026, Benoit BLANCHON
2021-06-26 11:23:40 +02:00
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::clear()") {
SECTION("No-op on null JsonArray") {
JsonArray array;
array.clear();
REQUIRE(array.isNull() == true);
REQUIRE(array.size() == 0);
}
SECTION("Removes all elements") {
StaticJsonDocument<64> doc;
JsonArray array = doc.to<JsonArray>();
array.add(1);
array.add(2);
array.clear();
REQUIRE(array.size() == 0);
REQUIRE(array.isNull() == false);
}
}