Skip to content

Commit 4590b1a

Browse files
committed
tests: internal: pack: add test for nested empty arrays
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 267674b commit 4590b1a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/internal/pack.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,23 @@ void test_json_pack_bug5336()
970970
}
971971
}
972972

973+
/* Ensure empty arrays inside nested objects are handled */
974+
void test_json_pack_empty_array()
975+
{
976+
int ret;
977+
int root_type;
978+
size_t out_size;
979+
char *out_buf;
980+
char json[] =
981+
"{\"resourceLogs\":[{\"resource\":{},\"scopeLogs\":[{\"scope\":{},"
982+
"\"logRecords\":[{\"body\":{\"test\":{\"values\":[]}}}]}]}]}";
983+
984+
ret = flb_pack_json(json, strlen(json), &out_buf, &out_size, &root_type, NULL);
985+
TEST_CHECK(ret == 0);
986+
987+
flb_free(out_buf);
988+
}
989+
973990
const char input_msgpack[] = {0x92,/* array 2 */
974991
0xd7, 0x00, /* event time*/
975992
0x07, 0x5b, 0xcd, 0x15, /* second = 123456789 = 1973/11/29 21:33:09 */
@@ -1115,6 +1132,7 @@ TEST_LIST = {
11151132
{ "json_pack_bug1278" , test_json_pack_bug1278},
11161133
{ "json_pack_nan" , test_json_pack_nan},
11171134
{ "json_pack_bug5336" , test_json_pack_bug5336},
1135+
{ "json_pack_empty_array", test_json_pack_empty_array},
11181136
{ "json_date_iso8601" , test_json_date_iso8601},
11191137
{ "json_date_double" , test_json_date_double},
11201138
{ "json_date_java_sql" , test_json_date_java_sql},

0 commit comments

Comments
 (0)