Merged MsgPackError and JsonError into DeserializationError.

Return NotSupported if the JSON input contains "\u".
This commit is contained in:
Benoit Blanchon
2018-05-15 18:23:09 +02:00
parent ccb54136a2
commit 4592f23260
38 changed files with 574 additions and 636 deletions

View File

@ -0,0 +1,46 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
void testStringification(DeserializationError error, std::string expected) {
REQUIRE(error.c_str() == expected);
}
void testBoolification(DeserializationError error, bool expected) {
CHECK(error == expected);
}
#define TEST_STRINGIFICATION(symbol) \
testStringification(DeserializationError::symbol, #symbol)
#define TEST_BOOLIFICATION(symbol, expected) \
testBoolification(DeserializationError::symbol, expected)
TEST_CASE("DeserializationError") {
SECTION("c_str()") {
TEST_STRINGIFICATION(Ok);
TEST_STRINGIFICATION(TooDeep);
TEST_STRINGIFICATION(NoMemory);
TEST_STRINGIFICATION(InvalidInput);
TEST_STRINGIFICATION(IncompleteInput);
TEST_STRINGIFICATION(NotSupported);
}
SECTION("as boolean") {
TEST_BOOLIFICATION(Ok, false);
TEST_BOOLIFICATION(TooDeep, true);
TEST_BOOLIFICATION(NoMemory, true);
TEST_BOOLIFICATION(InvalidInput, true);
TEST_BOOLIFICATION(IncompleteInput, true);
TEST_BOOLIFICATION(NotSupported, true);
}
SECTION("ostream") {
std::stringstream s;
s << DeserializationError::InvalidInput;
REQUIRE(s.str() == "InvalidInput");
}
}