27
27
extern "C" {
28
28
#endif
29
29
30
- extern int num_tests ;
30
+ extern int g_num_tests ;
31
31
32
32
#ifdef MG_TEST_ABORT_ON_FAIL
33
33
#define MG_TEST_ABORT abort()
@@ -48,7 +48,7 @@ void _strfail(const char *a, const char *e, int len);
48
48
49
49
#define ASSERT (expr ) \
50
50
do { \
51
- num_tests ++; \
51
+ g_num_tests ++; \
52
52
if (!(expr)) FAIL(#expr, __LINE__); \
53
53
} while (0)
54
54
#define ASSERT_TRUE (expr ) ASSERT(expr)
@@ -71,7 +71,6 @@ void _strfail(const char *a, const char *e, int len);
71
71
elapsed = cs_time() - elapsed; \
72
72
printf(" [%.3f] %s\n", elapsed, test_name); \
73
73
fflush(stdout); \
74
- *total_elapsed += elapsed; \
75
74
} \
76
75
if (msg) return msg; \
77
76
} while (0)
@@ -89,7 +88,7 @@ void _strfail(const char *a, const char *e, int len);
89
88
*/
90
89
#define ASSERT_EQ (actual , expected ) \
91
90
do { \
92
- num_tests ++; \
91
+ g_num_tests ++; \
93
92
if (!((actual) == (expected))) { \
94
93
printf("%f != %f\n", AS_DOUBLE(actual), AS_DOUBLE(expected)); \
95
94
FAIL(#actual " == " #expected, __LINE__); \
@@ -99,7 +98,7 @@ void _strfail(const char *a, const char *e, int len);
99
98
/* "Less than" assertion. */
100
99
#define ASSERT_LT (a , b ) \
101
100
do { \
102
- num_tests ++; \
101
+ g_num_tests ++; \
103
102
if (!((a) < (b))) { \
104
103
printf("%f >= %f\n", AS_DOUBLE(a), AS_DOUBLE(b)); \
105
104
FAIL(#a " < " #b, __LINE__); \
@@ -109,7 +108,7 @@ void _strfail(const char *a, const char *e, int len);
109
108
/* "Greater than" assertion. */
110
109
#define ASSERT_GT (a , b ) \
111
110
do { \
112
- num_tests ++; \
111
+ g_num_tests ++; \
113
112
if (!((a) > (b))) { \
114
113
printf("%f <= %f\n", AS_DOUBLE(a), AS_DOUBLE(b)); \
115
114
FAIL(#a " > " #b, __LINE__); \
@@ -119,7 +118,7 @@ void _strfail(const char *a, const char *e, int len);
119
118
/* Assert that actual == expected, where both are NUL-terminated. */
120
119
#define ASSERT_STREQ (actual , expected ) \
121
120
do { \
122
- num_tests ++; \
121
+ g_num_tests ++; \
123
122
if (!_assert_streq(actual, expected)) { \
124
123
FAIL("ASSERT_STREQ(" #actual ", " #expected ")", __LINE__); \
125
124
} \
@@ -128,7 +127,7 @@ void _strfail(const char *a, const char *e, int len);
128
127
/* Assert that actual == expected, where both are pointers */
129
128
#define ASSERT_PTREQ (actual , expected ) \
130
129
do { \
131
- num_tests ++; \
130
+ g_num_tests ++; \
132
131
if (actual != expected) { \
133
132
printf("%p != %p\n", actual, expected); \
134
133
FAIL("ASSERT_PTREQ(" #actual ", " #expected ")", __LINE__); \
@@ -138,7 +137,7 @@ void _strfail(const char *a, const char *e, int len);
138
137
/* Assert that actual != expected, where both are pointers */
139
138
#define ASSERT_PTRNEQ (actual , expected ) \
140
139
do { \
141
- num_tests ++; \
140
+ g_num_tests ++; \
142
141
if (actual == expected) { \
143
142
printf("%p == %p\n", actual, expected); \
144
143
FAIL("ASSERT_PTRNEQ(" #actual ", " #expected ")", __LINE__); \
@@ -148,15 +147,15 @@ void _strfail(const char *a, const char *e, int len);
148
147
/* Same as STREQ, but only expected is NUL-terminated. */
149
148
#define ASSERT_STREQ_NZ (actual , expected ) \
150
149
do { \
151
- num_tests ++; \
150
+ g_num_tests ++; \
152
151
if (!_assert_streq_nz(actual, expected)) { \
153
152
FAIL("ASSERT_STREQ_NZ(" #actual ", " #expected ")", __LINE__); \
154
153
} \
155
154
} while (0)
156
155
157
156
#define ASSERT_MG_STREQ (actual , expected ) \
158
157
do { \
159
- num_tests ++; \
158
+ g_num_tests ++; \
160
159
if ((actual).len != strlen(expected) || \
161
160
memcmp((actual).p, expected, (actual).len) != 0) { \
162
161
printf("'%.*s' (%d) != '%s'\n", (int)(actual).len, (actual).p, \
0 commit comments