-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstd_pair.cpp
More file actions
70 lines (50 loc) · 1.92 KB
/
Copy pathstd_pair.cpp
File metadata and controls
70 lines (50 loc) · 1.92 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
//
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "common.hpp"
template <class IArchive, class OArchive>
void test_pair() {
std::random_device rd;
std::mt19937 gen(rd());
auto rng = [&]() { return random_value<int>(gen); };
for (int ii = 0; ii < 100; ++ii) {
std::pair<int, int> o_podpair = {rng(), rng()};
std::pair<StructInternalSerialize, StructInternalSerialize> o_iserpair = {{rng(), rng()}, {rng(), rng()}};
std::pair<StructInternalSplit, StructInternalSplit> o_isplpair = {{rng(), rng()}, {rng(), rng()}};
std::pair<StructExternalSerialize, StructExternalSerialize> o_eserpair = {{rng(), rng()}, {rng(), rng()}};
std::pair<StructExternalSplit, StructExternalSplit> o_esplpair = {{rng(), rng()}, {rng(), rng()}};
std::ostringstream os; {
OArchive oar(os);
oar(o_podpair);
oar(o_iserpair);
oar(o_isplpair);
oar(o_eserpair);
oar(o_esplpair);
}
std::pair<int, int> i_podpair;
std::pair<StructInternalSerialize, StructInternalSerialize> i_iserpair;
std::pair<StructInternalSplit, StructInternalSplit> i_isplpair;
std::pair<StructExternalSerialize, StructExternalSerialize> i_eserpair;
std::pair<StructExternalSplit, StructExternalSplit> i_esplpair;
std::istringstream is(os.str()); {
IArchive iar(is);
iar(i_podpair);
iar(i_iserpair);
iar(i_isplpair);
iar(i_eserpair);
iar(i_esplpair);
}
CHECK_EQ(i_podpair.first, o_podpair.first);
CHECK_EQ(i_podpair.second, o_podpair.second);
CHECK_EQ(i_iserpair.first, o_iserpair.first);
CHECK_EQ(i_iserpair.second, o_iserpair.second);
CHECK_EQ(i_isplpair.first, o_isplpair.first);
CHECK_EQ(i_isplpair.second, o_isplpair.second);
CHECK_EQ(i_eserpair.first, o_eserpair.first);
CHECK_EQ(i_eserpair.second, o_eserpair.second);
CHECK_EQ(i_esplpair.first, o_esplpair.first);
CHECK_EQ(i_esplpair.second, o_esplpair.second);
}
}
TEST_SUITE_BEGIN("pair");
CREATE_TEST_CASES_FOR_ALL_ARCHIVE("pair", test_pair)
TEST_SUITE_END();