START_TEST(escaped_string)

{

    int i;

    struct {

        const char *encoded;

        const char *decoded;

        int skip;

    } test_cases[] = {

        { "\"\\\"\"", "\"" },

        { "\"hello world \\\"embedded string\\\"\"",

          "hello world \"embedded string\"" },

        { "\"hello world\\nwith new line\"", "hello world\nwith new line" },

        { "\"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" },

        {}

    };



    for (i = 0; test_cases[i].encoded; i++) {

        QObject *obj;

        QString *str;



        obj = qobject_from_json(test_cases[i].encoded);



        fail_unless(obj != NULL);

        fail_unless(qobject_type(obj) == QTYPE_QSTRING);

        

        str = qobject_to_qstring(obj);

        fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);



        if (test_cases[i].skip == 0) {

            str = qobject_to_json(obj);

            fail_unless(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0);



            qobject_decref(obj);

        }



        QDECREF(str);

    }

}

START_TEST(escaped_string)

{

    int i;

    struct {

        const char *encoded;

        const char *decoded;

        int skip;

    } test_cases[] = {

        { "\"\\\"\"", "\"" },

        { "\"hello world \\\"embedded string\\\"\"",

          "hello world \"embedded string\"" },

        { "\"hello world\\nwith new line\"", "hello world\nwith new line" },

        { "\"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" },

        {}

    };



    for (i = 0; test_cases[i].encoded; i++) {

        QObject *obj;

        QString *str;



        obj = qobject_from_json(test_cases[i].encoded);



        fail_unless(obj != NULL);

        fail_unless(qobject_type(obj) == QTYPE_QSTRING);

        

        str = qobject_to_qstring(obj);

        fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);



        if (test_cases[i].skip == 0) {

            str = qobject_to_json(obj);

            fail_unless(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0);



            qobject_decref(obj);

        }



        QDECREF(str);

    }

}

        fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);             fail_unless(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0);
FUNC_0(VAR_0)

{

    int VAR_1;

    struct {

        const char *encoded;

        const char *decoded;

        int skip;

    } VAR_2[] = {

        { "\"\\\"\"", "\"" },

        { "\"hello world \\\"embedded string\\\"\"",

          "hello world \"embedded string\"" },

        { "\"hello world\\nwith new line\"", "hello world\nwith new line" },

        { "\"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" },

        {}

    };



    for (VAR_1 = 0; VAR_2[VAR_1].encoded; VAR_1++) {

        QObject *obj;

        QString *str;



        obj = qobject_from_json(VAR_2[VAR_1].encoded);



        fail_unless(obj != NULL);

        fail_unless(qobject_type(obj) == QTYPE_QSTRING);

        

        str = qobject_to_qstring(obj);

        fail_unless(strcmp(qstring_get_str(str), VAR_2[VAR_1].decoded) == 0);



        if (VAR_2[VAR_1].skip == 0) {

            str = qobject_to_json(obj);

            fail_unless(strcmp(qstring_get_str(str), VAR_2[VAR_1].encoded) == 0);



            qobject_decref(obj);

        }



        QDECREF(str);

    }

}

FUNC_0(VAR_0)
{ int VAR_1; struct { const char *encoded; const char *decoded; int skip; } VAR_2[] = { { "\"\\\"\"", "\"" }, { "\"hello world \\\"embedded string\\\"\"", "hello world \"embedded string\"" }, { "\"hello world\\nwith new line\"", "hello world\nwith new line" }, { "\"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" }, {} }; for (VAR_1 = 0; VAR_2[VAR_1].encoded; VAR_1++) { QObject *obj; QString *str; obj = qobject_from_json(VAR_2[VAR_1].encoded); fail_unless(obj != NULL); fail_unless(qobject_type(obj) == QTYPE_QSTRING); str = qobject_to_qstring(obj); fail_unless(strcmp(qstring_get_str(str), VAR_2[VAR_1].decoded) == 0); if (VAR_2[VAR_1].skip == 0) { str = qobject_to_json(obj); fail_unless(strcmp(qstring_get_str(str), VAR_2[VAR_1].encoded) == 0); qobject_decref(obj); } QDECREF(str); } }