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