test/logging_tests.c

changeset 81
86a23238d8a1
parent 80
0125e4089f88
child 95
ecfdc1c4a552
equal deleted inserted replaced
80:0125e4089f88 81:86a23238d8a1
10 10
11 UcxLogger *logger = ucx_logger_new(stream, 11 UcxLogger *logger = ucx_logger_new(stream,
12 UCX_LOGGER_INFO, UCX_LOGGER_SOURCE | UCX_LOGGER_LEVEL); 12 UCX_LOGGER_INFO, UCX_LOGGER_SOURCE | UCX_LOGGER_LEVEL);
13 13
14 UCX_TEST_BEGIN 14 UCX_TEST_BEGIN
15 ucx_logger_info(logger, ST("allright")); 15 ucx_logger_info(logger, "allright");
16 ucx_logger_trace(logger, ST("dont log this!")); 16 ucx_logger_trace(logger, "dont log this!");
17 ucx_logger_error(logger, ST("error!")); 17 ucx_logger_error(logger, "error %d!", 42);
18 fseek(stream, 0, SEEK_SET); 18 fseek(stream, 0, SEEK_SET);
19 int r = fread(buffer, 1, 100, stream); 19 int r = fread(buffer, 1, 100, stream);
20 20
21 size_t expected_length = 73; 21 size_t expected_length = 76;
22 UCX_TEST_ASSERT(r == expected_length && strncmp(buffer, 22 UCX_TEST_ASSERT(r == expected_length && strncmp(buffer,
23 "[INFO] logging_tests.c:15 - allright\n" 23 "[INFO] logging_tests.c:15 - allright\n"
24 "[ERROR] logging_tests.c:17 - error!\n", expected_length) == 0, "incorrect logs"); 24 "[ERROR] logging_tests.c:17 - error 42!\n", expected_length) == 0, "incorrect logs");
25 25
26 UCX_TEST_END 26 UCX_TEST_END
27 27
28 ucx_logger_free(logger); 28 ucx_logger_free(logger);
29 fclose(stream); 29 fclose(stream);

mercurial