Test.h 868 B

12345678910111213141516171819202122232425262728293031323334
  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. void checkFloat(float wanted, float actual, float error, const char* text);
  26. };
  27. #endif