Tests: remove duplicate test of incomplete input

This commit is contained in:
Benoit Blanchon
2023-07-27 14:31:56 +02:00
parent 9a11d98117
commit 9122d87f12
2 changed files with 30 additions and 49 deletions

View File

@ -7,15 +7,36 @@
#include <catch.hpp> #include <catch.hpp>
TEST_CASE("Truncated JSON input") { TEST_CASE("Truncated JSON input") {
const char* testCases[] = {"\"hello", "\'hello", "'\\u", "'\\u00", "'\\u000", const char* testCases[] = {
// strings
"\"\\",
"\"hello",
"\'hello",
// unicode
"'\\u",
"'\\u00",
"'\\u000",
// false // false
"f", "fa", "fal", "fals", "f",
"fa",
"fal",
"fals",
// true // true
"t", "tr", "tru", "t",
"tr",
"tru",
// null // null
"n", "nu", "nul", "n",
"nu",
"nul",
// object // object
"{", "{a", "{a:", "{a:1", "{a:1,", "{a:1,"}; "{",
"{a",
"{a:",
"{a:1",
"{a:1,",
"{a:1,",
};
const size_t testCount = sizeof(testCases) / sizeof(testCases[0]); const size_t testCount = sizeof(testCases) / sizeof(testCases[0]);
JsonDocument doc; JsonDocument doc;

View File

@ -72,46 +72,6 @@ TEST_CASE("deserializeJson(JsonDocument&)") {
} }
} }
SECTION("Premature null-terminator") {
SECTION("In escape sequence") {
DeserializationError err = deserializeJson(doc, "\"\\");
REQUIRE(err == DeserializationError::IncompleteInput);
}
SECTION("In double quoted string") {
DeserializationError err = deserializeJson(doc, "\"hello");
REQUIRE(err == DeserializationError::IncompleteInput);
}
SECTION("In single quoted string") {
DeserializationError err = deserializeJson(doc, "'hello");
REQUIRE(err == DeserializationError::IncompleteInput);
}
}
SECTION("Premature end of input") {
SECTION("In escape sequence") {
DeserializationError err = deserializeJson(doc, "\"\\n\"", 2);
REQUIRE(err == DeserializationError::IncompleteInput);
}
SECTION("In double quoted string") {
DeserializationError err = deserializeJson(doc, "\"hello\"", 6);
REQUIRE(err == DeserializationError::IncompleteInput);
}
SECTION("In single quoted string") {
DeserializationError err = deserializeJson(doc, "'hello'", 6);
REQUIRE(err == DeserializationError::IncompleteInput);
}
}
SECTION("Should clear the JsonVariant") { SECTION("Should clear the JsonVariant") {
deserializeJson(doc, "[1,2,3]"); deserializeJson(doc, "[1,2,3]");
deserializeJson(doc, "{}"); deserializeJson(doc, "{}");