START_TEST(qdict_stress_test)

{

    size_t lines;

    char key[128];

    FILE *test_file;

    QDict *qdict;

    QString *value;

    const char *test_file_path = "qdict-test-data.txt";



    test_file = fopen(test_file_path, "r");

    fail_unless(test_file != NULL);



    // Create the dict

    qdict = qdict_new();

    fail_unless(qdict != NULL);



    // Add everything from the test file

    for (lines = 0;; lines++) {

        value = read_line(test_file, key);

        if (!value)

            break;



        qdict_put(qdict, key, value);

    }

    fail_unless(qdict_size(qdict) == lines);



    // Check if everything is really in there

    reset_file(test_file);

    for (;;) {

        const char *str1, *str2;



        value = read_line(test_file, key);

        if (!value)

            break;



        str1 = qstring_get_str(value);



        str2 = qdict_get_str(qdict, key);

        fail_unless(str2 != NULL);



        fail_unless(strcmp(str1, str2) == 0);



        QDECREF(value);

    }



    // Delete everything

    reset_file(test_file);

    for (;;) {

        value = read_line(test_file, key);

        if (!value)

            break;



        qdict_del(qdict, key);

        QDECREF(value);



        fail_unless(qdict_haskey(qdict, key) == 0);

    }

    fclose(test_file);



    fail_unless(qdict_size(qdict) == 0);

    QDECREF(qdict);

}

START_TEST(qdict_stress_test)

{

    size_t lines;

    char key[128];

    FILE *test_file;

    QDict *qdict;

    QString *value;

    const char *test_file_path = "qdict-test-data.txt";



    test_file = fopen(test_file_path, "r");

    fail_unless(test_file != NULL);



    

    qdict = qdict_new();

    fail_unless(qdict != NULL);



    

    for (lines = 0;; lines++) {

        value = read_line(test_file, key);

        if (!value)

            break;



        qdict_put(qdict, key, value);

    }

    fail_unless(qdict_size(qdict) == lines);



    

    reset_file(test_file);

    for (;;) {

        const char *str1, *str2;



        value = read_line(test_file, key);

        if (!value)

            break;



        str1 = qstring_get_str(value);



        str2 = qdict_get_str(qdict, key);

        fail_unless(str2 != NULL);



        fail_unless(strcmp(str1, str2) == 0);



        QDECREF(value);

    }



    

    reset_file(test_file);

    for (;;) {

        value = read_line(test_file, key);

        if (!value)

            break;



        qdict_del(qdict, key);

        QDECREF(value);



        fail_unless(qdict_haskey(qdict, key) == 0);

    }

    fclose(test_file);



    fail_unless(qdict_size(qdict) == 0);

    QDECREF(qdict);

}

FUNC_0(VAR_0)

{

    size_t lines;

    char VAR_1[128];

    FILE *test_file;

    QDict *qdict;

    QString *value;

    const char *VAR_2 = "qdict-test-data.txt";



    test_file = fopen(VAR_2, "r");

    fail_unless(test_file != NULL);



    

    qdict = qdict_new();

    fail_unless(qdict != NULL);



    

    for (lines = 0;; lines++) {

        value = read_line(test_file, VAR_1);

        if (!value)

            break;



        qdict_put(qdict, VAR_1, value);

    }

    fail_unless(qdict_size(qdict) == lines);



    

    reset_file(test_file);

    for (;;) {

        const char *VAR_3, *VAR_4;



        value = read_line(test_file, VAR_1);

        if (!value)

            break;



        VAR_3 = qstring_get_str(value);



        VAR_4 = qdict_get_str(qdict, VAR_1);

        fail_unless(VAR_4 != NULL);



        fail_unless(strcmp(VAR_3, VAR_4) == 0);



        QDECREF(value);

    }



    

    reset_file(test_file);

    for (;;) {

        value = read_line(test_file, VAR_1);

        if (!value)

            break;



        qdict_del(qdict, VAR_1);

        QDECREF(value);



        fail_unless(qdict_haskey(qdict, VAR_1) == 0);

    }

    fclose(test_file);



    fail_unless(qdict_size(qdict) == 0);

    QDECREF(qdict);

}

FUNC_0(VAR_0)
{ size_t lines; char VAR_1[128]; FILE *test_file; QDict *qdict; QString *value; const char *VAR_2 = "qdict-test-data.txt"; test_file = fopen(VAR_2, "r"); fail_unless(test_file != NULL); qdict = qdict_new(); fail_unless(qdict != NULL); for (lines = 0;; lines++) { value = read_line(test_file, VAR_1); if (!value)
break; qdict_put(qdict, VAR_1, value); } fail_unless(qdict_size(qdict) == lines); reset_file(test_file); for (;;) { const char *VAR_3, *VAR_4; value = read_line(test_file, VAR_1); if (!value)
break; VAR_3 = qstring_get_str(value); VAR_4 = qdict_get_str(qdict, VAR_1); fail_unless(VAR_4 != NULL); fail_unless(strcmp(VAR_3, VAR_4) == 0); QDECREF(value); } reset_file(test_file); for (;;) { value = read_line(test_file, VAR_1); if (!value)
break; qdict_del(qdict, VAR_1); QDECREF(value); fail_unless(qdict_haskey(qdict, VAR_1) == 0); } fclose(test_file); fail_unless(qdict_size(qdict) == 0); QDECREF(qdict); }