Test.h 960 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef CORE_TEST_H
  2. #define CORE_TEST_H
  3. #include "utils/Logger.h"
  4. namespace Core {
  5. class Test final {
  6. int tests;
  7. int successTests;
  8. const char* name;
  9. public:
  10. Test(const char* name);
  11. void finalize();
  12. template<typename T>
  13. void checkEqual(const T& wanted, const T& actual, const char* text) {
  14. tests++;
  15. if(wanted == actual) {
  16. successTests++;
  17. } else {
  18. (void)text;
  19. CORE_LOG_ERROR("# Test #: # - expected '#' got '#'", name,
  20. tests, text, wanted, actual)
  21. }
  22. }
  23. void checkEqual(float wanted, float actual, const char* text);
  24. void checkFloat(float wanted, float actual, float error,
  25. const char* text);
  26. void checkTrue(bool actual, const char* text);
  27. void checkFalse(bool actual, const char* text);
  28. };
  29. }
  30. #endif