Added StaticJsonDocument and DynamicJsonDocument.

Removed StaticJsonArray and DynamicJsonArray.
Removed StaticJsonObject and DynamicJsonObject.
Removed StaticJsonVariant and DynamicJsonVariant.
This commit is contained in:
Benoit Blanchon
2018-04-17 21:27:45 +02:00
parent a13b9e8bdc
commit 1feb92679d
100 changed files with 1696 additions and 1844 deletions

View File

@ -6,21 +6,14 @@
#include <catch.hpp>
TEST_CASE("deserializeMsgPack(JsonArray&)") {
DynamicJsonArray array;
SECTION("not an array") {
const char* input = "\xA0";
MsgPackError error = deserializeMsgPack(array, input);
REQUIRE(error == MsgPackError::NotAnArray);
}
DynamicJsonDocument doc;
SECTION("fixarray") {
SECTION("empty") {
const char* input = "\x90";
MsgPackError error = deserializeMsgPack(array, input);
MsgPackError error = deserializeMsgPack(doc, input);
JsonArray& array = doc.as<JsonArray>();
REQUIRE(error == MsgPackError::Ok);
REQUIRE(array.size() == 0);
@ -29,7 +22,8 @@ TEST_CASE("deserializeMsgPack(JsonArray&)") {
SECTION("two integers") {
const char* input = "\x92\x01\x02";
MsgPackError error = deserializeMsgPack(array, input);
MsgPackError error = deserializeMsgPack(doc, input);
JsonArray& array = doc.as<JsonArray>();
REQUIRE(error == MsgPackError::Ok);
REQUIRE(array.size() == 2);
@ -42,7 +36,8 @@ TEST_CASE("deserializeMsgPack(JsonArray&)") {
SECTION("empty") {
const char* input = "\xDC\x00\x00";
MsgPackError error = deserializeMsgPack(array, input);
MsgPackError error = deserializeMsgPack(doc, input);
JsonArray& array = doc.as<JsonArray>();
REQUIRE(error == MsgPackError::Ok);
REQUIRE(array.size() == 0);
@ -51,7 +46,8 @@ TEST_CASE("deserializeMsgPack(JsonArray&)") {
SECTION("two strings") {
const char* input = "\xDC\x00\x02\xA5hello\xA5world";
MsgPackError error = deserializeMsgPack(array, input);
MsgPackError error = deserializeMsgPack(doc, input);
JsonArray& array = doc.as<JsonArray>();
REQUIRE(error == MsgPackError::Ok);
REQUIRE(array.size() == 2);
@ -64,7 +60,8 @@ TEST_CASE("deserializeMsgPack(JsonArray&)") {
SECTION("empty") {
const char* input = "\xDD\x00\x00\x00\x00";
MsgPackError error = deserializeMsgPack(array, input);
MsgPackError error = deserializeMsgPack(doc, input);
JsonArray& array = doc.as<JsonArray>();
REQUIRE(error == MsgPackError::Ok);
REQUIRE(array.size() == 0);
@ -74,7 +71,8 @@ TEST_CASE("deserializeMsgPack(JsonArray&)") {
const char* input =
"\xDD\x00\x00\x00\x02\xCA\x00\x00\x00\x00\xCA\x40\x48\xF5\xC3";
MsgPackError error = deserializeMsgPack(array, input);
MsgPackError error = deserializeMsgPack(doc, input);
JsonArray& array = doc.as<JsonArray>();
REQUIRE(error == MsgPackError::Ok);
REQUIRE(array.size() == 2);