mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-23 23:37:37 +02:00
Rename tests in MixedConfiguration
This commit is contained in:
@ -7,83 +7,89 @@
|
||||
TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 1") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("set() returns true if string has 255 characters") {
|
||||
auto result = doc.set(std::string(255, '?'));
|
||||
SECTION("set(std::string)") {
|
||||
SECTION("returns true if len <= 255") {
|
||||
auto result = doc.set(std::string(255, '?'));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if len >= 256") {
|
||||
auto result = doc.set(std::string(256, '?'));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set() returns false if string has 256 characters") {
|
||||
auto result = doc.set(std::string(256, '?'));
|
||||
SECTION("set(MsgPackBinary)") {
|
||||
SECTION("returns true if size <= 253") {
|
||||
auto str = std::string(253, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if size >= 254") {
|
||||
auto str = std::string(254, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set() returns true if binary has 253 characters") {
|
||||
auto str = std::string(253, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
SECTION("deserializeJson()") {
|
||||
SECTION("returns Ok if string length <= 255") {
|
||||
auto input = "\"" + std::string(255, '?') + "\"";
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if string length >= 256") {
|
||||
auto input = "\"" + std::string(256, '?') + "\"";
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set() returns false if binary has 254 characters") {
|
||||
auto str = std::string(254, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
SECTION("deserializeMsgPack()") {
|
||||
SECTION("returns Ok if string length <= 255") {
|
||||
auto input = "\xd9\xff" + std::string(255, '?');
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
SECTION("deserializeJson() returns Ok if string has 255 characters") {
|
||||
auto input = "\"" + std::string(255, '?') + "\"";
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
SECTION("returns NoMemory if string length >= 256") {
|
||||
auto input = std::string("\xda\x01\x00", 3) + std::string(256, '?');
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
SECTION("deserializeJson() returns NoMemory if string has 256 characters") {
|
||||
auto input = "\"" + std::string(256, '?') + "\"";
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
SECTION("returns Ok if binary size <= 253") {
|
||||
auto input = "\xc4\xfd" + std::string(253, '?');
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
SECTION("deserializeMsgPack() returns Ok if string has 255 characters") {
|
||||
auto input = "\xd9\xff" + std::string(255, '?');
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
SECTION("returns NoMemory if binary size >= 254") {
|
||||
auto input = "\xc4\xfe" + std::string(254, '?');
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
SECTION(
|
||||
"deserializeMsgPack() returns NoMemory if string has 256 characters") {
|
||||
auto input = std::string("\xda\x01\x00", 3) + std::string(256, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
SECTION("deserializeMsgPack() returns Ok if binary has 253 characters") {
|
||||
auto input = "\xc4\xfd" + std::string(253, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION(
|
||||
"deserializeMsgPack() returns NoMemory if binary has 254 characters") {
|
||||
auto input = "\xc4\xfe" + std::string(254, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,84 +7,90 @@
|
||||
TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 2") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("set() returns true if string has 65535 characters") {
|
||||
auto result = doc.set(std::string(65535, '?'));
|
||||
SECTION("set(std::string)") {
|
||||
SECTION("returns true if len <= 65535") {
|
||||
auto result = doc.set(std::string(65535, '?'));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if len >= 65536") {
|
||||
auto result = doc.set(std::string(65536, '?'));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set() returns false if string has 65536 characters") {
|
||||
auto result = doc.set(std::string(65536, '?'));
|
||||
SECTION("set(MsgPackBinary)") {
|
||||
SECTION("returns true if size <= 65532") {
|
||||
auto str = std::string(65532, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if size >= 65533") {
|
||||
auto str = std::string(65533, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set() returns true if string has 65532 characters") {
|
||||
auto str = std::string(65532, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
SECTION("deserializeJson()") {
|
||||
SECTION("returns Ok if string length <= 65535") {
|
||||
auto input = "\"" + std::string(65535, '?') + "\"";
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if string length >= 65536") {
|
||||
auto input = "\"" + std::string(65536, '?') + "\"";
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set() returns false if string has 65533 characters") {
|
||||
auto str = std::string(65533, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
SECTION("deserializeMsgPack()") {
|
||||
SECTION("returns Ok if string length <= 65535") {
|
||||
auto input = "\xda\xff\xff" + std::string(65535, '?');
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
SECTION("deserializeJson() returns Ok if string has 65535 characters") {
|
||||
auto input = "\"" + std::string(65535, '?') + "\"";
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
SECTION("returns NoMemory if string length >= 65536") {
|
||||
auto input =
|
||||
std::string("\xdb\x00\x01\x00\x00", 5) + std::string(65536, '?');
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
SECTION("deserializeJson() returns NoMemory if string has 65536 characters") {
|
||||
auto input = "\"" + std::string(65536, '?') + "\"";
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
SECTION("returns Ok if binary size <= 65532") {
|
||||
auto input = "\xc5\xff\xfc" + std::string(65532, '?');
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
SECTION("deserializeMsgPack() returns Ok if string has 65535 characters") {
|
||||
auto input = "\xda\xff\xff" + std::string(65535, '?');
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
SECTION("returns NoMemory if binary size >= 65534") {
|
||||
auto input = "\xc5\xff\xfd" + std::string(65534, '?');
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
SECTION(
|
||||
"deserializeMsgPack() returns NoMemory if string has 65536 characters") {
|
||||
auto input =
|
||||
std::string("\xdb\x00\x01\x00\x00", 5) + std::string(65536, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
SECTION("deserializeMsgPack() returns Ok if binary has 65532 characters") {
|
||||
auto input = "\xc5\xff\xfc" + std::string(65532, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION(
|
||||
"deserializeMsgPack() returns NoMemory of binary has 65534 characters") {
|
||||
auto input = "\xc5\xff\xfd" + std::string(65534, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,43 +7,51 @@
|
||||
TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 4") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("set() returns true if string has 65536 characters") {
|
||||
auto result = doc.set(std::string(65536, '?'));
|
||||
SECTION("set(std::string)") {
|
||||
SECTION("returns true if string length >= 65536") {
|
||||
auto result = doc.set(std::string(65536, '?'));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set() returns true if binary has 65536 characters") {
|
||||
auto str = std::string(65536, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
SECTION("set(MsgPackBinary)") {
|
||||
SECTION("returns true if size >= 65536") {
|
||||
auto str = std::string(65536, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("deserializeJson() returns Ok if string has 65536 characters") {
|
||||
auto input = "\"" + std::string(65536, '?') + "\"";
|
||||
SECTION("deserializeJson()") {
|
||||
SECTION("returns Ok if string length >= 65536") {
|
||||
auto input = "\"" + std::string(65536, '?') + "\"";
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("deserializeMsgPack() returns Ok if string has 65536 characters") {
|
||||
auto input = "\xda\xff\xff" + std::string(65536, '?');
|
||||
SECTION("deserializeMsgPack()") {
|
||||
SECTION("returns Ok if string size >= 65536") {
|
||||
auto input = "\xda\xff\xff" + std::string(65536, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("deserializeMsgPack() returns Ok if binary has 65536 characters") {
|
||||
auto input = "\xc5\xff\xff" + std::string(65536, '?');
|
||||
SECTION("returns Ok if binary size >= 65536") {
|
||||
auto input = "\xc5\xff\xff" + std::string(65536, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("bin 32 deserialization") {
|
||||
|
Reference in New Issue
Block a user