Test.h 783 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef TEST_H
  2. #define TEST_H
  3. #include <iostream>
  4. class Test final {
  5. static constexpr const char* RED = "\033[0;31m";
  6. static constexpr const char* GREEN = "\033[0;32m";
  7. static constexpr const char* RESET = "\033[0m";
  8. int tests;
  9. int successTests;
  10. const char* name;
  11. public:
  12. Test(const char* name);
  13. void finalize();
  14. template<typename T>
  15. void checkEqual(const T& wanted, const T& actual, const char* text) {
  16. if(wanted == actual) {
  17. tests++;
  18. successTests++;
  19. } else {
  20. tests++;
  21. std::cout << RED << name << " Test " << tests << ": " << text << " - " << RESET;
  22. std::cout << RED << "expected '" << wanted << "' got '" << actual << "'\n" << RESET;
  23. }
  24. }
  25. };
  26. #endif