Skip to content

Instantly share code, notes, and snippets.

@bountin
Created March 9, 2013 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bountin/5125200 to your computer and use it in GitHub Desktop.
Save bountin/5125200 to your computer and use it in GitHub Desktop.
test: all
gcc -std=c99 test.c asma.o -o test
./test
#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