-
Notifications
You must be signed in to change notification settings - Fork 741
/
Copy pathTest.h
174 lines (139 loc) · 4.01 KB
/
Test.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#pragma once
#define TESTMACRO
enum {
MY_ANNOYING_MACRO =
#define MY_ANNOYING_MACRO 1
MY_ANNOYING_MACRO,
};
class Test {
int m_int;
double m_double;
public:
static const char* name();
Test(int foo);
Test(double foo);
static const int COUNTDOWN[];
static const int* COUNTDOWN_PTR;
static const int* countdown();
};
class ITest {
virtual void foo() = 0;
};
class VirtualDestructor {
public:
static unsigned sDestructorCount;
virtual ~VirtualDestructor() = 0;
};
class InheritsFromVirtualDestructor final : public VirtualDestructor {
public:
static unsigned sDestructorCount;
InheritsFromVirtualDestructor();
~InheritsFromVirtualDestructor() final;
};
namespace testing {
typedef Test TypeAlias;
} // namespace testing
typedef testing::TypeAlias TypeAlias;
namespace bitfields {
struct First {
unsigned char three_bits_byte_one : 3;
// This starts a new byte, leaving 5 bits unused.
unsigned char :0;
unsigned char six_bits_byte_two : 6;
unsigned char two_bits_byte_two : 2;
/// Returns true if the bitfields match the arguments, false otherwise.
bool assert(unsigned char first,
unsigned char second,
unsigned char third);
};
struct Second {
int thirty_one_bits : 31;
bool one_bit : 1;
/// Returns true if the bitfields match the arguments, false otherwise.
bool assert(int first,
bool second);
};
enum ItemKind {
ITEM_KIND_UNO = 0,
ITEM_KIND_DOS,
ITEM_KIND_TRES,
};
struct Third {
int flags : 28;
bool is_whatever : 1;
ItemKind kind : 3;
/// Returns true if the bitfields match the arguments, false otherwise.
bool assert(int first, bool second, ItemKind third);
};
enum MyEnum {
ONE = 0,
TWO,
THREE,
FOUR,
};
struct Fourth {
MyEnum tag: 2;
unsigned long ptr: 48;
/// Returns true if the bitfields match the arguments, false otherwise.
bool assert(MyEnum tag, unsigned long ptr);
};
struct Date2 {
unsigned short nWeekDay : 3; // 0..7 (3 bits)
unsigned short nMonthDay : 6; // 0..31 (6 bits)
unsigned short nMonth : 5; // 0..12 (5 bits)
unsigned short nYear : 8; // 0..100 (8 bits)
unsigned char byte : 8;
bool assert(unsigned short nWeekDay,
unsigned short nMonthDay,
unsigned short nMonth,
unsigned short nYear,
unsigned short byte);
};
struct Fifth {
unsigned short nWeekDay : 3; // 0..7 (3 bits)
unsigned short nMonthDay : 6; // 0..31 (6 bits)
unsigned short nMonth : 5; // 0..12 (5 bits)
unsigned short nYear : 8; // 0..100 (8 bits)
unsigned char byte;
/// Returns true if the bitfields match the arguments, false otherwise.
bool assert(unsigned short nWeekDay,
unsigned short nMonthDay,
unsigned short nMonth,
unsigned short nYear,
unsigned char byte);
};
struct Sixth {
unsigned char byte;
unsigned char nWeekDay : 3;
unsigned char nMonth : 5;
unsigned char nMonthDay : 6;
/// Returns true if the bitfields match the arguments, false otherwise.
bool assert(unsigned char byte,
unsigned char nWeekDay,
unsigned char nMonth,
unsigned char nMonthDay);
};
struct Seventh {
bool first_one_bit : 1;
unsigned int second_thirty_bits : 30;
unsigned short third_two_bits : 2;
unsigned int fourth_thirty_bits : 30;
unsigned short fifth_two_bits : 2;
bool sixth_one_bit : 1;
unsigned int seventh_thirty_bits : 30;
/// Returns true if the bitfields match the arguments, false otherwise.
bool assert(bool first,
int second,
unsigned short third,
unsigned int fourth,
unsigned short fifth,
bool sixth,
int seventh);
};
} // namespace bitfields
struct AutoRestoreBool {
bool* m_ptr;
bool m_value;
AutoRestoreBool(bool*);
~AutoRestoreBool();
};