#include #include "test.h" #include #include #include #define RED "\033[1;91m" #define GREEN "\033[1;92m" #define AQUA "\033[1;36m" #define RESET "\033[;1m" extern std::map tests; void loadTests(); int main(int argc, char** argv) { auto start = std::chrono::high_resolution_clock::now(); loadTests(); int failcount = 0; int testcount = tests.size(); int testnumber = 0; for(std::map::iterator current = tests.begin(); current != tests.end(); ++current) { printf("\033[1mRunning test: %d/%d " AQUA "%s " RESET, ++testnumber, testcount, current->first.c_str()); if((current->second)()) { printf(GREEN "succeeded" RESET "!\n"); } else { printf(RED "failed" RESET "\n"); failcount++; } } const char* color = (failcount > 0 ? RED : GREEN); // red or green printf("%s%d" RESET "/%d failed\n", color, failcount, testcount); auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration t = end - start; printf("Testing took: %fms\n", (t.count() * 1000)); return failcount > 0; }