Test.cpp 936 B

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