diff mbox series

[08/56] check-qjson: Streamline escaped_string()'s test strings

Message ID 20180808120334.10970-9-armbru@redhat.com
State New
Headers show
Series json: Fixes, error reporting improvements, cleanups | expand

Commit Message

Markus Armbruster Aug. 8, 2018, 12:02 p.m. UTC
Merge a few closely related test strings, and drop a few redundant
ones.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/check-qjson.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

Comments

Eric Blake Aug. 9, 2018, 1:57 p.m. UTC | #1
On 08/08/2018 07:02 AM, Markus Armbruster wrote:
> Merge a few closely related test strings, and drop a few redundant
> ones.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   tests/check-qjson.c | 14 ++------------
>   1 file changed, 2 insertions(+), 12 deletions(-)
> 

>       } test_cases[] = {
> -        { "\\b", "\b" },
> -        { "\\f", "\f" },
> -        { "\\n", "\n" },
> -        { "\\r", "\r" },
> -        { "\\t", "\t" },
> -        { "/", "/" },
> -        { "\\/", "/", .skip = 1 },
> -        { "\\\\", "\\" },
> -        { "\\\"", "\"" },
> -        { "hello world \\\"embedded string\\\"",
> -          "hello world \"embedded string\"" },
> -        { "hello world\\nwith new line", "hello world\nwith new line" },
> +        { "\\b\\f\\n\\r\\t\\\\\\\"", "\b\f\n\r\t\\\"" },
> +        { "\\/\\'", "/'", .skip = 1 },

Aha - this adds coverage of the escaped ' not present in 7/56. (Still 
nothing about the unescaped versions of ' or " with correct quoting).

Reviewed-by: Eric Blake <eblake@redhat.com>
Markus Armbruster Aug. 10, 2018, 2:15 p.m. UTC | #2
Eric Blake <eblake@redhat.com> writes:

> On 08/08/2018 07:02 AM, Markus Armbruster wrote:
>> Merge a few closely related test strings, and drop a few redundant
>> ones.
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>   tests/check-qjson.c | 14 ++------------
>>   1 file changed, 2 insertions(+), 12 deletions(-)
>>
>
>>       } test_cases[] = {
>> -        { "\\b", "\b" },
>> -        { "\\f", "\f" },
>> -        { "\\n", "\n" },
>> -        { "\\r", "\r" },
>> -        { "\\t", "\t" },
>> -        { "/", "/" },
>> -        { "\\/", "/", .skip = 1 },
>> -        { "\\\\", "\\" },
>> -        { "\\\"", "\"" },
>> -        { "hello world \\\"embedded string\\\"",
>> -          "hello world \"embedded string\"" },
>> -        { "hello world\\nwith new line", "hello world\nwith new line" },
>> +        { "\\b\\f\\n\\r\\t\\\\\\\"", "\b\f\n\r\t\\\"" },
>> +        { "\\/\\'", "/'", .skip = 1 },
>
> Aha - this adds coverage of the escaped ' not present in 7/56.

You're right.  I'll move that part there.

> Aha - this adds coverage of the escaped ' not present in 7/56. (Still
> nothing about the unescaped versions of ' or " with correct quoting).
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!
diff mbox series

Patch

diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 1c7f24bc4d..8f51f57af9 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -54,18 +54,8 @@  static void escaped_string(void)
         const char *utf8_out;
         int skip;
     } test_cases[] = {
-        { "\\b", "\b" },
-        { "\\f", "\f" },
-        { "\\n", "\n" },
-        { "\\r", "\r" },
-        { "\\t", "\t" },
-        { "/", "/" },
-        { "\\/", "/", .skip = 1 },
-        { "\\\\", "\\" },
-        { "\\\"", "\"" },
-        { "hello world \\\"embedded string\\\"",
-          "hello world \"embedded string\"" },
-        { "hello world\\nwith new line", "hello world\nwith new line" },
+        { "\\b\\f\\n\\r\\t\\\\\\\"", "\b\f\n\r\t\\\"" },
+        { "\\/\\'", "/'", .skip = 1 },
         { "single byte utf-8 \\u0020", "single byte utf-8  ", .skip = 1 },
         { "double byte utf-8 \\u00A2", "double byte utf-8 \xc2\xa2" },
         { "triple byte utf-8 \\u20AC", "triple byte utf-8 \xe2\x82\xac" },