aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>2011-03-31 12:46:06 +0100
committerPaul LeoNerd Evans <leonerd@leonerd.org.uk>2011-03-31 12:46:06 +0100
commit0ea0fb331b62a6239090f8d840fc0821d157a67c (patch)
tree21e5f5a513d9b7ceef56cd03b5e5a6e243e6fbf0 /t
parent9d7f0037a83f0a3bc84fea4784e3728dcb5002bf (diff)
downloadtermo-0ea0fb331b62a6239090f8d840fc0821d157a67c.tar.gz
termo-0ea0fb331b62a6239090f8d840fc0821d157a67c.tar.xz
termo-0ea0fb331b62a6239090f8d840fc0821d157a67c.zip
is()-like testing for ints and strings
Diffstat (limited to 't')
-rw-r--r--t/taplib.c34
-rw-r--r--t/taplib.h2
2 files changed, 36 insertions, 0 deletions
diff --git a/t/taplib.c b/t/taplib.c
index 0e8735a..256523f 100644
--- a/t/taplib.c
+++ b/t/taplib.c
@@ -1,6 +1,8 @@
#include "taplib.h"
#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
static int nexttest = 1;
static int _exit_status = 0;
@@ -17,6 +19,38 @@ void ok(int cmp, char *name)
_exit_status = 1;
}
+void diag(char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+
+ fprintf(stderr, "# ");
+ vfprintf(stderr, fmt, args);
+ fprintf(stderr, "\n");
+
+ va_end(args);
+}
+
+void is_int(int got, int expect, char *name)
+{
+ if(got == expect)
+ ok(1, name);
+ else {
+ ok(0, name);
+ diag("got %d expected %d", got, expect);
+ }
+}
+
+void is_str(char *got, char *expect, char *name)
+{
+ if(strcmp(got, expect) == 0)
+ ok(1, name);
+ else {
+ ok(0, name);
+ diag("got '%s' expected '%s'", got, expect);
+ }
+}
+
int exit_status(void)
{
return _exit_status;
diff --git a/t/taplib.h b/t/taplib.h
index 16e41b6..b675329 100644
--- a/t/taplib.h
+++ b/t/taplib.h
@@ -1,3 +1,5 @@
void plan_tests(int n);
void ok(int cmp, char *name);
+void is_int(int got, int expect, char *name);
+void is_str(char *got, char *expect, char *name);
int exit_status(void);