mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-29 18:27:37 +02:00
Add a stub for StaticJsonDocument
This commit is contained in:
@ -12,6 +12,7 @@ link_libraries(ArduinoJson catch)
|
||||
include_directories(Helpers)
|
||||
add_subdirectory(Cpp17)
|
||||
add_subdirectory(Cpp20)
|
||||
add_subdirectory(Deprecated)
|
||||
add_subdirectory(FailingBuilds)
|
||||
add_subdirectory(IntegrationTests)
|
||||
add_subdirectory(JsonArray)
|
||||
|
26
extras/tests/Deprecated/CMakeLists.txt
Normal file
26
extras/tests/Deprecated/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
# ArduinoJson - https://arduinojson.org
|
||||
# Copyright © 2014-2023, Benoit BLANCHON
|
||||
# MIT License
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
||||
add_compile_options(
|
||||
-Wno-deprecated-declarations
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options(
|
||||
/wd4996
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(DeprecatedTests
|
||||
StaticJsonDocument.cpp
|
||||
)
|
||||
|
||||
add_test(Deprecated DeprecatedTests)
|
||||
|
||||
set_tests_properties(Deprecated
|
||||
PROPERTIES
|
||||
LABELS "Catch"
|
||||
)
|
32
extras/tests/Deprecated/StaticJsonDocument.cpp
Normal file
32
extras/tests/Deprecated/StaticJsonDocument.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
using ArduinoJson::detail::is_base_of;
|
||||
|
||||
TEST_CASE("StaticJsonDocument") {
|
||||
SECTION("is a JsonDocument") {
|
||||
REQUIRE(is_base_of<JsonDocument, StaticJsonDocument<256>>::value == true);
|
||||
}
|
||||
|
||||
SECTION("deserialize / serialize") {
|
||||
StaticJsonDocument<256> doc;
|
||||
deserializeJson(doc, "{\"hello\":\"world\"}");
|
||||
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
|
||||
}
|
||||
|
||||
SECTION("copy") {
|
||||
StaticJsonDocument<256> doc;
|
||||
doc["hello"] = "world";
|
||||
auto copy = doc;
|
||||
REQUIRE(copy.as<std::string>() == "{\"hello\":\"world\"}");
|
||||
}
|
||||
|
||||
SECTION("capacity") {
|
||||
StaticJsonDocument<256> doc;
|
||||
REQUIRE(doc.capacity() == 256);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user