git.fiddlerwoaroof.com
Browse code

factor check into test util header

Greg Wiley authored on 06/04/2017 16:03:03
Showing 3 changed files
1 1
Binary files a/logging_test and b/logging_test differ
... ...
@@ -4,6 +4,8 @@
4 4
 #include "dc_syslog.h"
5 5
 #include "logging.h"
6 6
 
7
+#include "testutil.h"
8
+
7 9
 int logged_priority = -1000;
8 10
 const char *logged_message = "";
9 11
 void dc_syslog(int priority, const char *message, ...) {
... ...
@@ -25,21 +27,6 @@ void dc_openlog(const char *ident, int logopt, int facility) {
25 27
     opened_logopt = logopt;
26 28
 }
27 29
 
28
-
29
-#define check(assertion, msg) \
30
-    if (!(assertion)) { \
31
-      fprintf(stderr, "assertion failed: %s\n", msg); \
32
-      return 0; \
33
-    }
34
-
35
-#define checkint(expected, actual, name) \
36
-    check(expected == actual, name " should be " #expected)
37
-
38
-#define checkstr(expected, actual, name) \
39
-    check(!strcmp(actual, expected), name " should be '" expected "'")
40
-
41
-#define succeed() return 1
42
-
43 30
 int test_log_success() {
44 31
     // given
45 32
     opened_facility = -1000;
46 33
new file mode 100644
... ...
@@ -0,0 +1,19 @@
1
+#ifndef _TESTUTIL_H
2
+#define _TESTUTIL_H
3
+
4
+#define check(assertion, msg) \
5
+    if (!(assertion)) { \
6
+      fprintf(stderr, "assertion failed: %s\n", msg); \
7
+      return 0; \
8
+    }
9
+
10
+#define checkint(expected, actual, name) \
11
+    check(expected == actual, name " should be " #expected)
12
+
13
+#define checkstr(expected, actual, name) \
14
+    check(!strcmp(actual, expected), name " should be '" expected "'")
15
+
16
+#define succeed() return 1
17
+
18
+#endif
19
+