1 /*
2  *  Created by Phil on 29/10/2010.
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_INFO_H_INCLUDED
9 #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
10 
11 #include "catch_common.h"
12 #include "catch_ptr.hpp"
13 
14 #include <string>
15 #include <set>
16 
17 #ifdef __clang__
18 #pragma clang diagnostic push
19 #pragma clang diagnostic ignored "-Wpadded"
20 #endif
21 
22 namespace Catch {
23 
24     struct ITestCase;
25 
26     struct TestCaseInfo {
27         enum SpecialProperties{
28             None = 0,
29             IsHidden = 1 << 1,
30             ShouldFail = 1 << 2,
31             MayFail = 1 << 3,
32             Throws = 1 << 4,
33             NonPortable = 1 << 5
34         };
35 
36         TestCaseInfo(   std::string const& _name,
37                         std::string const& _className,
38                         std::string const& _description,
39                         std::set<std::string> const& _tags,
40                         SourceLineInfo const& _lineInfo );
41 
42         TestCaseInfo( TestCaseInfo const& other );
43 
44         friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
45 
46         bool isHidden() const;
47         bool throws() const;
48         bool okToFail() const;
49         bool expectedToFail() const;
50 
51         std::string name;
52         std::string className;
53         std::string description;
54         std::set<std::string> tags;
55         std::set<std::string> lcaseTags;
56         std::string tagsAsString;
57         SourceLineInfo lineInfo;
58         SpecialProperties properties;
59     };
60 
61     class TestCase : public TestCaseInfo {
62     public:
63 
64         TestCase( ITestCase* testCase, TestCaseInfo const& info );
65         TestCase( TestCase const& other );
66 
67         TestCase withName( std::string const& _newName ) const;
68 
69         void invoke() const;
70 
71         TestCaseInfo const& getTestCaseInfo() const;
72 
73         void swap( TestCase& other );
74         bool operator == ( TestCase const& other ) const;
75         bool operator < ( TestCase const& other ) const;
76         TestCase& operator = ( TestCase const& other );
77 
78     private:
79         Ptr<ITestCase> test;
80     };
81 
82     TestCase makeTestCase(  ITestCase* testCase,
83                             std::string const& className,
84                             std::string const& name,
85                             std::string const& description,
86                             SourceLineInfo const& lineInfo );
87 }
88 
89 #ifdef __clang__
90 #pragma clang diagnostic pop
91 #endif
92 
93 #endif // TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
94