Wed, 27 Feb 2013 10:28:02 +0100
added tests for ucx_(d)list_contains
54 | 1 | /* |
2 | * | |
3 | */ | |
4 | ||
5 | #include "logging_tests.h" | |
6 | ||
7 | UCX_TEST_IMPLEMENT(test_ucx_logger_log) { | |
8 | char buffer[100]; | |
55
180bc6b18fec
fixed map tests + used tmpfiles in tests
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
9 | FILE *stream = tmpfile(); |
180bc6b18fec
fixed map tests + used tmpfiles in tests
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
10 | |
80
0125e4089f88
Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents:
75
diff
changeset
|
11 | UcxLogger *logger = ucx_logger_new(stream, |
0125e4089f88
Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents:
75
diff
changeset
|
12 | UCX_LOGGER_INFO, UCX_LOGGER_SOURCE | UCX_LOGGER_LEVEL); |
54 | 13 | |
14 | UCX_TEST_BEGIN | |
81
86a23238d8a1
changed logger to behave more like printf + added possibility to specify write function
Mike Becker <universe@uap-core.de>
parents:
80
diff
changeset
|
15 | ucx_logger_info(logger, "allright"); |
86a23238d8a1
changed logger to behave more like printf + added possibility to specify write function
Mike Becker <universe@uap-core.de>
parents:
80
diff
changeset
|
16 | ucx_logger_trace(logger, "dont log this!"); |
86a23238d8a1
changed logger to behave more like printf + added possibility to specify write function
Mike Becker <universe@uap-core.de>
parents:
80
diff
changeset
|
17 | ucx_logger_error(logger, "error %d!", 42); |
54 | 18 | fseek(stream, 0, SEEK_SET); |
75
990734f548ef
fixed some compiler warnings
Mike Becker <universe@uap-core.de>
parents:
55
diff
changeset
|
19 | int r = fread(buffer, 1, 100, stream); |
80
0125e4089f88
Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents:
75
diff
changeset
|
20 | |
81
86a23238d8a1
changed logger to behave more like printf + added possibility to specify write function
Mike Becker <universe@uap-core.de>
parents:
80
diff
changeset
|
21 | size_t expected_length = 76; |
80
0125e4089f88
Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents:
75
diff
changeset
|
22 | UCX_TEST_ASSERT(r == expected_length && strncmp(buffer, |
0125e4089f88
Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents:
75
diff
changeset
|
23 | "[INFO] logging_tests.c:15 - allright\n" |
81
86a23238d8a1
changed logger to behave more like printf + added possibility to specify write function
Mike Becker <universe@uap-core.de>
parents:
80
diff
changeset
|
24 | "[ERROR] logging_tests.c:17 - error 42!\n", expected_length) == 0, "incorrect logs"); |
54 | 25 | |
26 | UCX_TEST_END | |
27 | ||
80
0125e4089f88
Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents:
75
diff
changeset
|
28 | ucx_logger_free(logger); |
54 | 29 | fclose(stream); |
30 | } |