Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
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
uplex-varnish
trackrdrd
Commits
39abfdc3
Commit
39abfdc3
authored
May 14, 2014
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added more convenience macros to minunit.h
parent
d2d5b4b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
12 deletions
+34
-12
minunit.h
trackrdrd/src/test/minunit.h
+34
-12
No files found.
trackrdrd/src/test/minunit.h
View file @
39abfdc3
...
@@ -39,24 +39,46 @@
...
@@ -39,24 +39,46 @@
* understanding that it comes with NO WARRANTY."
* understanding that it comes with NO WARRANTY."
*/
*/
/* XXX: Format error message in mu_assert() */
#define mu_assert(msg, test) do { if (!(test)) return msg; } while (0)
#define mu_assert(msg, test) do { if (!(test)) return msg; } while (0)
#define mu_run_test(test) do { const char *msg = test(); tests_run++; \
#define mu_run_test(test) do { const char *msg = test(); tests_run++; \
if (msg) return msg; } while (0)
if (msg) return msg; } while (0)
/* phk-ish mu_assert */
#define mu_assert_errno(c) \
#define _massert(test, errmsg, msg, ...) \
do { \
do { \
if (!(c)) { \
if (!(test)) { \
sprintf(errmsg, "%s failed in %s at %s:%d: errno %d (%s)", \
sprintf((errmsg), (msg), __VA_ARGS__); \
#c, __func__, __FILE__, __LINE__, errno, strerror(errno)); \
return (errmsg); \
mu_assert(errmsg, 0); \
} \
} \
} while(0)
#define _massert0(test, errmsg, msg) \
do { \
if (!(test)) { \
sprintf((errmsg), (msg)); \
return (errmsg); \
} \
} while(0)
} while(0)
/* These assume that a global static char* errmsg is declared and
has allocated space. */
#define VMASSERT(test, msg, ...) _massert((test),(errmsg),(msg),__VA_ARGS__)
#define MASSERT0(test, msg) _massert0((test),(errmsg),(msg))
/* This assumes #include <errno.h> and <string.h> */
#define MASSERT(c) \
VMASSERT((c), "%s failed in %s at %s:%d (errno %d: %s)", \
#c, __func__, __FILE__, __LINE__, errno, strerror(errno))
/* short for MU Assert Zero / Non-Zero */
/* short for MU Assert Zero / Non-Zero */
#define MAZ(c) do { mu_assert_errno((c) == 0); } while(0)
#define MAZ(c) MASSERT((c) == 0)
#define MAN(c) do { mu_assert_errno((c) != 0); } while(0)
#define MAN(c) MASSERT((c) != 0)
#define MCHECK_OBJ(ptr, type_magic) MASSERT((ptr)->magic == type_magic)
#define MCHECK_OBJ_NOTNULL(ptr, type_magic) \
do { \
MAN(ptr); \
MCHECK_OBJ(ptr, type_magic); \
} while(0)
extern
int
tests_run
;
extern
int
tests_run
;
...
...
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