Test.cpp 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #include "test/Test.h"
  2. Core::HashMap<Core::Test::Internal::FileName, Core::Test::Internal::Result>
  3. Core::Test::Internal::results;
  4. void Core::Test::Internal::warn(const char* file, int line, Error e) {
  5. CORE_LOG_WARNING("#:# | ", Core::getFileName(file), line, e);
  6. }
  7. bool Core::Test::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. using namespace Internal;
  15. for(const auto& e : results) {
  16. if(e.value.successTests == e.value.tests) {
  17. CORE_LOG_DEBUG("# - # / # tests succeeded", e.getKey(),
  18. e.value.successTests, e.value.tests);
  19. } else {
  20. CORE_LOG_ERROR("# - # / # tests succeeded", e.getKey(),
  21. e.value.successTests, e.value.tests);
  22. }
  23. }
  24. results.clear();
  25. }