Added JsonError

This commit is contained in:
Benoit Blanchon
2018-03-09 16:58:01 +01:00
parent 83d73c93f7
commit b2a8085651
24 changed files with 641 additions and 515 deletions

View File

@ -56,9 +56,9 @@ TEST_CASE("std::stream") {
SECTION("ParseArray") {
std::istringstream json(" [ 42 /* comment */ ] ");
DynamicJsonArray arr;
bool success = deserializeJson(arr, json);
JsonError err = deserializeJson(arr, json);
REQUIRE(true == success);
REQUIRE(err == JsonError::Ok);
REQUIRE(1 == arr.size());
REQUIRE(42 == arr[0]);
}
@ -66,9 +66,9 @@ TEST_CASE("std::stream") {
SECTION("ParseObject") {
std::istringstream json(" { hello : world // comment\n }");
DynamicJsonObject obj;
bool success = deserializeJson(obj, json);
JsonError err = deserializeJson(obj, json);
REQUIRE(true == success);
REQUIRE(err == JsonError::Ok);
REQUIRE(1 == obj.size());
REQUIRE(std::string("world") == obj["hello"]);
}

View File

@ -19,10 +19,10 @@ TEST_CASE("std::string") {
SECTION("deserializeJson") {
std::string json("[\"hello\"]");
bool success = deserializeJson(array, json);
JsonError err = deserializeJson(array, json);
eraseString(json);
REQUIRE(true == success);
REQUIRE(err == JsonError::Ok);
REQUIRE(std::string("hello") == array[0]);
}
@ -72,10 +72,10 @@ TEST_CASE("std::string") {
SECTION("deserializeJson()") {
std::string json("{\"hello\":\"world\"}");
bool success = deserializeJson(object, json);
JsonError err = deserializeJson(object, json);
eraseString(json);
REQUIRE(true == success);
REQUIRE(err == JsonError::Ok);
REQUIRE(std::string("world") == object["hello"]);
}

View File

@ -14,18 +14,18 @@ TEST_CASE("unsigned char string") {
unsigned char json[] = "[42]";
StaticJsonArray<JSON_ARRAY_SIZE(1)> arr;
bool success = deserializeJson(arr, json);
JsonError err = deserializeJson(arr, json);
REQUIRE(true == success);
REQUIRE(err == JsonError::Ok);
}
SECTION("JsonBuffer::parseObject") {
unsigned char json[] = "{\"a\":42}";
StaticJsonObject<JSON_OBJECT_SIZE(1)> obj;
bool success = deserializeJson(obj, json);
JsonError err = deserializeJson(obj, json);
REQUIRE(true == success);
REQUIRE(err == JsonError::Ok);
}
SECTION("JsonVariant constructor") {

View File

@ -23,9 +23,9 @@ TEST_CASE("Variable Length Array") {
strcpy(vla, "[42]");
StaticJsonArray<JSON_ARRAY_SIZE(1)> arr;
bool success = deserializeJson(arr, vla);
JsonError err = deserializeJson(arr, vla);
REQUIRE(true == success);
REQUIRE(err == JsonError::Ok);
}
SECTION("ParseObject") {