ucx/test.c

Thu, 17 Jan 2013 23:56:48 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 17 Jan 2013 23:56:48 +0100
changeset 77
51311a5685d3
parent 26
59f147baea31
child 83
3b552d7a9610
permissions
-rw-r--r--

used more library friendly optimization level

/* 
 * File:   test.c
 * Author: Mike
 *
 * Created on 18. Februar 2012, 14:15
 */

#include "test.h"

UcxTestSuite* ucx_test_suite_new() {
    UcxTestSuite* suite = (UcxTestSuite*) malloc(sizeof(UcxTestSuite));
    if (suite != NULL) {
        suite->success = 0;
        suite->failure = 0;
        suite->tests = NULL;
    }
    return suite;
}

void ucx_test_suite_free(UcxTestSuite* suite) {
    ucx_list_free(suite->tests);
    free(suite);
}

void ucx_test_register(UcxTestSuite* suite, UcxTest test) {
    suite->tests = ucx_list_append(suite->tests, (void*) test);
}

void ucx_test_run(UcxTestSuite* suite, FILE* output) {
    suite->success = 0;
    suite->failure = 0;
    UCX_FOREACH (UcxList*, suite->tests, e) {
        UcxTest test = (UcxTest) (e->data);
        test(suite, output);
    }
    fwrite("\nAll test completed.\n", 1, 21, output);
    fprintf(output, "  Total:   %d\n  Success: %d\n  Failure: %d\n",
            suite->success+suite->failure, suite->success, suite->failure);
}

mercurial