-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathlibcpp_test.hpp
More file actions
400 lines (331 loc) · 10.2 KB
/
libcpp_test.hpp
File metadata and controls
400 lines (331 loc) · 10.2 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
#include <vector>
#include <string>
#include <utility>
#include <map>
#include <memory>
enum EEE {
A, B
};
class Int {
public:
int i_;
Int(int i): i_(i) { };
Int(const Int & i): i_(i.i_) { };
};
class AbstractBaseClass {
protected:
AbstractBaseClass(int i): i_(i) {};
public:
int i_;
virtual ~AbstractBaseClass() {};
virtual int get() = 0;
};
class ABS_Impl1 : public AbstractBaseClass {
public:
~ABS_Impl1() {}
ABS_Impl1(int i) : AbstractBaseClass(i) {}
int get() {return i_;}
};
class ABS_Impl2 : public AbstractBaseClass {
public:
~ABS_Impl2() {}
ABS_Impl2(int i) : AbstractBaseClass(i) {}
int get() {return i_;}
};
class LibCppTest {
private:
int i;
public:
LibCppTest():
i(0),
integer_ptr(0),
integer_vector_ptr(0)
{};
LibCppTest(int ii):
i(ii),
integer_ptr(0),
integer_vector_ptr(0)
{}
LibCppTest(const LibCppTest &o):
i(o.i),
integer_ptr(0),
integer_vector_ptr(0)
{}
enum class MyEnum : int
{
A,B,C
};
enum class MyEnum2 : int
{
A,B,C
};
int enumToInt(MyEnum e)
{
switch(e)
{
case MyEnum::A : return 1;
case MyEnum::B : return 2;
case MyEnum::C : return 3;
}
}
Int * integer_ptr;
std::vector<Int> * integer_vector_ptr;
bool operator<(const LibCppTest & other) const
{
return this->i < other.i;
}
bool operator==(const LibCppTest & other) const
{
return this->i == other.i;
}
bool operator!=(const LibCppTest & other) const
{
return !operator==(other);
}
int get() { return i; }
std::pair<int, std::string> twist(std::pair<std::string, int> in)
{
return std::pair<int, std::string>(in.second, in.first);
};
std::vector<int> process(std::vector<int> & in)
{
in.push_back(42);
return in;
};
std::pair<int, int> process2(std::pair<int, int> & in)
{
in.first = 42;
in.second = 11;
return in;
};
std::pair<LibCppTest, int> process3(std::pair<LibCppTest, int> & in)
{
in.second = 42;
return std::pair<LibCppTest, int>(in.first, in.second);
};
std::pair<int, LibCppTest> process4(std::pair<int, LibCppTest> & in)
{
in.first = 42;
return std::pair<int, LibCppTest>(in.first, in.second);
};
std::pair<LibCppTest, LibCppTest> process5(std::pair<LibCppTest, LibCppTest> & in)
{
in.first = 43;
return std::pair<LibCppTest, LibCppTest>(in.second, in.first);
};
std::vector<std::pair<int, double> > process6(std::vector<std::pair<int, double> >& in) {
in.push_back(std::pair<int,double>(7, 11.0));
return std::vector<std::pair<int, double> > (in.rbegin(), in.rend());
}
std::pair<int, EEE> process7(std::pair<EEE, int> & in ) {
return std::pair<int, EEE>(in.second, in.first);
}
std::vector<EEE> process8(std::vector<EEE> & in ) {
return std::vector<EEE>(in.rbegin(), in.rend());
}
std::set<int> process9(std::set<int> & in ) {
in.insert(42);
return in;
}
std::set<EEE> process10(std::set<EEE> & in ) {
in.insert(A);
return in;
}
std::set<LibCppTest> process11(std::set<LibCppTest> & in ) {
LibCppTest n(42);
in.insert(n);
return in;
}
std::map<int,float> process12(int i, float f)
{
std::map<int,float> map;
map[i] = f;
return map;
}
std::map<EEE, int> process13(EEE e, int i)
{
std::map<EEE,int> map;
map[e] = i;
return map;
}
std::map<int, EEE> process14(EEE e, int i)
{
std::map<int, EEE> map;
map[i] = e;
return map;
}
std::map<long int, LibCppTest> process15(int i)
{
std::map<long int, LibCppTest> map;
map[i] = LibCppTest(i);
return map;
}
float process16(std::map<int, float> in)
{
return in[42];
}
float process17(std::map<EEE, float> in)
{
return in[A];
}
int process18(std::map<int, LibCppTest> in)
{
return in[23].get();
}
void process19(std::map<int, LibCppTest> & in)
{
LibCppTest v(12);
in[23] = v;
}
void process20(std::map<int, float> & in)
{
in[23] = 42.0;
}
void process21(std::map<int, float> & in, std::map<int,int> & arg2)
{
in[1] = (float) arg2[42];
}
void process211(std::map<int, float> & in, std::map<std::string, std::vector<int> > & arg2)
{
std::string test_str("42");
in[1] = (float) arg2[test_str][0];
}
void process212(std::map<int, float> & in, std::map<std::string, std::vector< std::vector<int> > > & arg2)
{
std::string test_str("42");
in[1] = (float) arg2[test_str][0][0];
}
void process213(std::map<int, float> & in, std::map<std::string, std::vector< std::vector<Int> > > & arg2)
{
std::string test_str("42");
in[1] = (float) arg2[test_str][0][0].i_;
}
void process214(std::map<int, float> & in, std::map<std::string, std::vector< std::pair<int, int> > > & arg2)
{
std::string test_str("42");
in[1] = (float) arg2[test_str][0].first;
}
void process22(std::set<int> & in, std::set<float> & arg2)
{
std::set<int>::iterator it = in.begin();
int x = *it;
in.erase(it);
arg2.insert((float)x);
}
void process23(std::vector<int> & in, std::vector<float> & arg2)
{
int x = *(in.rbegin());
in.pop_back();
arg2.push_back((float)x);
}
void process24(std::pair<int, float> & in, std::pair<int,int> & arg2)
{
in.first = arg2.second;
in.second = (float) arg2.first;
}
int process25(std::vector<Int> in)
{
int sum = 0;
for (std::vector<Int>::const_iterator i = in.begin(); i != in.end(); ++i)
sum += i->i_;
return sum;
}
int process26(std::vector<std::vector<Int> > in)
{
int sum = 0;
for (std::vector<std::vector<Int> >::const_iterator i = in.begin(); i != in.end(); ++i)
sum += process25(*i);
return sum;
}
int process27(std::vector<std::vector<std::vector<Int> > > in)
{
int sum = 0;
for (std::vector<std::vector<std::vector<Int> > >::const_iterator i = in.begin(); i != in.end(); ++i)
sum += process26(*i);
return sum;
}
int process28(std::vector<std::vector<std::vector<std::vector<Int> > > > in)
{
int sum = 0;
for (std::vector<std::vector<std::vector<std::vector<Int> > > >::const_iterator i = in.begin(); i != in.end(); ++i)
sum += process27(*i);
return sum;
}
void process29(std::vector<std::vector<Int> > & in)
{
for (std::vector<std::vector<Int> >::iterator i = in.begin(); i != in.end(); ++i)
{
i->push_back(42);
}
}
void process30(std::vector<std::vector<std::vector<std::vector<Int> > > > & in)
{
for (std::vector<std::vector<std::vector<std::vector<Int> > > >::iterator i = in.begin(); i != in.end(); ++i)
{
std::vector<std::vector<Int> > newvec;
std::vector<Int> newvec_inner;
Int int_obj = Int(42);
newvec_inner.push_back(int_obj);
newvec.push_back(newvec_inner);
i->push_back(newvec);
}
}
int process31(const std::vector<int> & in)
{
int sum = 0;
for (std::vector<int>::const_iterator i = in.begin(); i != in.end(); ++i)
sum += *i;
return sum;
}
int process32(const std::vector<std::vector<int> > & in)
{
int sum = 0;
for (std::vector<std::vector<int> >::const_iterator i = in.begin(); i != in.end(); ++i)
sum += process31(*i);
return sum;
}
int process33(std::shared_ptr<Int> in)
{
in->i_++;
return in->i_;
}
std::shared_ptr<Int> process34(std::shared_ptr<Int> in)
{
in->i_++;
return in;
}
std::shared_ptr<const Int> process35(std::shared_ptr<Int> in)
{
in->i_++;
return std::static_pointer_cast<const Int>(in);
}
int process36(Int* in)
{
in->i_++;
return in->i_;
}
Int* process37(Int* in)
{
if (in->i_ == 18) return NULL;
in->i_++;
return in;
}
std::vector<std::vector<unsigned int> > process38(int x)
{
std::vector<std::vector<unsigned int> > res;
std::vector<unsigned int> res_inner;
res_inner.push_back(x);
res.push_back(res_inner);
res.push_back(res_inner);
return res;
}
const Int* process39(Int* in)
{
in->i_++;
return in;
}
int process40(AbstractBaseClass* in)
{
return in->get();
}
};