From b6a3052c3ebde6114ec6166971b3072460c44814 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Thu, 28 Dec 2017 20:43:30 +1300 Subject: Add more tests, fix misc bugs found --- test/test-short-keyword.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/test-short-keyword.c (limited to 'test/test-short-keyword.c') diff --git a/test/test-short-keyword.c b/test/test-short-keyword.c new file mode 100644 index 0000000..50d44d3 --- /dev/null +++ b/test/test-short-keyword.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +#include "gate.h" +#include "parser.h" + +char *failures[] = { + "input\n", + "input \n", +}; + +char *passes[] = { + "input a\n", + "input aaaaaaaa\n", + "\n", + "\n\n", + "\r", + "\r\r", + "\r\n", + "\n\r", + "\n\n\r", + "\r\n\r", +}; + +int main(void) { + size_t i = 0; + char *string = NULL; + + for (i = 0; i < sizeof(failures)/sizeof(failures[0]); i++) { + string = strdup(failures[i]); + if (string == NULL) { + perror("strdup"); + return 1; + } + fprintf(stderr, "Testing xfail '%s'\n", string); + assert(0 != parse_line(string)); + free(string); + } + for (i = 0; i < sizeof(passes)/sizeof(passes[0]); i++) { + string = strdup(passes[i]); + if (string == NULL) { + perror("strdup"); + return 1; + } + fprintf(stderr, "Testing xpass '%s'\n", string); + assert(0 == parse_line(string)); + free(string); + } + return 0; +} -- cgit v1.1