run_test.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2010-2024 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx/blob/master/LICENSE
  4. */
  5. #define CATCH_CONFIG_RUNNER
  6. #include "test.h"
  7. #include <bx/string.h>
  8. bool testAssertHandler(const bx::Location& _location, const char* _format, va_list _argList)
  9. {
  10. bx::printf("%s(%d): ", _location.filePath, _location.line);
  11. bx::vprintf(_format, _argList);
  12. bx::printf("\n");
  13. // Throwing exceptions is required for testing asserts being trigged.
  14. // Use REQUIRE_ASSERTS to test asserts.
  15. throw std::exception();
  16. return true;
  17. }
  18. int runAllTests(int _argc, const char* _argv[])
  19. {
  20. bx::setAssertHandler(testAssertHandler);
  21. DBG("Compiler: " BX_COMPILER_NAME
  22. ", CPU: " BX_CPU_NAME
  23. ", Arch: " BX_ARCH_NAME
  24. ", OS: " BX_PLATFORM_NAME
  25. ", CRT: " BX_CRT_NAME
  26. ", C++: " BX_CPP_NAME
  27. ", Date: " __DATE__
  28. ", Time: " __TIME__
  29. );
  30. using namespace Catch;
  31. Session session;
  32. ConfigData config;
  33. config.defaultColourMode = BX_PLATFORM_EMSCRIPTEN ? ColourMode::None : ColourMode::PlatformDefault;
  34. session.useConfigData(config);
  35. return session.run(_argc, _argv);
  36. }