diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-10-09 23:47:24 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-10-09 23:47:24 +0200 |
commit | 5692f32bcfa049fc2b5555b5a883045b217349b9 (patch) | |
tree | 512eaa1bece48291ffdf7cf4865a085e6ee0b2cc /tests/taplib.c | |
parent | 3465d5553fbe88a75320d1da3f7228619492b036 (diff) | |
download | termo-5692f32bcfa049fc2b5555b5a883045b217349b9.tar.gz termo-5692f32bcfa049fc2b5555b5a883045b217349b9.tar.xz termo-5692f32bcfa049fc2b5555b5a883045b217349b9.zip |
CMake-ify, rename to termkey2 for the time being
Diffstat (limited to 'tests/taplib.c')
-rw-r--r-- | tests/taplib.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/taplib.c b/tests/taplib.c new file mode 100644 index 0000000..bfb70f8 --- /dev/null +++ b/tests/taplib.c @@ -0,0 +1,79 @@ +#include "taplib.h" + +#include <stdio.h> +#include <stdarg.h> +#include <string.h> + +static int g_nexttest = 1; +static int g_exit_status = 0; + +void +plan_tests (int n) +{ + printf ("1..%d\n", n); +} + +void +pass (char *name) +{ + printf ("ok %d - %s\n", g_nexttest++, name); +} + +void +fail (char *name) +{ + printf ("not ok %d - %s\n", g_nexttest++, name); + g_exit_status = 1; +} + +void +ok (int cmp, char *name) +{ + if (cmp) + pass (name); + else + fail (name); +} + +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 (const char *got, const 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 g_exit_status; +} |