Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* Filename: /home/osvegn/Documents/Repositories/ECS/tests/library/ECS/world_logger_tests.c |
3 |
|
|
* Path: /home/osvegn/Documents/Repositories/ECS/tests/library/ECS |
4 |
|
|
* Created Date: Tuesday, April 18th 2023, 8:34:03 pm |
5 |
|
|
* Author: osvegn |
6 |
|
|
* |
7 |
|
|
* Copyright (c) 2023 Your Company |
8 |
|
|
*/ |
9 |
|
|
|
10 |
|
|
#include <criterion/criterion.h> |
11 |
|
|
#include <criterion/redirect.h> |
12 |
|
|
#include "world_logger.h" |
13 |
|
|
|
14 |
|
✗ |
void redirect_all_std(void) |
15 |
|
|
{ |
16 |
|
✗ |
cr_redirect_stdout(); |
17 |
|
✗ |
cr_redirect_stderr(); |
18 |
|
|
} |
19 |
|
|
|
20 |
|
✗ |
Test(world_log_init, initialize_logger_with_stdout) |
21 |
|
|
{ |
22 |
|
✗ |
world_log_init(stdout); |
23 |
|
✗ |
world_log_destroy(); |
24 |
|
✗ |
cr_assert(true); |
25 |
|
|
} |
26 |
|
|
|
27 |
|
✗ |
Test(world_log_init, initialize_logger_with_stderr) |
28 |
|
|
{ |
29 |
|
✗ |
world_log_init(stderr); |
30 |
|
✗ |
world_log_destroy(); |
31 |
|
✗ |
cr_assert(true); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
✗ |
Test(world_log_init, initialize_logger_with_null) |
35 |
|
|
{ |
36 |
|
✗ |
world_log_init(0); |
37 |
|
✗ |
world_log_destroy(); |
38 |
|
✗ |
cr_assert(true); |
39 |
|
|
} |
40 |
|
|
|
41 |
|
✗ |
Test(world_log_init, initialize_logger_with_file) |
42 |
|
|
{ |
43 |
|
✗ |
FILE *file = fopen("test.log", "w"); |
44 |
|
✗ |
world_log_init(file); |
45 |
|
✗ |
world_log_destroy(); |
46 |
|
✗ |
cr_assert(true); |
47 |
|
|
} |
48 |
|
|
|
49 |
|
✗ |
Test(world_log_init, initialize_logger_with_invalid_file) |
50 |
|
|
{ |
51 |
|
✗ |
FILE *file = fopen("test.log", "r"); |
52 |
|
✗ |
world_log_init(file); |
53 |
|
✗ |
world_log_destroy(); |
54 |
|
✗ |
cr_assert(true); |
55 |
|
|
} |
56 |
|
|
|
57 |
|
✗ |
Test(world_log, log_debug_message) |
58 |
|
|
{ |
59 |
|
✗ |
cr_redirect_stdout(); |
60 |
|
✗ |
world_log_init(stdout); |
61 |
|
✗ |
cr_assert_eq(log_debug("test"), 0); |
62 |
|
✗ |
world_log_destroy(); |
63 |
|
✗ |
cr_assert(true); |
64 |
|
|
} |
65 |
|
|
|
66 |
|
✗ |
Test(world_log, log_info_message) |
67 |
|
|
{ |
68 |
|
✗ |
cr_redirect_stdout(); |
69 |
|
✗ |
world_log_init(stdout); |
70 |
|
✗ |
cr_assert_eq(log_info("test"), 0); |
71 |
|
✗ |
world_log_destroy(); |
72 |
|
✗ |
cr_assert(true); |
73 |
|
|
} |
74 |
|
|
|
75 |
|
✗ |
Test(world_log, log_warning_message) |
76 |
|
|
{ |
77 |
|
✗ |
cr_redirect_stderr(); |
78 |
|
✗ |
world_log_init(stderr); |
79 |
|
✗ |
cr_assert_eq(log_warn("test"), 0); |
80 |
|
✗ |
world_log_destroy(); |
81 |
|
✗ |
cr_assert(true); |
82 |
|
|
} |
83 |
|
|
|
84 |
|
✗ |
Test(world_log, log_error_message) |
85 |
|
|
{ |
86 |
|
✗ |
cr_redirect_stderr(); |
87 |
|
✗ |
world_log_init(stderr); |
88 |
|
✗ |
cr_assert_eq(log_error("test"), 0); |
89 |
|
✗ |
world_log_destroy(); |
90 |
|
✗ |
cr_assert(true); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
✗ |
Test(world_log, log_fatal_message) |
94 |
|
|
{ |
95 |
|
✗ |
cr_redirect_stderr(); |
96 |
|
✗ |
world_log_init(stderr); |
97 |
|
✗ |
cr_assert_eq(log_fatal("test"), 0); |
98 |
|
✗ |
world_log_destroy(); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
✗ |
Test(world_log, log_debug_message_with_null_logger) |
102 |
|
|
{ |
103 |
|
✗ |
cr_redirect_stdout(); |
104 |
|
✗ |
cr_assert_eq(log_debug("test"), -1); |
105 |
|
|
} |
106 |
|
|
|
107 |
|
✗ |
Test(world_log, unknown_log_level) |
108 |
|
|
{ |
109 |
|
✗ |
cr_redirect_stderr(); |
110 |
|
✗ |
world_log_init(stderr); |
111 |
|
✗ |
cr_assert_eq(world_log(10, "test", 0, "test"), 0); |
112 |
|
✗ |
world_log_destroy(); |
113 |
|
|
} |
114 |
|
|
|