• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved.
2 
3 #ifndef GTEST_INCLUDE_GTEST_GTEST_TAG_H_
4 #define GTEST_INCLUDE_GTEST_GTEST_TAG_H_
5 
6 #include <string.h>
7 #include <string>
8 #include <map>
9 #include <vector>
10 
11 namespace testing {
12   namespace ext {
13 
14     using ::std::string;
15     using ::std::map;
16     using ::std::pair;
17     using ::std::vector;
18 
19     enum TestTypeFlag {
20         Function = 1 << 8, Performance = 2 << 8, Power = 3 << 8, Reliability = 4 << 8,
21         Security = 5 << 8, Global = 6 << 8, Compatibility = 7 << 8, User = 8 << 8,
22         Standard = 9 << 8, Safety = 10 << 8, Resilience = 11 << 8
23     };
24 
25     enum TestSizeFlag {
26         SmallTest = 1 << 4, MediumTest = 2 << 4, LargeTest = 3 << 4
27     };
28 
29     enum TestRankFlag {
30         Level0 = 1, Level1 = 2, Level2 = 3, Level3 = 4, Level4 = 5
31     };
32 
33     // base class of tag flag::bitwise integers
34     class TestFlag {
35     public:
36         static const int None = 0;
37 
38     private:
39         const char* const name;
40         const char* const desc;
41         const int mask;
42         map<int, const char*> elementMap;
43         int eleCount;
44     protected:
45         TestFlag(const char*  n, const char* d, int m);
46         void element(const char* desc, int hex);
47     public:
48         bool verify(const int hex, char* err) const;
naming()49         const char* naming() const { return name; }
description()50         const char* description() const { return desc; }
51         bool eleForName(const char* name, int& result) const;
52         void printHelp(const char** indents) const;
53     };
54 
55     // test size scope
56     class  TestSizeSet : public TestFlag {
57     public:
58         TestSizeSet();
59         static const int Level0 = 1  << 24;
60         static const int Level1 = 2  << 24;
61         static const int Level2 = 4  << 24;
62         static const int Level3 = 8  << 24;
63         static const int Level4 = 16 << 24;
64     };
65 
66     extern const TestSizeSet TestSize;
67 
68     // test type scope
69     class  TypeSet : public TestFlag {
70     public:
71         TypeSet();
72         static const int function = Function;
73         static const int performance = Performance;
74         static const int power = Power;
75         static const int reliability = Reliability;
76         static const int security = Security;
77         static const int global = Global;
78         static const int compatibility = Compatibility;
79         static const int user = User;
80         static const int standard = Standard;
81         static const int safety = Safety;
82         static const int resilience = Resilience;
83     };
84 
85     // test size scope
86     class  SizeSet : public TestFlag {
87     public:
88         SizeSet();
89         static const int smallTest = SmallTest;
90         static const int mediumTest = MediumTest;
91         static const int largeTest = LargeTest;
92     };
93 
94     // test rank scope
95     class  RankSet : public TestFlag {
96     public:
97         RankSet();
98         static const int level0 = Level0;
99         static const int level1 = Level1;
100         static const int level2 = Level2;
101         static const int level3 = Level3;
102         static const int level4 = Level4;
103     };
104 
105     // get each instance of all the TestFlag implementions
106     const vector<const TestFlag*>& AllHextTagSets();
107     // verify the test flagset, returns false if the flagset is illegal
108     bool CheckFlagsLegality(int flags);
109     // convert name string to test flag value
110     bool flagForName(const char* set_name, const char* ele_name, int& result);
111 
112   } // namespace ext
113 } // namespace testing
114 
115 #endif  // GTEST_INCLUDE_GTEST_GTEST_TAG_H_
116