#include #include #include #include #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; }