.Ss PRINTF STRINGS
In the descriptions that follow, for any function that takes as the
last two parameters
-.Dq Fa char * , Fa ...
+.Dq Fa const char * , Fa ...
it can be assumed that the
-.Fa char *
+.Fa const char *
is a
.Fn printf
-like format string, and the optional arguments are values to be placed
.Xc
.It Xo
.Ft void
-.Fn plan_skip_all "char *" "..."
+.Fn plan_skip_all "const char *" "..."
.Xc
.El
.Pp
.Bl -tag -width indent
.It Xo
.Ft unsigned int
-.Fn ok "expression" "char *" "..."
+.Fn ok "expression" "const char *" "..."
.Xc
.It Xo
.Ft unsigned int
.Xc
.It Xo
.Ft unsigned int
-.Fn pass "char *" "..."
+.Fn pass "const char *" "..."
.Xc
.It Xo
.Ft unsigned int
-.Fn fail "char *" "..."
+.Fn fail "const char *" "..."
.Xc
.El
.Pp
.Bl -tag -width indent
.It Xo
.Ft void
-.Fn skip "unsigned int" "char *" "..."
+.Fn skip "unsigned int" "const char *" "..."
.Xc
.It Xo
-.Fn skip_if "expression" "unsigned int" "char *" "..."
+.Fn skip_if "expression" "unsigned int" "const char *" "..."
.Xc
.El
.Pp
.Bl -tag -width indent
.It Xo
.Ft void
-.Fn todo_start "char *" "..."
+.Fn todo_start "const char *" "..."
.Xc
.It Xo
.Ft void
.Ss DIAGNOSTIC OUTPUT
.Bl -tag -width indent
.It Xo
-.Fr void
-.Fn diag "char *" "..."
+.Fr int
+.Fn diag "const char *" "..."
.Xc
.El
.Pp
adds the necessary trailing
.Dq \en
for you.
+It returns the number of characters written.
.Bd -literal -offset indent
diag("Expected return code 0, got return code %d", rcode);
.Ed
static unsigned int e_tests = 0; /* Expected number of tests to run */
static unsigned int failures = 0; /* Number of tests that failed */
static char *todo_msg = NULL;
-static char *todo_msg_fixed = "libtap malloc issue";
+static const char *todo_msg_fixed = "libtap malloc issue";
static int todo = 0;
static int test_died = 0;
static int test_pid;
}
static void
-diagv(char *fmt, va_list ap)
+diagv(const char *fmt, va_list ap)
{
fputs("# ", stdout);
vfprintf(stdout, fmt, ap);
}
static void
-_diag(char *fmt, ...)
+_diag(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
* test_comment -- a comment to print afterwards, may be NULL
*/
unsigned int
-_gen_result(int ok, const char *func, char *file, unsigned int line,
- char *test_name, ...)
+_gen_result(int ok, const char *func, const char *file, unsigned int line,
+ const char *test_name, ...)
{
va_list ap;
char *local_test_name = NULL;
* Note that the plan is to skip all tests
*/
void
-plan_skip_all(char *reason)
+plan_skip_all(const char *reason)
{
LOCK;
}
void
-diag(char *fmt, ...)
+diag(const char *fmt, ...)
{
va_list ap;
}
void
-skip(unsigned int n, char *fmt, ...)
+skip(unsigned int n, const char *fmt, ...)
{
va_list ap;
char *skip_msg;
}
void
-todo_start(char *fmt, ...)
+todo_start(const char *fmt, ...)
{
va_list ap;
#endif
#endif
-unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...)
- PRINTF_ATTRIBUTE(5, 6);
+unsigned int _gen_result(int, const char *, const char *, unsigned int,
+ const char *, ...) PRINTF_ATTRIBUTE(5, 6);
/**
* diag - print a diagnostic message (use instead of printf/fprintf)
* Example:
* diag("Now running complex tests");
*/
-void diag(char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
+void diag(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
/**
* skip - print a diagnostic message (use instead of printf/fprintf)
* skip(1, "Don't have SOME_FEATURE");
* #endif
*/
-void skip(unsigned int n, char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
+void skip(unsigned int n, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
/**
* todo_start - mark tests that you expect to fail.
* ok(dwim(), "Did what the user wanted");
* todo_end();
*/
-void todo_start(char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
+void todo_start(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
/**
* todo_end - end of tests you expect to fail.
* }
* plan_tests(13);
*/
-void plan_skip_all(char *reason);
+void plan_skip_all(const char *reason);
#endif /* C99 or gcc */