Test.cpp 968 B

12345678910111213141516171819202122232425262728
  1. #include "Test.hpp"
  2. namespace Internal = Core::Test::Internal;
  3. namespace Logger = Core::Logger;
  4. Core::HashMap<Internal::FileName, Internal::Result> Internal::results;
  5. void Internal::warn(const char* file, int line, Error e) {
  6. Logger::log("#:# | #", Logger::getFileName(file), line, e);
  7. }
  8. bool Internal::checkFloat(const char* file, int line, float wanted,
  9. float actual, float error) {
  10. float diff = wanted - actual;
  11. diff = diff < 0.0f ? -diff : diff;
  12. return check(file, line, wanted, actual, diff <= error);
  13. }
  14. void Core::Test::finalize() {
  15. for(const auto& e : Internal::results) {
  16. const char* color = e.value.successTests == e.value.tests
  17. ? Logger::COLOR_GREEN
  18. : Logger::COLOR_RED;
  19. Logger::log(color, "# - # / # tests succeeded", e.getKey(),
  20. e.value.successTests, e.value.tests);
  21. }
  22. Internal::results.clear();
  23. }