summaryrefslogtreecommitdiff
path: root/src/test/logging
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2021-09-25 10:45:36 -0500
committersanine <sanine.not@pm.me>2021-09-25 10:45:36 -0500
commit732aca2a13ebab4f4fb3418b103b91d57e698ccb (patch)
tree05a89605a1b836c63c44a21c0c8c4f0ad17c8427 /src/test/logging
parent78e262b448e034e96aa75193a76d36cd0062daf7 (diff)
add honey_info() log function
Diffstat (limited to 'src/test/logging')
-rw-r--r--src/test/logging/logging_tests.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/logging/logging_tests.c b/src/test/logging/logging_tests.c
index b2dacf3..f50cbfb 100644
--- a/src/test/logging/logging_tests.c
+++ b/src/test/logging/logging_tests.c
@@ -12,6 +12,7 @@
mu_test test_log_get_level();
mu_test test_log_set_defaults();
mu_test test_log_debug();
+mu_test test_log_info();
/* main suite */
@@ -20,6 +21,7 @@ void honey_logging_tests()
{
mu_run_test("get log level strings", test_log_get_level);
mu_run_test("print debug message", test_log_debug);
+ mu_run_test("print info message", test_log_info);
}
@@ -72,6 +74,7 @@ mu_test test_log_debug()
honey_log_set_level(DEBUG);
mu_assert_equal(honey_log_get_level(), DEBUG);
+
honey_debug("hello, %s!", "world");
fclose(stream);
mu_assert_streq(buffer, "[DEBUG] hello, world!");
@@ -79,3 +82,34 @@ mu_test test_log_debug()
return 0;
}
+
+
+mu_test test_log_info()
+{
+ FILE *stream;
+ char *buffer;
+ size_t len;
+
+ stream = open_memstream(&buffer, &len);
+ mu_assert_unequal(stream, NULL);
+
+ honey_log_set_file(stream);
+ mu_assert_equal(honey_log_get_file(), stream);
+
+ honey_log_set_level(FATAL);
+ mu_assert_equal(honey_log_get_level(), FATAL);
+
+ honey_info("hello, %s!", "world");
+ fflush(stream);
+ mu_assert_streq(buffer, "");
+
+ honey_log_set_level(INFO);
+ mu_assert_equal(honey_log_get_level(), INFO);
+
+ honey_info("hello, %s!", "world");
+ fclose(stream);
+ mu_assert_streq(buffer, "[INFO] hello, world!");
+ free(buffer);
+
+ return 0;
+}