Wed, 27 Feb 2013 14:04:45 +0100
fixed execution order of tests + added test for sstrtrim
/* * */ #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); }