forked from bblanchon/ArduinoJson
Return JsonArray
and JsonObject
by value (closes #309)
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
|
||||
TEST_CASE("serialize MsgPack to various destination types") {
|
||||
DynamicJsonDocument doc;
|
||||
JsonObject &object = doc.to<JsonObject>();
|
||||
JsonObject object = doc.to<JsonObject>();
|
||||
object["hello"] = "world";
|
||||
const char *expected_result = "\x81\xA5hello\xA5world";
|
||||
const size_t expected_length = 13;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
TEST_CASE("measureMsgPack()") {
|
||||
DynamicJsonDocument doc;
|
||||
JsonObject &object = doc.to<JsonObject>();
|
||||
JsonObject object = doc.to<JsonObject>();
|
||||
object["hello"] = "world";
|
||||
|
||||
REQUIRE(measureMsgPack(doc) == 13);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
static void check(const JsonArray& array, const char* expected_data,
|
||||
static void check(const JsonArray array, const char* expected_data,
|
||||
size_t expected_len) {
|
||||
std::string expected(expected_data, expected_data + expected_len);
|
||||
std::string actual;
|
||||
@ -16,19 +16,19 @@ static void check(const JsonArray& array, const char* expected_data,
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
static void check(const JsonArray& array, const char (&expected_data)[N]) {
|
||||
static void check(const JsonArray array, const char (&expected_data)[N]) {
|
||||
const size_t expected_len = N - 1;
|
||||
check(array, expected_data, expected_len);
|
||||
}
|
||||
|
||||
// TODO: this function is used by the commented test
|
||||
// static void check(const JsonArray& array, const std::string& expected) {
|
||||
// static void check(const JsonArray array, const std::string& expected) {
|
||||
// check(array, expected.data(), expected.length());
|
||||
// }
|
||||
|
||||
TEST_CASE("serialize MsgPack array") {
|
||||
DynamicJsonDocument doc;
|
||||
JsonArray& array = doc.to<JsonArray>();
|
||||
JsonArray array = doc.to<JsonArray>();
|
||||
|
||||
SECTION("empty") {
|
||||
check(array, "\x90");
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
static void check(const JsonObject& object, const char* expected_data,
|
||||
static void check(const JsonObject object, const char* expected_data,
|
||||
size_t expected_len) {
|
||||
std::string expected(expected_data, expected_data + expected_len);
|
||||
std::string actual;
|
||||
@ -17,19 +17,19 @@ static void check(const JsonObject& object, const char* expected_data,
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
static void check(const JsonObject& object, const char (&expected_data)[N]) {
|
||||
static void check(const JsonObject object, const char (&expected_data)[N]) {
|
||||
const size_t expected_len = N - 1;
|
||||
check(object, expected_data, expected_len);
|
||||
}
|
||||
|
||||
// TODO: used by the commented test
|
||||
// static void check(const JsonObject& object, const std::string& expected) {
|
||||
// static void check(const JsonObject object, const std::string& expected) {
|
||||
// check(object, expected.data(), expected.length());
|
||||
//}
|
||||
|
||||
TEST_CASE("serialize MsgPack object") {
|
||||
DynamicJsonDocument doc;
|
||||
JsonObject& object = doc.to<JsonObject>();
|
||||
JsonObject object = doc.to<JsonObject>();
|
||||
|
||||
SECTION("empty") {
|
||||
check(object, "\x80");
|
||||
|
Reference in New Issue
Block a user