in simple string tests, always check lengths too
This commit is contained in:
parent
a76dc45512
commit
c7d479c740
@ -72,11 +72,22 @@ static void run_tests()
|
||||
fail("json_string failed");
|
||||
if(strcmp(json_string_value(value), "foo"))
|
||||
fail("invalid string value");
|
||||
if (json_string_length(value) != 3)
|
||||
fail("invalid string length");
|
||||
|
||||
if(json_string_set(value, "bar"))
|
||||
if(json_string_set(value, "barr"))
|
||||
fail("json_string_set failed");
|
||||
if(strcmp(json_string_value(value), "bar"))
|
||||
if(strcmp(json_string_value(value), "barr"))
|
||||
fail("invalid string value");
|
||||
if (json_string_length(value) != 4)
|
||||
fail("invalid string length");
|
||||
|
||||
if(json_string_setn(value, "hi\0ho", 5))
|
||||
fail("json_string_set failed");
|
||||
if(memcmp(json_string_value(value), "hi\0ho\0", 6))
|
||||
fail("invalid string value");
|
||||
if (json_string_length(value) != 5)
|
||||
fail("invalid string length");
|
||||
|
||||
json_decref(value);
|
||||
|
||||
@ -94,11 +105,22 @@ static void run_tests()
|
||||
fail("json_string_nocheck failed");
|
||||
if(strcmp(json_string_value(value), "foo"))
|
||||
fail("invalid string value");
|
||||
if (json_string_length(value) != 3)
|
||||
fail("invalid string length");
|
||||
|
||||
if(json_string_set_nocheck(value, "bar"))
|
||||
if(json_string_set_nocheck(value, "barr"))
|
||||
fail("json_string_set_nocheck failed");
|
||||
if(strcmp(json_string_value(value), "bar"))
|
||||
if(strcmp(json_string_value(value), "barr"))
|
||||
fail("invalid string value");
|
||||
if (json_string_length(value) != 4)
|
||||
fail("invalid string length");
|
||||
|
||||
if(json_string_setn_nocheck(value, "hi\0ho", 5))
|
||||
fail("json_string_set failed");
|
||||
if(memcmp(json_string_value(value), "hi\0ho\0", 6))
|
||||
fail("invalid string value");
|
||||
if (json_string_length(value) != 5)
|
||||
fail("invalid string length");
|
||||
|
||||
json_decref(value);
|
||||
|
||||
@ -108,11 +130,15 @@ static void run_tests()
|
||||
fail("json_string_nocheck failed");
|
||||
if(strcmp(json_string_value(value), "qu\xff"))
|
||||
fail("invalid string value");
|
||||
if (json_string_length(value) != 3)
|
||||
fail("invalid string length");
|
||||
|
||||
if(json_string_set_nocheck(value, "\xfd\xfe\xff"))
|
||||
fail("json_string_set_nocheck failed");
|
||||
if(strcmp(json_string_value(value), "\xfd\xfe\xff"))
|
||||
fail("invalid string value");
|
||||
if (json_string_length(value) != 3)
|
||||
fail("invalid string length");
|
||||
|
||||
json_decref(value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user