Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
84a11fe3
Commit
84a11fe3
authored
Feb 08, 2018
by
Deomid Ryabkov
Committed by
Cesanta Bot
Feb 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Count both tests and individual checks
CL: none PUBLISHED_FROM=ab7f50e1c68154832e862ebfb4a02d385ef7c6be
parent
2a3cfc98
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
test_util.h
src/common/test_util.h
+11
-9
No files found.
src/common/test_util.h
View file @
84a11fe3
...
@@ -28,6 +28,7 @@ extern "C" {
...
@@ -28,6 +28,7 @@ extern "C" {
#endif
#endif
extern
int
g_num_tests
;
extern
int
g_num_tests
;
extern
int
g_num_checks
;
#ifdef MG_TEST_ABORT_ON_FAIL
#ifdef MG_TEST_ABORT_ON_FAIL
#define MG_TEST_ABORT abort()
#define MG_TEST_ABORT abort()
...
@@ -48,7 +49,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -48,7 +49,7 @@ void _strfail(const char *a, const char *e, int len);
#define ASSERT(expr) \
#define ASSERT(expr) \
do { \
do { \
g_num_
tests++;
\
g_num_
checks++;
\
if (!(expr)) FAIL(#expr, __LINE__); \
if (!(expr)) FAIL(#expr, __LINE__); \
} while (0)
} while (0)
#define ASSERT_TRUE(expr) ASSERT(expr)
#define ASSERT_TRUE(expr) ASSERT(expr)
...
@@ -71,6 +72,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -71,6 +72,7 @@ void _strfail(const char *a, const char *e, int len);
elapsed = cs_time() - elapsed; \
elapsed = cs_time() - elapsed; \
printf(" [%.3f] %s\n", elapsed, test_name); \
printf(" [%.3f] %s\n", elapsed, test_name); \
fflush(stdout); \
fflush(stdout); \
g_num_tests++; \
} \
} \
if (msg) return msg; \
if (msg) return msg; \
} while (0)
} while (0)
...
@@ -88,7 +90,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -88,7 +90,7 @@ void _strfail(const char *a, const char *e, int len);
*/
*/
#define ASSERT_EQ(actual, expected) \
#define ASSERT_EQ(actual, expected) \
do { \
do { \
g_num_
tests++;
\
g_num_
checks++;
\
if (!((actual) == (expected))) { \
if (!((actual) == (expected))) { \
printf("%f != %f\n", AS_DOUBLE(actual), AS_DOUBLE(expected)); \
printf("%f != %f\n", AS_DOUBLE(actual), AS_DOUBLE(expected)); \
FAIL(#actual " == " #expected, __LINE__); \
FAIL(#actual " == " #expected, __LINE__); \
...
@@ -98,7 +100,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -98,7 +100,7 @@ void _strfail(const char *a, const char *e, int len);
/* "Less than" assertion. */
/* "Less than" assertion. */
#define ASSERT_LT(a, b) \
#define ASSERT_LT(a, b) \
do { \
do { \
g_num_
tests++;
\
g_num_
checks++;
\
if (!((a) < (b))) { \
if (!((a) < (b))) { \
printf("%f >= %f\n", AS_DOUBLE(a), AS_DOUBLE(b)); \
printf("%f >= %f\n", AS_DOUBLE(a), AS_DOUBLE(b)); \
FAIL(#a " < " #b, __LINE__); \
FAIL(#a " < " #b, __LINE__); \
...
@@ -108,7 +110,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -108,7 +110,7 @@ void _strfail(const char *a, const char *e, int len);
/* "Greater than" assertion. */
/* "Greater than" assertion. */
#define ASSERT_GT(a, b) \
#define ASSERT_GT(a, b) \
do { \
do { \
g_num_
tests++;
\
g_num_
checks++;
\
if (!((a) > (b))) { \
if (!((a) > (b))) { \
printf("%f <= %f\n", AS_DOUBLE(a), AS_DOUBLE(b)); \
printf("%f <= %f\n", AS_DOUBLE(a), AS_DOUBLE(b)); \
FAIL(#a " > " #b, __LINE__); \
FAIL(#a " > " #b, __LINE__); \
...
@@ -118,7 +120,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -118,7 +120,7 @@ void _strfail(const char *a, const char *e, int len);
/* Assert that actual == expected, where both are NUL-terminated. */
/* Assert that actual == expected, where both are NUL-terminated. */
#define ASSERT_STREQ(actual, expected) \
#define ASSERT_STREQ(actual, expected) \
do { \
do { \
g_num_
tests++;
\
g_num_
checks++;
\
if (!_assert_streq(actual, expected)) { \
if (!_assert_streq(actual, expected)) { \
FAIL("ASSERT_STREQ(" #actual ", " #expected ")", __LINE__); \
FAIL("ASSERT_STREQ(" #actual ", " #expected ")", __LINE__); \
} \
} \
...
@@ -127,7 +129,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -127,7 +129,7 @@ void _strfail(const char *a, const char *e, int len);
/* Assert that actual == expected, where both are pointers */
/* Assert that actual == expected, where both are pointers */
#define ASSERT_PTREQ(actual, expected) \
#define ASSERT_PTREQ(actual, expected) \
do { \
do { \
g_num_
tests++;
\
g_num_
checks++;
\
if (actual != expected) { \
if (actual != expected) { \
printf("%p != %p\n", actual, expected); \
printf("%p != %p\n", actual, expected); \
FAIL("ASSERT_PTREQ(" #actual ", " #expected ")", __LINE__); \
FAIL("ASSERT_PTREQ(" #actual ", " #expected ")", __LINE__); \
...
@@ -137,7 +139,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -137,7 +139,7 @@ void _strfail(const char *a, const char *e, int len);
/* Assert that actual != expected, where both are pointers */
/* Assert that actual != expected, where both are pointers */
#define ASSERT_PTRNEQ(actual, expected) \
#define ASSERT_PTRNEQ(actual, expected) \
do { \
do { \
g_num_
tests++;
\
g_num_
checks++;
\
if (actual == expected) { \
if (actual == expected) { \
printf("%p == %p\n", actual, expected); \
printf("%p == %p\n", actual, expected); \
FAIL("ASSERT_PTRNEQ(" #actual ", " #expected ")", __LINE__); \
FAIL("ASSERT_PTRNEQ(" #actual ", " #expected ")", __LINE__); \
...
@@ -147,7 +149,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -147,7 +149,7 @@ void _strfail(const char *a, const char *e, int len);
/* Same as STREQ, but only expected is NUL-terminated. */
/* Same as STREQ, but only expected is NUL-terminated. */
#define ASSERT_STREQ_NZ(actual, expected) \
#define ASSERT_STREQ_NZ(actual, expected) \
do { \
do { \
g_num_
tests++;
\
g_num_
checks++;
\
if (!_assert_streq_nz(actual, expected)) { \
if (!_assert_streq_nz(actual, expected)) { \
FAIL("ASSERT_STREQ_NZ(" #actual ", " #expected ")", __LINE__); \
FAIL("ASSERT_STREQ_NZ(" #actual ", " #expected ")", __LINE__); \
} \
} \
...
@@ -155,7 +157,7 @@ void _strfail(const char *a, const char *e, int len);
...
@@ -155,7 +157,7 @@ void _strfail(const char *a, const char *e, int len);
#define ASSERT_MG_STREQ(actual, expected) \
#define ASSERT_MG_STREQ(actual, expected) \
do { \
do { \
g_num_
tests++;
\
g_num_
checks++;
\
if ((actual).len != strlen(expected) || \
if ((actual).len != strlen(expected) || \
memcmp((actual).p, expected, (actual).len) != 0) { \
memcmp((actual).p, expected, (actual).len) != 0) { \
printf("'%.*s' (%d) != '%s'\n", (int)(actual).len, (actual).p, \
printf("'%.*s' (%d) != '%s'\n", (int)(actual).len, (actual).p, \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment