58 lines
942 B
C
58 lines
942 B
C
#include <stdio.h>
|
|
|
|
// printf Formating
|
|
#define X_RED "\x1B[31m"
|
|
#define X_GREEN "\x1B[32m"
|
|
#define X_RST "\x1B[0m"
|
|
|
|
// INSERT HEADERS FOR FUNCS
|
|
|
|
// SET THE NUMBER OF TESTS
|
|
#define NUM_TESTS 1
|
|
|
|
|
|
// DEFINE TESTS
|
|
|
|
|
|
// DUMMY TEST
|
|
int fail(){
|
|
return -1;
|
|
}
|
|
|
|
// END OF TEST DEFINITIONS
|
|
|
|
void run_tests(int (**tests)()){
|
|
int i = 0;
|
|
int errors = 0;
|
|
|
|
for ( i = 0; i < NUM_TESTS; i++ ){
|
|
printf("Test #%d... ", i);
|
|
if ( tests[i]() == 0){
|
|
printf("%spassed%s\n", X_GREEN, X_RST);
|
|
}
|
|
else {
|
|
printf("%sfailed%s\n", X_RED, X_RST);
|
|
errors++;
|
|
}
|
|
}
|
|
|
|
printf("Tests completed with %s%d passed%s", X_GREEN, NUM_TESTS - errors, X_RST);
|
|
printf(" and %s%d failed%s\n", X_RED, errors, X_RST);
|
|
}
|
|
|
|
int main(){
|
|
int (*tests[NUM_TESTS])();
|
|
|
|
// PASS TESTS INTO ARRAY
|
|
tests[0] = fail;
|
|
|
|
|
|
// END OF PASSING TESTS
|
|
|
|
// RUN TESTS
|
|
run_tests(tests);
|
|
|
|
return 0;
|
|
}
|
|
|