/** * @author: Pat Hawks * Created on: Feb 26, 2015 * Source File: Test.cpp */ #include #include #include using namespace std; #ifdef _WIN32 #include HANDLE hConsole; hConsole = GetStdHandle(STD_OUTPUT_HANDLE); #define PASS_COLOR() SetConsoleTextAttribute(hConsole, 10); #define FAIL_COLOR() SetConsoleTextAttribute(hConsole, 12); #define DFLT_COLOR() SetConsoleTextAttribute(hConsole, 7); #else #define PASS_COLOR() cout << "\033[1;32m"; #define FAIL_COLOR() cout << "\033[1;91m"; #define DFLT_COLOR() cout << "\033[0m"; #endif bool test( string message, const bool condition, const bool showPass=true ) { if (showPass || !condition) { message.resize(70, ' '); cout << message << "["; if (condition) { PASS_COLOR(); cout << " ok "; } else { FAIL_COLOR(); cout << " FAIL "; } DFLT_COLOR(); cout << "]" << endl; } return condition; } int main( void ) { test("This test is true", true); test("This test will fail", false); return 0; }