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
c6c0f79d
Commit
c6c0f79d
authored
May 16, 2014
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more refactoring of minunit.h -- now declares its own error message
buffer, and includes all necessary headers
parent
39abfdc3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
minunit.h
trackrdrd/src/test/minunit.h
+18
-11
No files found.
trackrdrd/src/test/minunit.h
View file @
c6c0f79d
...
...
@@ -29,7 +29,13 @@
*
*/
#ifndef _MINUNIT_INCLUDED
#define _MINUNIT_INCLUDED
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
/*-
* Adapted from http://www.jera.com/techinfo/jtns/jtn002.html
...
...
@@ -43,28 +49,27 @@
#define mu_run_test(test) do { const char *msg = test(); tests_run++; \
if (msg) return msg; } while (0)
#define _massert(test, errmsg, msg, ...) \
char
_mu_errmsg
[
BUFSIZ
];
#define _massert(test, msg, ...) \
do { \
if (!(test)) { \
sprintf((
errmsg), (msg), __VA_ARGS__);
\
return (
errmsg);
\
sprintf((
_mu_errmsg), (msg), __VA_ARGS__);
\
return (
_mu_errmsg);
\
} \
} while(0)
#define _massert0(test,
errmsg, msg)
\
#define _massert0(test,
msg)
\
do { \
if (!(test)) { \
sprintf((
errmsg), (msg));
\
return (
errmsg);
\
sprintf((
_mu_errmsg), (msg));
\
return (
_mu_errmsg);
\
} \
} 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))
#define VMASSERT(test, msg, ...) _massert((test),(msg),__VA_ARGS__)
#define MASSERT0(test, msg) _massert0((test),(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))
...
...
@@ -97,3 +102,5 @@ main(int argc, char **argv) \
} \
exit(EXIT_SUCCESS); \
}
#endif
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