catch_test_registry.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Created by Martin on 25/07/2017.
  3. *
  4. * Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #include "catch_test_registry.h"
  8. #include "catch_compiler_capabilities.h"
  9. #include "catch_test_case_registry_impl.h"
  10. #include "catch_interfaces_registry_hub.h"
  11. namespace Catch {
  12. auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker* {
  13. return new(std::nothrow) TestInvokerAsFunction( testAsFunction );
  14. }
  15. NameAndTags::NameAndTags( StringRef const& name_ , StringRef const& tags_ ) noexcept : name( name_ ), tags( tags_ ) {}
  16. AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept {
  17. CATCH_TRY {
  18. getMutableRegistryHub()
  19. .registerTest(
  20. makeTestCase(
  21. invoker,
  22. extractClassName( classOrMethod ),
  23. nameAndTags,
  24. lineInfo));
  25. } CATCH_CATCH_ALL {
  26. // Do not throw when constructing global objects, instead register the exception to be processed later
  27. getMutableRegistryHub().registerStartupException();
  28. }
  29. }
  30. AutoReg::~AutoReg() = default;
  31. }