summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/logging/logging_tests.c40
-rw-r--r--src/test/minunit.h17
2 files changed, 48 insertions, 9 deletions
diff --git a/src/test/logging/logging_tests.c b/src/test/logging/logging_tests.c
index 2e92d68..2a07d30 100644
--- a/src/test/logging/logging_tests.c
+++ b/src/test/logging/logging_tests.c
@@ -1,6 +1,42 @@
-#include "../minunit.h"
-#include "../suites.h"
+#include "test/minunit.h"
+#include "test/suites.h"
+
+#include "logging/logging.h"
+
+
+/* test declarations */
+
+mu_test test_log_get_level();
+
+
+/* main suite */
void honey_logging_tests()
{
+ mu_run_test("get log level strings", test_log_get_level);
+}
+
+
+/* test definitions */
+
+mu_test test_log_get_level()
+{
+ struct honey_log_info info;
+
+ info.log_level = DEBUG;
+ mu_assert_streq("DEBUG", honey_log_level_str_(&info));
+
+ info.log_level = INFO;
+ mu_assert_streq("INFO", honey_log_level_str_(&info));
+
+ info.log_level = WARN;
+ mu_assert_streq("WARN", honey_log_level_str_(&info));
+
+ info.log_level = ERROR;
+ mu_assert_streq("ERROR", honey_log_level_str_(&info));
+
+ info.log_level = FATAL;
+ mu_assert_streq("FATAL", honey_log_level_str_(&info));
+
+ return 0;
}
diff --git a/src/test/minunit.h b/src/test/minunit.h
index b1bfda7..ed5e57d 100644
--- a/src/test/minunit.h
+++ b/src/test/minunit.h
@@ -2,6 +2,7 @@
#define MINUNIT_H
#include <stdio.h>
+#include <string.h>
#define STR_IMPL(x) #x
#define STR(x) STR_IMPL(x)
@@ -9,7 +10,7 @@
#define MU_INDENT " "
/* minunit testing macros from /www.jera.com/techinfo/jtns/jtn002.html */
-#define mu_assert(test, message) do { if (!(test)) return message "\n" MU_INDENT "[" __FILE__ ":" STR(__LINE__) "]"; } while (0)
+#define mu_assert(test, message) do { if (!(test)) return message "\n" MU_INDENT " [" __FILE__ ":" STR(__LINE__) "]"; } while (0)
#define mu_assert_equal(a, b) mu_assert(a == b, "'" #a "' is not equal to '" #b "'")
#define mu_assert_unequal(a, b) mu_assert(a != b, "'" #a "' is equal to '" #b "'")
#define mu_assert_streq(a, b) mu_assert(strcmp(a, b) == 0, "'" #a "' is not equal to '" #b "'")
@@ -22,12 +23,14 @@
tests_failed++; \
} \
} while (0)
-#define mu_run_suite(suite) do { \
- int tests_run_old = tests_run; \
- printf("suite: " #suite "\n"); \
- suite(); \
- printf(MU_INDENT "ran %d tests\n\n", \
- tests_run - tests_run_old); \
+#define mu_run_suite(suite) do { \
+ int run_old = tests_run; \
+ int failed_old = tests_failed; \
+ printf("suite: " #suite "\n"); \
+ suite(); \
+ printf(MU_INDENT "ran %d tests, %d failed\n\n", \
+ tests_run - run_old, \
+ tests_failed - failed_old); \
} while(0)
#define mu_tests_finished() do { \
printf("ran %d tests, %d failed\n", tests_run, tests_failed); \