Created
March 9, 2013 18:39
-
-
Save bountin/5125200 to your computer and use it in GitHub Desktop.
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
test: all | |
gcc -std=c99 test.c asma.o -o test | |
./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
#include <stdio.h> | |
#include <assert.h> | |
extern int asma(char *); | |
int asma_ref(char *s) { | |
int c = 0; | |
for (int i=0; i<16; i++) { | |
if (s[i] == ' ') | |
c++; | |
} | |
return c; | |
} | |
int main(int argc, char* argv[]) { | |
char* tests[] = { | |
" ", | |
"aaaaaaaaaaaaaaaa", | |
"ab ab ab ab ab a", | |
"abc abc abc abc ", | |
" ", | |
"aaaaaaaaaaaaaaaaaaaa" | |
}; | |
int i; | |
int elements = sizeof(tests) / sizeof (char*); | |
for (i = 0; i < elements; i++) { | |
printf("%d,", i); | |
assert(asma(tests[i]) == asma_ref(tests[i])); | |
} | |
printf("\n***** EVERTHING OKAY (%d tests succeeded) *****\n\n", i); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment