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 #include "catch/catch.hpp"
13 
14 
15 #if defined(CATCH_CONFIG_RUNNER)
16 
17 namespace Catch
18 {
19 
20  // Allow custom test-cases on the fly
21  class CustomRunContext : public RunContext
22  {
23  public:
24  CustomRunContext( CustomRunContext const& ) = delete;
25  CustomRunContext & operator=( CustomRunContext const& ) = delete;
26 
27  // RunContext ctor, but you need to give details...
28  explicit CustomRunContext( IStreamingReporterPtr&& reporter, IConfigPtr const& cfg )
29  : RunContext( cfg, std::move( reporter ))
30  {
31  }
32 
33  // Easy way to instantiate, using the compact reporter by default
34  explicit CustomRunContext( std::string const & reporter_type = "compact", IConfigPtr const & cfg = IConfigPtr( new Config ) )
35  : CustomRunContext( getRegistryHub().getReporterRegistry().create( reporter_type, cfg ), cfg )
36  {
37  }
38 
39  // Easy way to instantiate, using config data first
40  explicit CustomRunContext( Catch::ConfigData const & cfg, std::string const & reporter_type = "compact" )
41  : CustomRunContext( reporter_type, IConfigPtr( new Config( cfg ) ) )
42  {
43  }
44 
45  // Allow changing the redirection for the reporter by force (the compact reporter does
46  // not allow changing via the Config's verbosity)
47  void set_redirection( bool on )
48  {
49  auto r = dynamic_cast<Catch::CompactReporter *>(&reporter());
50  if( r )
51  r->m_reporterPrefs.shouldRedirectStdOut = on;
52  }
53 
54  template< class T >
55  Totals run_test( std::string const & name, T test )
56  {
57  struct invoker : ITestInvoker
58  {
59  T _test;
60  invoker( T t ) : _test( t ) {}
61  void invoke() const override
62  {
63  _test();
64  }
65  };
66  TestCase test_case( new invoker( test ),
67  TestCaseInfo( name, {}, {}, {}, {"",0} )
68  );
69  return runTest( test_case );
70  }
71  };
72 
73 } // namespace Catch
74 
75 #endif // CATCH_CONFIG_RUNNER
def run_test(self, configuration=None, log_path=None)
GLuint const GLchar * name
Definition: catch.hpp:95
GLsizei const GLchar *const * string
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): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:45:07