summaryrefslogtreecommitdiff
path: root/src/logging/logging.test.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-06-14 20:53:14 -0500
committersanine <sanine.not@pm.me>2022-06-14 20:53:14 -0500
commit31c6a0939a23b2ce1b450168b93c371f1a3e8d13 (patch)
treee9996748ae24278232fb6f670c15084d62499c8c /src/logging/logging.test.c
parent5d5af62d63c331245a1cb41433fabc0ac25754b6 (diff)
do not log if log level is too low
Diffstat (limited to 'src/logging/logging.test.c')
-rw-r--r--src/logging/logging.test.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/logging/logging.test.c b/src/logging/logging.test.c
index cc6a316..dfcbe4e 100644
--- a/src/logging/logging.test.c
+++ b/src/logging/logging.test.c
@@ -70,12 +70,16 @@ void clean_mock(lily_mock_t **m)
}
}
-void test_log_fatal_succeeds();
+void level_fatal_log_fatal_succeeds();
+void level_neg_log_fatal_fails();
void suite_logging()
{
vfprintf_mock_data = NULL;
- lily_run_test(test_log_fatal_succeeds);
+
+ lily_run_test(level_neg_log_fatal_fails);
+ lily_run_test(level_fatal_log_fatal_succeeds);
+
if (vfprintf_mock_data != NULL)
lily_mock_destroy(vfprintf_mock_data);
}
@@ -88,7 +92,7 @@ void suite_logging()
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
-void test_log_fatal_succeeds()
+void level_fatal_log_fatal_succeeds()
{
clean_mock(&vfprintf_mock_data);
vfprintf_mock_data = lily_mock_create();
@@ -106,6 +110,17 @@ void test_log_fatal_succeeds()
lily_get_call(vfprintf_mock_data, args, 0);
lily_assert_ptr_equal(file, stderr);
- lily_assert_string_equal(fmt, "[FATAL] some message");
+ lily_assert_string_equal((char*) fmt, "[FATAL] some message");
lily_assert_int_equal(n_strings, 0);
}
+
+
+void level_neg_log_fatal_fails()
+{
+ clean_mock(&vfprintf_mock_data);
+ vfprintf_mock_data = lily_mock_create();
+
+ honey_set_log_level(-1);
+ honey_fatal("some message");
+ lily_assert_int_equal(vfprintf_mock_data->n_calls, 0);
+}