forked from bblanchon/ArduinoJson
Return JsonArray
and JsonObject
by value (closes #309)
This commit is contained in:
@ -13,7 +13,7 @@ TEST_CASE("deserialize MsgPack array") {
|
||||
const char* input = "\x90";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonArray& array = doc.as<JsonArray>();
|
||||
JsonArray array = doc.as<JsonArray>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(array.size() == 0);
|
||||
@ -23,7 +23,7 @@ TEST_CASE("deserialize MsgPack array") {
|
||||
const char* input = "\x92\x01\x02";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonArray& array = doc.as<JsonArray>();
|
||||
JsonArray array = doc.as<JsonArray>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(array.size() == 2);
|
||||
@ -37,7 +37,7 @@ TEST_CASE("deserialize MsgPack array") {
|
||||
const char* input = "\xDC\x00\x00";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonArray& array = doc.as<JsonArray>();
|
||||
JsonArray array = doc.as<JsonArray>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(array.size() == 0);
|
||||
@ -47,7 +47,7 @@ TEST_CASE("deserialize MsgPack array") {
|
||||
const char* input = "\xDC\x00\x02\xA5hello\xA5world";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonArray& array = doc.as<JsonArray>();
|
||||
JsonArray array = doc.as<JsonArray>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(array.size() == 2);
|
||||
@ -61,7 +61,7 @@ TEST_CASE("deserialize MsgPack array") {
|
||||
const char* input = "\xDD\x00\x00\x00\x00";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonArray& array = doc.as<JsonArray>();
|
||||
JsonArray array = doc.as<JsonArray>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(array.size() == 0);
|
||||
@ -72,7 +72,7 @@ TEST_CASE("deserialize MsgPack array") {
|
||||
"\xDD\x00\x00\x00\x02\xCA\x00\x00\x00\x00\xCA\x40\x48\xF5\xC3";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonArray& array = doc.as<JsonArray>();
|
||||
JsonArray array = doc.as<JsonArray>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(array.size() == 2);
|
||||
|
@ -13,7 +13,7 @@ TEST_CASE("deserialize MsgPack object") {
|
||||
const char* input = "\x80";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonObject& obj = doc.as<JsonObject>();
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
@ -24,7 +24,7 @@ TEST_CASE("deserialize MsgPack object") {
|
||||
const char* input = "\x82\xA3one\x01\xA3two\x02";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonObject& obj = doc.as<JsonObject>();
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
@ -39,7 +39,7 @@ TEST_CASE("deserialize MsgPack object") {
|
||||
const char* input = "\xDE\x00\x00";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonObject& obj = doc.as<JsonObject>();
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
@ -50,7 +50,7 @@ TEST_CASE("deserialize MsgPack object") {
|
||||
const char* input = "\xDE\x00\x02\xA1H\xA5hello\xA1W\xA5world";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonObject& obj = doc.as<JsonObject>();
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
@ -65,7 +65,7 @@ TEST_CASE("deserialize MsgPack object") {
|
||||
const char* input = "\xDF\x00\x00\x00\x00";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonObject& obj = doc.as<JsonObject>();
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
@ -78,7 +78,7 @@ TEST_CASE("deserialize MsgPack object") {
|
||||
"\xF5\xC3";
|
||||
|
||||
DeserializationError error = deserializeMsgPack(doc, input);
|
||||
JsonObject& obj = doc.as<JsonObject>();
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
|
||||
REQUIRE(error == DeserializationError::Ok);
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
|
@ -14,7 +14,7 @@ TEST_CASE("deserializeMsgPack(std::istream&)") {
|
||||
DeserializationError err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
JsonArray& arr = doc.as<JsonArray>();
|
||||
JsonArray arr = doc.as<JsonArray>();
|
||||
REQUIRE(arr[0] == 0);
|
||||
REQUIRE(arr[1] == 2);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ TEST_CASE("deserializeMsgPack(const std::string&)") {
|
||||
DeserializationError err = deserializeMsgPack(doc, input);
|
||||
input[2] = 'X'; // alter the string tomake sure we made a copy
|
||||
|
||||
JsonArray& array = doc.as<JsonArray>();
|
||||
JsonArray array = doc.as<JsonArray>();
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
REQUIRE(std::string("hello") == array[0]);
|
||||
}
|
||||
@ -39,7 +39,7 @@ TEST_CASE("deserializeMsgPack(const std::string&)") {
|
||||
deserializeMsgPack(doc, std::string("\x92\x00\x02", 3));
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
JsonArray& arr = doc.as<JsonArray>();
|
||||
JsonArray arr = doc.as<JsonArray>();
|
||||
REQUIRE(arr[0] == 0);
|
||||
REQUIRE(arr[1] == 2);
|
||||
}
|
||||
|
Reference in New Issue
Block a user