initial commit for tests
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct{
|
||||
char name[50];
|
||||
void (*func)(void);
|
||||
} TestCase;
|
||||
|
||||
|
||||
void run_suite(TestCase tests[], int num_cases){
|
||||
for(int i = 0; i < num_cases; i++){
|
||||
tests[i].func();
|
||||
printf("\r%d \033[0;32m\tPASSED\t%s\e[0m\n",i,tests[i].name);
|
||||
}
|
||||
printf("\033[0;32m ALL %d CASES PASSED\e[0m\n",num_cases);
|
||||
}
|
||||
|
||||
void run_case(TestCase tests[], int num_cases, char name[50]){
|
||||
printf("\rRUNNING INDIVIDUAL TEST \033[0;32m\t\t\e[0m\n");
|
||||
for(int i = 0; i < num_cases; i++){
|
||||
int res = strcmp(tests[i].name, name);
|
||||
if(0 == res)
|
||||
{
|
||||
tests[i].func();
|
||||
printf("\r%d \033[0;32m\tPASSED\t%s\e[0m\n",i,tests[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user