2011-03-31 13:11:19 +02:00
|
|
|
#include "taplib.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2011-03-31 13:46:06 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
2011-03-31 13:11:19 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
static int g_nexttest = 1;
|
|
|
|
static int g_exit_status = 0;
|
2011-03-31 13:11:19 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
void
|
|
|
|
plan_tests (int n)
|
2011-03-31 13:11:19 +02:00
|
|
|
{
|
2014-09-28 05:56:13 +02:00
|
|
|
printf ("1..%d\n", n);
|
2011-03-31 13:11:19 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
void
|
|
|
|
pass (char *name)
|
2013-01-04 18:39:41 +01:00
|
|
|
{
|
2014-09-28 05:56:13 +02:00
|
|
|
printf ("ok %d - %s\n", g_nexttest++, name);
|
2013-01-04 18:39:41 +01:00
|
|
|
}
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
void
|
|
|
|
fail (char *name)
|
2013-01-04 18:39:41 +01:00
|
|
|
{
|
2014-09-28 05:56:13 +02:00
|
|
|
printf ("not ok %d - %s\n", g_nexttest++, name);
|
|
|
|
g_exit_status = 1;
|
2013-01-04 18:39:41 +01:00
|
|
|
}
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
void
|
|
|
|
ok (int cmp, char *name)
|
2011-03-31 13:11:19 +02:00
|
|
|
{
|
2014-09-28 05:56:13 +02:00
|
|
|
if (cmp)
|
|
|
|
pass (name);
|
|
|
|
else
|
|
|
|
fail (name);
|
2011-03-31 13:11:19 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
void
|
|
|
|
diag (char *fmt, ...)
|
2011-03-31 13:46:06 +02:00
|
|
|
{
|
2014-09-28 05:56:13 +02:00
|
|
|
va_list args;
|
|
|
|
va_start (args, fmt);
|
2011-03-31 13:46:06 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
fprintf (stderr, "# ");
|
|
|
|
vfprintf (stderr, fmt, args);
|
|
|
|
fprintf (stderr, "\n");
|
2011-03-31 13:46:06 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
va_end (args);
|
2011-03-31 13:46:06 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
void
|
|
|
|
is_int (int got, int expect, char *name)
|
2011-03-31 13:46:06 +02:00
|
|
|
{
|
2014-09-28 05:56:13 +02:00
|
|
|
if (got == expect)
|
|
|
|
ok (1, name);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok (0, name);
|
|
|
|
diag ("got %d expected %d", got, expect);
|
|
|
|
}
|
2011-03-31 13:46:06 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
void
|
|
|
|
is_str (const char *got, const char *expect, char *name)
|
2011-03-31 13:46:06 +02:00
|
|
|
{
|
2014-09-28 05:56:13 +02:00
|
|
|
if (strcmp (got, expect) == 0)
|
|
|
|
ok (1, name);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok (0, name);
|
|
|
|
diag ("got '%s' expected '%s'", got, expect);
|
|
|
|
}
|
2011-03-31 13:46:06 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
int
|
|
|
|
exit_status(void)
|
2011-03-31 13:11:19 +02:00
|
|
|
{
|
2014-09-28 05:56:13 +02:00
|
|
|
return g_exit_status;
|
2011-03-31 13:11:19 +02:00
|
|
|
}
|