Test.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. String name;
  9. public:
  10. Test(const String& 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. LOG_ERROR("# Test #: # - expected '#' got '#'", name, tests,
  20. 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. void checkUnsigned8(u8 wanted, u8 actual, const char* text);
  29. void checkUnsigned16(u16 wanted, u16 actual, const char* text);
  30. void checkSigned8(i8 wanted, i8 actual, const char* text);
  31. void checkSigned16(i16 wanted, i16 actual, const char* text);
  32. };
  33. }
  34. #endif