From: Anthony Liguori <aliguori@linux.vnet.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/3] add some tests for invalid JSON
Date: Mon, 24 May 2010 15:17:29 -0500 [thread overview]
Message-ID: <4BFADED9.3030808@linux.vnet.ibm.com> (raw)
In-Reply-To: <1274686793-1566-2-git-send-email-pbonzini@redhat.com>
On 05/24/2010 02:39 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
>
I think this series conflicts a bit with Luiz's series which I just
pushed. Could you rebase against the latest?
Regards,
Anthony Liguori
> ---
> check-qjson.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 97 insertions(+), 1 deletions(-)
>
> diff --git a/check-qjson.c b/check-qjson.c
> index 109e777..a04e334 100644
> --- a/check-qjson.c
> +++ b/check-qjson.c
> @@ -628,11 +628,90 @@ START_TEST(simple_varargs)
> }
> END_TEST
>
> +START_TEST(empty_input)
> +{
> + QObject *obj = qobject_from_json("");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +START_TEST(unterminated_string)
> +{
> + QObject *obj = qobject_from_json("\"abc");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +START_TEST(unterminated_sq_string)
> +{
> + QObject *obj = qobject_from_json("'abc");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +START_TEST(unterminated_escape)
> +{
> + QObject *obj = qobject_from_json("\"abc\\\"");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +START_TEST(unterminated_array)
> +{
> + QObject *obj = qobject_from_json("[32");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +START_TEST(unterminated_array_comma)
> +{
> + QObject *obj = qobject_from_json("[32,");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +START_TEST(invalid_array_comma)
> +{
> + QObject *obj = qobject_from_json("[32,}");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +START_TEST(unterminated_dict)
> +{
> + QObject *obj = qobject_from_json("{'abc':32");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +START_TEST(unterminated_dict_comma)
> +{
> + QObject *obj = qobject_from_json("{'abc':32,");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +#if 0
> +START_TEST(invalid_dict_comma)
> +{
> + QObject *obj = qobject_from_json("{'abc':32,}");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +
> +START_TEST(unterminated_literal)
> +{
> + QObject *obj = qobject_from_json("nul");
> + fail_unless(obj == NULL);
> +}
> +END_TEST
> +#endif
> +
> static Suite *qjson_suite(void)
> {
> Suite *suite;
> TCase *string_literals, *number_literals, *keyword_literals;
> - TCase *dicts, *lists, *whitespace, *varargs;
> + TCase *dicts, *lists, *whitespace, *varargs, *errors;
>
> string_literals = tcase_create("String Literals");
> tcase_add_test(string_literals, simple_string);
> @@ -658,6 +737,22 @@ static Suite *qjson_suite(void)
> varargs = tcase_create("Varargs");
> tcase_add_test(varargs, simple_varargs);
>
> + errors = tcase_create("Invalid JSON");
> + tcase_add_test(errors, empty_input);
> + tcase_add_test(errors, unterminated_string);
> + tcase_add_test(errors, unterminated_escape);
> + tcase_add_test(errors, unterminated_sq_string);
> + tcase_add_test(errors, unterminated_array);
> + tcase_add_test(errors, unterminated_array_comma);
> + tcase_add_test(errors, invalid_array_comma);
> + tcase_add_test(errors, unterminated_dict);
> + tcase_add_test(errors, unterminated_dict_comma);
> +#if 0
> + /* FIXME: this print parse error messages on stderr. */
> + tcase_add_test(errors, invalid_dict_comma);
> + tcase_add_test(errors, unterminated_literal);
> +#endif
> +
> suite = suite_create("QJSON test-suite");
> suite_add_tcase(suite, string_literals);
> suite_add_tcase(suite, number_literals);
> @@ -666,6 +761,7 @@ static Suite *qjson_suite(void)
> suite_add_tcase(suite, lists);
> suite_add_tcase(suite, whitespace);
> suite_add_tcase(suite, varargs);
> + suite_add_tcase(suite, errors);
>
> return suite;
> }
>
next prev parent reply other threads:[~2010-05-24 20:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-24 7:39 [Qemu-devel] [PATCH v2 0/3] json lexer tests and removal of lookahead Paolo Bonzini
2010-05-24 7:39 ` [Qemu-devel] [PATCH v2 1/3] add some tests for invalid JSON Paolo Bonzini
2010-05-24 20:17 ` Anthony Liguori [this message]
2010-05-25 7:28 ` Paolo Bonzini
2010-05-25 13:08 ` Anthony Liguori
2010-05-24 7:39 ` [Qemu-devel] [PATCH v2 2/3] implement optional lookahead in json lexer Paolo Bonzini
2010-05-24 7:39 ` [Qemu-devel] [PATCH v2 3/3] remove unnecessary lookaheads Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BFADED9.3030808@linux.vnet.ibm.com \
--to=aliguori@linux.vnet.ibm.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).