Fixed enums serialized as booleans (fixes #1197)

This commit is contained in:
Benoit Blanchon
2020-02-26 16:16:20 +01:00
parent 0214c9bcad
commit 2996503b27
9 changed files with 149 additions and 1 deletions

View File

@ -5,6 +5,8 @@
#include <ArduinoJson.h>
#include <catch.hpp>
enum ErrorCode { ERROR_01 = 1, ERROR_10 = 10 };
TEST_CASE("JsonVariant and strings") {
DynamicJsonDocument doc(4096);
JsonVariant variant = doc.to<JsonVariant>();
@ -91,6 +93,15 @@ TEST_CASE("JsonVariant and strings") {
REQUIRE(variant == "hello");
}
SECTION("stores an enum as an integer") {
ErrorCode code = ERROR_10;
variant.set(code);
REQUIRE(variant.is<int>() == true);
REQUIRE(variant.as<int>() == 10);
}
}
TEST_CASE("JsonVariant with not enough memory") {