Skip to content

Commit 02d099c

Browse files
author
Marcel Meulemans
committed
Fail test if the measure size were to be less than the serialized size
Doesn't fail currently, but good to check for!
1 parent d6eb388 commit 02d099c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/main.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,17 @@ void test_buf (char * buffer, size_t size, int * num_failed)
127127
char * buf = (char *) malloc (measured);
128128
json_serialize (buf, value);
129129

130-
printf ("serialized len: %d\n", (int) strlen (buf) + 1);
130+
size_t serialized = (int) strlen (buf) + 1;
131+
printf ("serialized len: %d\n", serialized);
131132

132133
printf ("serialized:\n%s\n", buf);
133134

134-
if (! (value2 = json_parse_ex (&settings, buf, strlen(buf), error)))
135+
if (serialized > measured)
136+
{
137+
printf ("Serialized more than measured\n");
138+
++ *num_failed;
139+
}
140+
else if (! (value2 = json_parse_ex (&settings, buf, strlen(buf), error)))
135141
{
136142
printf ("Failed to re-parse: %s\n", error);
137143
++ *num_failed;

0 commit comments

Comments
 (0)