Grafalgo
Library of useful data structures and algorithms
|
00001 00009 #ifndef UTEST_H 00010 #define UTEST_H 00011 00012 #include "stdinc.h" 00013 00017 class Utest { 00018 public: static bool assertTrue(bool, const char*); 00019 static bool assertEqual(int, int, const char*); 00020 static bool assertEqual(const string&, const string&, const char*); 00021 }; 00022 00023 inline bool Utest::assertTrue(bool condition, const char* s) { 00024 if (!condition) { 00025 cout << s << endl; exit(1); 00026 } 00027 return true; 00028 } 00029 00030 inline bool Utest::assertEqual(int x, int y, const char* s) { 00031 if (x != y) { 00032 cout << s << endl; exit(1); 00033 } 00034 return true; 00035 } 00036 00037 inline bool Utest::assertEqual(const string& p, const string& q, const char* s) { 00038 if (p.compare(q) != 0) { 00039 cout << s << endl; exit(1); 00040 } 00041 return true; 00042 } 00043 00044 #endif