summaryrefslogtreecommitdiff
path: root/src/test/logging/logging_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/logging/logging_tests.c')
-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;
+}