test/logging_tests.c

Wed, 06 Feb 2013 14:31:44 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 06 Feb 2013 14:31:44 +0100
changeset 79
cf3757c60c8f
parent 75
990734f548ef
child 80
0125e4089f88
permissions
-rw-r--r--

fixed macros and ucx_map_store_enc

/*
 *
 */

#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);
    int r = fread(buffer, 1, 100, stream);

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

    UCX_TEST_END

    free(logger);
    fclose(stream);
}

mercurial