diff options
Diffstat (limited to 'test/old')
-rw-r--r-- | test/old/test-duplicate-input.c | 13 | ||||
-rw-r--r-- | test/old/test-short-keyword.c | 76 | ||||
-rw-r--r-- | test/old/test-whitespace-input.c | 11 |
3 files changed, 100 insertions, 0 deletions
diff --git a/test/old/test-duplicate-input.c b/test/old/test-duplicate-input.c new file mode 100644 index 0000000..8d1b88f --- /dev/null +++ b/test/old/test-duplicate-input.c @@ -0,0 +1,13 @@ +#include <assert.h> + +#include "gate.h" +#include "parser.h" + +int main(void) { + char test_string[] = "input test\n"; + assert(0 == parse_line(test_string)); + assert(gate_get_input_by_name("test") != NULL); + assert(0 != parse_line(test_string)); + assert(gate_get_input_by_name("test") != NULL); + return 0; +} diff --git a/test/old/test-short-keyword.c b/test/old/test-short-keyword.c new file mode 100644 index 0000000..b3baa2c --- /dev/null +++ b/test/old/test-short-keyword.c @@ -0,0 +1,76 @@ +#include <assert.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#include "gate.h" +#include "parser.h" + +char *failures[] = { + "input" + "input\n", + "input \n", + "input aa aa\n", + "module", + " module ", + "\tmodule ", + " moudle \t\n ", + "expr ", + " expr ", + "expr", + "expr asdf xor a b", + "expr asdf: xor b", + "expr asdf: foo b", + "expr asdf: foo a b", +}; + +char *passes[] = { + "input aa", + "input a\n", + "input aaaaaaaa\n", + "module test", + "module test", + "module test ", + "module test ", + " \tmodule \ttest \t", + "expr asdf: xor aa a", + "expr asdf: not aa", + " expr asdf: not aa ", + "\n", + "\n\n", + "\r", + "\r\r", + "\r\n", + "\n\r", + "\n\n\r", + "\r\n\r", + "", + "\t" +}; + +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; +} diff --git a/test/old/test-whitespace-input.c b/test/old/test-whitespace-input.c new file mode 100644 index 0000000..cb4ec22 --- /dev/null +++ b/test/old/test-whitespace-input.c @@ -0,0 +1,11 @@ +#include <assert.h> + +#include "gate.h" +#include "parser.h" + +int main(void) { + char test_string[] = "input b \n"; + parse_line(test_string); + assert(gate_get_input_by_name("b") != NULL); + return 0; +} |