Reformat filters test file

This commit is contained in:
Benoit Blanchon
2023-07-31 17:34:53 +02:00
parent 218a12ca46
commit 3003756adb

View File

@@ -24,7 +24,6 @@ TEST_CASE("Filtering") {
size_t memoryUsage; size_t memoryUsage;
}; };
// clang-format off
TestCase testCases[] = { TestCase testCases[] = {
{ {
"{\"hello\":\"world\"}", // 1. input "{\"hello\":\"world\"}", // 1. input
@@ -32,7 +31,7 @@ TEST_CASE("Filtering") {
10, // 3. nestingLimit 10, // 3. nestingLimit
DeserializationError::Ok, // 4. error DeserializationError::Ok, // 4. error
"null", // 5. output "null", // 5. output
0 // 6. memoryUsage 0, // 6. memoryUsage
}, },
{ {
"{\"hello\":\"world\"}", "{\"hello\":\"world\"}",
@@ -40,7 +39,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"null", "null",
0 0,
}, },
{ {
"{\"abcdefg\":\"hijklmn\"}", "{\"abcdefg\":\"hijklmn\"}",
@@ -48,7 +47,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"abcdefg\":\"hijklmn\"}", "{\"abcdefg\":\"hijklmn\"}",
sizeofObject(1) + sizeofString("abcdefg") + sizeofString("hijklmn") sizeofObject(1) + sizeofString("abcdefg") + sizeofString("hijklmn"),
}, },
{ {
"{\"hello\":\"world\"}", "{\"hello\":\"world\"}",
@@ -56,7 +55,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{}", "{}",
sizeofObject(0) sizeofObject(0),
}, },
{ {
// Input in an object, but filter wants an array // Input in an object, but filter wants an array
@@ -65,7 +64,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"null", "null",
0 0,
}, },
{ {
// Member is a string, but filter wants an array // Member is a string, but filter wants an array
@@ -74,7 +73,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":null}", "{\"example\":null}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// Member is a number, but filter wants an array // Member is a number, but filter wants an array
@@ -83,7 +82,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":null}", "{\"example\":null}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// Input is an array, but filter wants an object // Input is an array, but filter wants an object
@@ -92,7 +91,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"null", "null",
0 0,
}, },
{ {
// Input is a bool, but filter wants an object // Input is a bool, but filter wants an object
@@ -101,7 +100,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"null", "null",
0 0,
}, },
{ {
// Input is a string, but filter wants an object // Input is a string, but filter wants an object
@@ -110,7 +109,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"null", "null",
0 0,
}, },
{ {
// skip an integer // skip an integer
@@ -119,7 +118,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// skip a float // skip a float
@@ -128,7 +127,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// skip false // skip false
@@ -137,7 +136,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// skip true // skip true
@@ -146,7 +145,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// skip null // skip null
@@ -155,7 +154,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// can skip a double-quoted string // can skip a double-quoted string
@@ -164,7 +163,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// can skip a single-quoted string // can skip a single-quoted string
@@ -173,7 +172,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// can skip an empty array // can skip an empty array
@@ -182,7 +181,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// can skip an empty array with spaces in it // can skip an empty array with spaces in it
@@ -191,7 +190,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// can skip an array // can skip an array
@@ -200,7 +199,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// can skip an array with spaces in it // can skip an array with spaces in it
@@ -209,7 +208,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// can skip an empty object // can skip an empty object
@@ -218,7 +217,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// can skip an empty object with spaces in it // can skip an empty object with spaces in it
@@ -227,7 +226,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// can skip an object // can skip an object
@@ -236,7 +235,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// skip an object with spaces in it // skip an object with spaces in it
@@ -245,7 +244,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":42}", "{\"example\":42}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
"{\"an_integer\": 0,\"example\":{\"type\":\"int\",\"outcome\":42}}", "{\"an_integer\": 0,\"example\":{\"type\":\"int\",\"outcome\":42}}",
@@ -253,7 +252,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":{\"outcome\":42}}", "{\"example\":{\"outcome\":42}}",
2 * sizeofObject(1) + 2*sizeofString("example") 2 * sizeofObject(1) + 2 * sizeofString("example"),
}, },
{ {
// wildcard // wildcard
@@ -262,7 +261,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":{\"outcome\":42}}", "{\"example\":{\"outcome\":42}}",
2 * sizeofObject(1) + 2*sizeofString("example") 2 * sizeofObject(1) + 2 * sizeofString("example"),
}, },
{ {
// exclusion filter (issue #1628) // exclusion filter (issue #1628)
@@ -271,7 +270,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{\"example\":1}", "{\"example\":1}",
sizeofObject(1) + sizeofString("example") sizeofObject(1) + sizeofString("example"),
}, },
{ {
// only the first element of array counts // only the first element of array counts
@@ -280,7 +279,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"[1,2,3]", "[1,2,3]",
sizeofArray(3) sizeofArray(3),
}, },
{ {
// only the first element of array counts // only the first element of array counts
@@ -289,7 +288,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"[]", "[]",
sizeofArray(0) sizeofArray(0),
}, },
{ {
// filter members of object in array // filter members of object in array
@@ -298,7 +297,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"[{\"example\":1},{\"example\":3}]", "[{\"example\":1},{\"example\":3}]",
sizeofArray(2) + 2 * sizeofObject(1) + sizeofString("example") sizeofArray(2) + 2 * sizeofObject(1) + sizeofString("example"),
}, },
{ {
"[',2,3]", "[',2,3]",
@@ -306,7 +305,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"[]", "[]",
sizeofArray(0) sizeofArray(0),
}, },
{ {
"[\",2,3]", "[\",2,3]",
@@ -314,7 +313,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"[]", "[]",
sizeofArray(0) sizeofArray(0),
}, },
{ {
// detect errors in skipped value // detect errors in skipped value
@@ -323,7 +322,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"[]", "[]",
sizeofArray(0) sizeofArray(0),
}, },
{ {
// detect incomplete string event if it's skipped // detect incomplete string event if it's skipped
@@ -332,7 +331,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// detect incomplete string event if it's skipped // detect incomplete string event if it's skipped
@@ -341,7 +340,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// handle escaped quotes // handle escaped quotes
@@ -350,7 +349,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"null", "null",
0 0,
}, },
{ {
// handle escaped quotes // handle escaped quotes
@@ -359,7 +358,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"null", "null",
0 0,
}, },
{ {
// detect incomplete string in presence of escaped quotes // detect incomplete string in presence of escaped quotes
@@ -368,7 +367,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// detect incomplete string in presence of escaped quotes // detect incomplete string in presence of escaped quotes
@@ -377,7 +376,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// skip empty array // skip empty array
@@ -386,7 +385,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"null", "null",
0 0,
}, },
{ {
// skip empty array with spaces // skip empty array with spaces
@@ -395,7 +394,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"null", "null",
0 0,
}, },
{ {
// bubble up element error even if array is skipped // bubble up element error even if array is skipped
@@ -404,7 +403,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// bubble up member error even if object is skipped // bubble up member error even if object is skipped
@@ -413,7 +412,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// bubble up colon error even if object is skipped // bubble up colon error even if object is skipped
@@ -422,7 +421,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"null", "null",
0 0,
}, },
{ {
// bubble up key error even if object is skipped // bubble up key error even if object is skipped
@@ -431,7 +430,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// detect invalid value in skipped object // detect invalid value in skipped object
@@ -440,7 +439,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"null", "null",
0 0,
}, },
{ {
// ignore invalid value in skipped object // ignore invalid value in skipped object
@@ -449,7 +448,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"null", "null",
0 0,
}, },
{ {
// check nesting limit even for ignored objects // check nesting limit even for ignored objects
@@ -458,7 +457,7 @@ TEST_CASE("Filtering") {
0, 0,
DeserializationError::TooDeep, DeserializationError::TooDeep,
"null", "null",
0 0,
}, },
{ {
// check nesting limit even for ignored objects // check nesting limit even for ignored objects
@@ -467,7 +466,7 @@ TEST_CASE("Filtering") {
1, 1,
DeserializationError::TooDeep, DeserializationError::TooDeep,
"null", "null",
0 0,
}, },
{ {
// check nesting limit even for ignored values in objects // check nesting limit even for ignored values in objects
@@ -476,7 +475,7 @@ TEST_CASE("Filtering") {
1, 1,
DeserializationError::TooDeep, DeserializationError::TooDeep,
"{}", "{}",
sizeofObject(0) sizeofObject(0),
}, },
{ {
// check nesting limit even for ignored arrays // check nesting limit even for ignored arrays
@@ -485,7 +484,7 @@ TEST_CASE("Filtering") {
0, 0,
DeserializationError::TooDeep, DeserializationError::TooDeep,
"null", "null",
0 0,
}, },
{ {
// check nesting limit even for ignored arrays // check nesting limit even for ignored arrays
@@ -494,7 +493,7 @@ TEST_CASE("Filtering") {
1, 1,
DeserializationError::TooDeep, DeserializationError::TooDeep,
"null", "null",
0 0,
}, },
{ {
// check nesting limit even for ignored values in arrays // check nesting limit even for ignored values in arrays
@@ -503,7 +502,7 @@ TEST_CASE("Filtering") {
1, 1,
DeserializationError::TooDeep, DeserializationError::TooDeep,
"[]", "[]",
sizeofArray(0) sizeofArray(0),
}, },
{ {
// supports back-slash at the end of skipped string // supports back-slash at the end of skipped string
@@ -512,7 +511,7 @@ TEST_CASE("Filtering") {
1, 1,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// invalid comment at after an element in a skipped array // invalid comment at after an element in a skipped array
@@ -521,7 +520,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"null", "null",
0 0,
}, },
{ {
// incomplete comment at after an element in a skipped array // incomplete comment at after an element in a skipped array
@@ -530,7 +529,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// missing comma in a skipped array // missing comma in a skipped array
@@ -539,7 +538,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"null", "null",
0 0,
}, },
{ {
// invalid comment at the beginning of array // invalid comment at the beginning of array
@@ -548,7 +547,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"[]", "[]",
sizeofArray(0) sizeofArray(0),
}, },
{ {
// incomplete comment at the begining of an array // incomplete comment at the begining of an array
@@ -557,7 +556,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"[]", "[]",
sizeofArray(0) sizeofArray(0),
}, },
{ {
// invalid comment before key // invalid comment before key
@@ -566,7 +565,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"{}", "{}",
sizeofObject(0) sizeofObject(0),
}, },
{ {
// incomplete comment before key // incomplete comment before key
@@ -575,7 +574,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"{}", "{}",
sizeofObject(0) sizeofObject(0),
}, },
{ {
// invalid comment after key // invalid comment after key
@@ -584,7 +583,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"{}", "{}",
sizeofObject(0) sizeofObject(0),
}, },
{ {
// incomplete comment after key // incomplete comment after key
@@ -593,7 +592,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"{}", "{}",
sizeofObject(0) sizeofObject(0),
}, },
{ {
// invalid comment after colon // invalid comment after colon
@@ -602,7 +601,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"{}", "{}",
sizeofObject(0) sizeofObject(0),
}, },
{ {
// incomplete comment after colon // incomplete comment after colon
@@ -611,7 +610,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"{}", "{}",
sizeofObject(0) sizeofObject(0),
}, },
{ {
// comment next to an integer // comment next to an integer
@@ -620,7 +619,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::Ok, DeserializationError::Ok,
"{}", "{}",
sizeofObject(0) sizeofObject(0),
}, },
{ {
// invalid comment after opening brace of a skipped object // invalid comment after opening brace of a skipped object
@@ -629,7 +628,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"null", "null",
0 0,
}, },
{ {
// incomplete after opening brace of a skipped object // incomplete after opening brace of a skipped object
@@ -638,7 +637,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// invalid comment after key of a skipped object // invalid comment after key of a skipped object
@@ -647,7 +646,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"null", "null",
0 0,
}, },
{ {
// incomplete comment after key of a skipped object // incomplete comment after key of a skipped object
@@ -656,7 +655,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// invalid comment after value in a skipped object // invalid comment after value in a skipped object
@@ -665,7 +664,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::InvalidInput, DeserializationError::InvalidInput,
"null", "null",
0 0,
}, },
{ {
// incomplete comment after value of a skipped object // incomplete comment after value of a skipped object
@@ -674,7 +673,7 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
{ {
// incomplete comment after comma in skipped object // incomplete comment after comma in skipped object
@@ -683,9 +682,9 @@ TEST_CASE("Filtering") {
10, 10,
DeserializationError::IncompleteInput, DeserializationError::IncompleteInput,
"null", "null",
0 0,
}, },
}; // clang-format on };
for (size_t i = 0; i < sizeof(testCases) / sizeof(testCases[0]); i++) { for (size_t i = 0; i < sizeof(testCases) / sizeof(testCases[0]); i++) {
CAPTURE(i); CAPTURE(i);