| ... | ... |
@@ -1,14 +1,14 @@ |
| 1 | 1 |
#include <stdio.h> |
| 2 | 2 |
#include "fzy.h" |
| 3 | 3 |
|
| 4 |
-int testsrun = 0, testspassed = 0; |
|
| 4 |
+int testsrun = 0, testsfailed = 0, assertionsrun = 0; |
|
| 5 | 5 |
|
| 6 |
-#define assert(x) if(!(x)){fprintf(stderr, "test \"%s\" failed\n assert(%s) was false\n at %s:%i\n\n", __func__, #x, __FILE__ ,__LINE__);return -1;}
|
|
| 6 |
+#define assert(x) if(++assertionsrun && !(x)){fprintf(stderr, "test \"%s\" failed\n assert(%s) was false\n at %s:%i\n\n", __func__, #x, __FILE__ ,__LINE__);return -1;}
|
|
| 7 | 7 |
|
| 8 | 8 |
void runtest(int (*test)()){
|
| 9 | 9 |
testsrun++; |
| 10 |
- if(!test()) |
|
| 11 |
- testspassed++; |
|
| 10 |
+ if(test()) |
|
| 11 |
+ testsfailed++; |
|
| 12 | 12 |
} |
| 13 | 13 |
|
| 14 | 14 |
int test_match(){
|
| ... | ... |
@@ -63,7 +63,7 @@ int test_positions_2(){
|
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 | 65 |
void summary(){
|
| 66 |
- printf("%i tests run: %i passed %i failed\n", testsrun, testspassed, testsrun - testspassed);
|
|
| 66 |
+ printf("%i tests, %i assertions, %i failures\n", testsrun, assertionsrun, testsfailed);
|
|
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 | 69 |
int main(int argc, char *argv[]){
|
| ... | ... |
@@ -78,5 +78,5 @@ int main(int argc, char *argv[]){
|
| 78 | 78 |
summary(); |
| 79 | 79 |
|
| 80 | 80 |
/* exit 0 if all tests pass */ |
| 81 |
- return testsrun != testspassed; |
|
| 81 |
+ return !!testsfailed; |
|
| 82 | 82 |
} |