mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 20:12:16 +02:00
Added tests for Flash strings (closes #1070)
This commit is contained in:
53
test/MixedConfiguration/enable_progmem_1.cpp
Normal file
53
test/MixedConfiguration/enable_progmem_1.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2019
|
||||
// MIT License
|
||||
|
||||
#include "progmem_emulation.hpp"
|
||||
|
||||
#define ARDUINOJSON_ENABLE_PROGMEM 1
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("Flash strings") {
|
||||
DynamicJsonDocument doc(2048);
|
||||
|
||||
SECTION("deserializeJson()") {
|
||||
DeserializationError err = deserializeJson(doc, F("{'hello':'world'}"));
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
REQUIRE(doc["hello"] == "world");
|
||||
}
|
||||
|
||||
SECTION("JsonDocument::operator[]") {
|
||||
doc[F("hello")] = F("world");
|
||||
|
||||
REQUIRE(doc["hello"] == "world");
|
||||
}
|
||||
|
||||
SECTION("JsonDocument::add()") {
|
||||
doc.add(F("world"));
|
||||
|
||||
REQUIRE(doc[0] == "world");
|
||||
}
|
||||
|
||||
SECTION("JsonVariant::set()") {
|
||||
JsonVariant var = doc.to<JsonVariant>();
|
||||
|
||||
var.set(F("world"));
|
||||
|
||||
REQUIRE(var == "world");
|
||||
}
|
||||
|
||||
SECTION("MemberProxy::operator==") {
|
||||
doc["hello"] = "world";
|
||||
|
||||
REQUIRE(doc["hello"] == F("world"));
|
||||
}
|
||||
|
||||
SECTION("ElementProxy::operator==") {
|
||||
doc.add("world");
|
||||
|
||||
REQUIRE(doc[0] == F("world"));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user