1 #include "Test.h"
2
3 const int Test::COUNTDOWN[] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
4 const int* Test::COUNTDOWN_PTR = Test::COUNTDOWN;
5
6 unsigned VirtualDestructor::sDestructorCount = 0;
~VirtualDestructor()7 VirtualDestructor::~VirtualDestructor() {
8 sDestructorCount++;
9 }
10
11 unsigned InheritsFromVirtualDestructor::sDestructorCount = 0;
12 InheritsFromVirtualDestructor::InheritsFromVirtualDestructor() = default;
13
~InheritsFromVirtualDestructor()14 InheritsFromVirtualDestructor::~InheritsFromVirtualDestructor() {
15 sDestructorCount++;
16 }
17
countdown()18 const int* Test::countdown() {
19 return COUNTDOWN;
20 }
21
name()22 const char* Test::name() {
23 return "Test";
24 }
25
Test(int foo)26 Test::Test(int foo)
27 : m_int(foo)
28 , m_double(0.0)
29 {}
30
Test(double foo)31 Test::Test(double foo)
32 : m_int(0)
33 , m_double(foo)
34 {}
35
AutoRestoreBool(bool * ptr)36 AutoRestoreBool::AutoRestoreBool(bool* ptr)
37 : m_ptr(ptr)
38 , m_value(*ptr)
39 {}
40
~AutoRestoreBool()41 AutoRestoreBool::~AutoRestoreBool() {
42 *m_ptr = m_value;
43 }
44
45 namespace bitfields {
46
47 bool
assert(unsigned char first,unsigned char second,unsigned char third)48 First::assert(unsigned char first,
49 unsigned char second,
50 unsigned char third)
51 {
52 return three_bits_byte_one == first &&
53 six_bits_byte_two == second &&
54 two_bits_byte_two == third;
55 }
56
57 bool
assert(int first,bool second)58 Second::assert(int first, bool second)
59 {
60 return thirty_one_bits == first && one_bit == second;
61 }
62
63 bool
assert(int first,bool second,ItemKind third)64 Third::assert(int first, bool second, ItemKind third)
65 {
66 return flags == first &&
67 is_whatever == second &&
68 kind == third;
69 }
70
71 bool
assert(MyEnum tag,unsigned long ptr)72 Fourth::assert(MyEnum tag, unsigned long ptr)
73 {
74 return this->tag == tag && this->ptr == ptr;
75 }
76
77 bool
assert(unsigned short nWeekDay,unsigned short nMonthDay,unsigned short nMonth,unsigned short nYear,unsigned short byte)78 Date2::assert(unsigned short nWeekDay,
79 unsigned short nMonthDay,
80 unsigned short nMonth,
81 unsigned short nYear,
82 unsigned short byte)
83 {
84 return this->nWeekDay == nWeekDay &&
85 this->nMonthDay == nMonthDay &&
86 this->nMonth == nMonth &&
87 this->nYear == nYear &&
88 this->byte == byte;
89 }
90
91 bool
assert(unsigned short nWeekDay,unsigned short nMonthDay,unsigned short nMonth,unsigned short nYear,unsigned char byte)92 Fifth::assert(unsigned short nWeekDay,
93 unsigned short nMonthDay,
94 unsigned short nMonth,
95 unsigned short nYear,
96 unsigned char byte)
97 {
98 return this->nWeekDay == nWeekDay &&
99 this->nMonthDay == nMonthDay &&
100 this->nMonth == nMonth &&
101 this->nYear == nYear &&
102 this->byte == byte;
103 }
104
105 bool
assert(unsigned char byte,unsigned char nWeekDay,unsigned char nMonth,unsigned char nMonthDay)106 Sixth::assert(unsigned char byte,
107 unsigned char nWeekDay,
108 unsigned char nMonth,
109 unsigned char nMonthDay) {
110 return this->nWeekDay == nWeekDay &&
111 this->nMonthDay == nMonthDay &&
112 this->nMonth == nMonth &&
113 this->byte == byte;
114 };
115
116 bool
assert(bool first,int second,unsigned short third,unsigned int fourth,unsigned short fifth,bool sixth,int seventh)117 Seventh::assert(bool first,
118 int second,
119 unsigned short third,
120 unsigned int fourth,
121 unsigned short fifth,
122 bool sixth,
123 int seventh) {
124 return this->first_one_bit == first &&
125 this->second_thirty_bits == second &&
126 this->third_two_bits == third &&
127 this->fourth_thirty_bits == fourth &&
128 this->fifth_two_bits == fifth &&
129 this->sixth_one_bit == sixth &&
130 this->seventh_thirty_bits == seventh;
131 };
132
133 } // namespace bitfields
134
my_prefixed_function_name()135 int my_prefixed_function_name() {
136 return 4;
137 }
138
coord(double x,double y,double z,double t)139 Coord coord(double x, double y, double z, double t) {
140 Coord res;
141 res.v[0] = x;
142 res.v[1] = y;
143 res.v[2] = z;
144 res.v[3] = t;
145 return res;
146 }
147