test/logging_tests.c

Fri, 12 Oct 2012 12:09:00 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 12 Oct 2012 12:09:00 +0200
changeset 72
bb3eae81aae8
parent 55
180bc6b18fec
child 75
990734f548ef
permissions
-rw-r--r--

Merge with 6721482eaf8e8d35b1cd46f0a21285bfaa520d5a

/*
 *
 */

#include "logging_tests.h"

UCX_TEST_IMPLEMENT(test_ucx_logger_log) {
    char buffer[100];
    FILE *stream = tmpfile();

    UcxLogger *logger = ucx_logger_new(stream, UCX_LOGGER_INFO);
    
    UCX_TEST_BEGIN
    ucx_logger_info(logger, ST("[INFO:] allright\n"));
    ucx_logger_trace(logger, ST("[TRACE:] dont log this!\n"));
    ucx_logger_error(logger, ST("[ERROR:] error!\n"));
    fseek(stream, 0, SEEK_SET);
    fread(buffer, 1, 100, stream);

    UCX_TEST_ASSERT(strncmp(buffer,
            "[INFO:] allright\n[ERROR:] error!\n", 33) == 0, "incorrect logs");

    UCX_TEST_END

    free(logger);
    fclose(stream);
}

mercurial