ucx/test.c

Sat, 01 Dec 2012 14:49:34 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 01 Dec 2012 14:49:34 +0100
changeset 2
f7e408d98a83
parent 1
1bcaac272cdf
child 5
88625853ae74
permissions
-rw-r--r--

fixed dav Makefile

/* 
 * 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