-
-
Save gcmurphy/3365371 to your computer and use it in GitHub Desktop.
Basic TAP test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() | |
{ | |
const char *answer; | |
plan_tests(2); | |
answer = read_answer(stdin); | |
if (!answer){ | |
fail("Malformed JSON data provided"); | |
} else { | |
pass("Valid JSON data recieved"); | |
} | |
skip_start(! answer, 1, "Skipping because malformed JSON data received") ; | |
ok(check_banned(answer), "No banned functions allowed"); | |
skip_end; | |
return exit_status(); | |
} | |
/* Test case */ | |
static int check_banned(const char *str) | |
{ | |
const char *banned[] = { | |
"[\t\r\n ]strcpy[\t\r\n ]*(", | |
"[\t\r\n ]sprintf[\t\r\n ]*(", | |
"[\t\r\n ]gets[\t\r\n ]*(", | |
"[\t\r\n ]alloca[\t\r\n ]*(" | |
}; | |
unsigned short i; | |
if (str == NULL) | |
return FAIL; | |
for (i = 0; i < sizeof(banned)/sizeof(banned[0]); i++){ | |
if (match(banned[i], str)){ | |
return FAIL; | |
} | |
} | |
return PASS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment