• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Created by Phil on 7/1/2011
3  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
4  *
5  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
6  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  */
8 #ifndef TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
9 #define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
10 
11 #include "catch_test_registry.h"
12 #include "catch_test_spec.h"
13 #include "catch_interfaces_config.h"
14 
15 #include <vector>
16 #include <set>
17 #include <algorithm>
18 #include <ios>
19 
20 namespace Catch {
21 
22     class TestCase;
23     struct IConfig;
24 
25     std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases );
26 
27     bool isThrowSafe( TestCase const& testCase, IConfig const& config );
28     bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
29 
30     void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions );
31 
32     std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
33     std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
34 
35     class TestRegistry : public ITestCaseRegistry {
36     public:
37         virtual ~TestRegistry() = default;
38 
39         virtual void registerTest( TestCase const& testCase );
40 
41         std::vector<TestCase> const& getAllTests() const override;
42         std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const override;
43 
44     private:
45         std::vector<TestCase> m_functions;
46         mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder;
47         mutable std::vector<TestCase> m_sortedFunctions;
48         std::size_t m_unnamedCount = 0;
49         std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
50     };
51 
52     ///////////////////////////////////////////////////////////////////////////
53 
54     class TestInvokerAsFunction : public ITestInvoker {
55         void(*m_testAsFunction)();
56     public:
57         TestInvokerAsFunction( void(*testAsFunction)() ) noexcept;
58 
59         void invoke() const override;
60     };
61 
62 
63     std::string extractClassName( StringRef const& classOrQualifiedMethodName );
64 
65     ///////////////////////////////////////////////////////////////////////////
66 
67 
68 } // end namespace Catch
69 
70 
71 #endif // TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
72