catch.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 
7 // Catch defines CHECK() and so does EL++, and so we have to undefine it or we get compilation errors!
8 #undef CHECK
9 // Otherwise, don't let it define its own:
10 #define ELPP_NO_CHECK_MACROS
11 
12 // We set our own main by default, so CATCH_CONFIG_MAIN will cause linker errors!
13 #if defined(CATCH_CONFIG_MAIN)
14 #error CATCH_CONFIG_MAIN must not be defined: to run your own main(), use CATCH_CONFIG_RUNNER with #cmake:custom-main
15 #endif
16 
17 #include "catch/catch.hpp"
18 
19 #if defined(CATCH_CONFIG_RUNNER)
20 
21 namespace Catch
22 {
23 
24  // Allow custom test-cases on the fly
25  class CustomRunContext : public RunContext
26  {
27  public:
28  CustomRunContext( CustomRunContext const& ) = delete;
29  CustomRunContext & operator=( CustomRunContext const& ) = delete;
30 
31  // RunContext ctor, but you need to give details...
32  explicit CustomRunContext( IStreamingReporterPtr&& reporter, IConfigPtr const& cfg )
33  : RunContext( cfg, std::move( reporter ))
34  {
35  }
36 
37  // Easy way to instantiate, using the compact reporter by default
38  explicit CustomRunContext( std::string const & reporter_type = "compact", IConfigPtr const & cfg = IConfigPtr( new Config ) )
39  : CustomRunContext( getRegistryHub().getReporterRegistry().create( reporter_type, cfg ), cfg )
40  {
41  }
42 
43  // Easy way to instantiate, using config data first
44  explicit CustomRunContext( Catch::ConfigData const & cfg, std::string const & reporter_type = "compact" )
45  : CustomRunContext( reporter_type, IConfigPtr( new Config( cfg ) ) )
46  {
47  }
48 
49  // Allow changing the redirection for the reporter by force (the compact reporter does
50  // not allow changing via the Config's verbosity)
51  void set_redirection( bool on )
52  {
53  auto r = dynamic_cast<Catch::CompactReporter *>(&reporter());
54  if( r )
55  r->m_reporterPrefs.shouldRedirectStdOut = on;
56  }
57 
58  template< class T >
59  Totals run_test( std::string const & name, T test )
60  {
61  struct invoker : ITestInvoker
62  {
63  T _test;
64  invoker( T t ) : _test( t ) {}
65  void invoke() const override
66  {
67  _test();
68  }
69  };
70  TestCase test_case( new invoker( test ),
71  TestCaseInfo( name, {}, {}, {}, {"",0} )
72  );
73  return runTest( test_case );
74  }
75  };
76 
77 } // namespace Catch
78 
79 #endif // CATCH_CONFIG_RUNNER
GLuint const GLchar * name
Definition: test.cpp:7
Definition: catch.hpp:95
dispatcher invoke([&](dispatcher::cancellable_timer c) { std::this_thread::sleep_for(std::chrono::seconds(3));dispatched_end_verifier=true;})
def run_test(self, configuration=None, log_path=None, opts=set())
Definition: libci.py:268
GLdouble t
std::function< void(std::function< void()>)> invoker
GLdouble GLdouble r
typename ::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
IRegistryHub const & getRegistryHub()
std::shared_ptr< IConfig const > IConfigPtr
Definition: catch.hpp:4344


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:41:42