test/logging_tests.c

Thu, 28 Feb 2013 08:17:26 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 28 Feb 2013 08:17:26 +0100
changeset 102
7c8ebad4d973
parent 95
ecfdc1c4a552
child 103
08018864fb91
permissions
-rw-r--r--

added headers that are missing under visual studio

/*
 *
 */

#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_LOGGER_SOURCE | UCX_LOGGER_LEVEL);
    
    UCX_TEST_BEGIN
    ucx_logger_info(logger, "allright");
    ucx_logger_trace(logger, "dont log this!");
    ucx_logger_error(logger, "error %d!", 42);
    fseek(stream, 0, SEEK_SET);
    size_t r = fread(buffer, 1, 100, stream);
    
    size_t expected_length = 76;
    UCX_TEST_ASSERT(r == expected_length && strncmp(buffer,
            "[INFO] logging_tests.c:15 - allright\n"
            "[ERROR] logging_tests.c:17 - error 42!\n", expected_length) == 0, "incorrect logs");

    UCX_TEST_END

    ucx_logger_free(logger);
    fclose(stream);
}

mercurial