-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstd_array.cpp
More file actions
79 lines (59 loc) · 2.02 KB
/
Copy pathstd_array.cpp
File metadata and controls
79 lines (59 loc) · 2.02 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
//
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "common.hpp"
template <typename IArchive, typename OArchive, size_t N>
void aux_test_array() {
std::random_device rd;
std::mt19937 gen(rd());
for (size_t ii = 0; ii < N; ++ii) {
std::array<int, N> o_podarray;
for (auto& elem : o_podarray)
elem = random_value<int>(gen);
std::array<StructInternalSerialize, N> o_iserarray;
for (auto& elem : o_iserarray)
elem = StructInternalSerialize(random_value<int>(gen), random_value<int>(gen));
std::array<StructInternalSplit, N> o_isplarray;
for (auto& elem : o_isplarray)
elem = StructInternalSplit(random_value<int>(gen), random_value<int>(gen));
std::array<StructExternalSerialize, N> o_eserarray;
for (auto& elem : o_eserarray)
elem = StructExternalSerialize(random_value<int>(gen), random_value<int>(gen));
std::array<StructExternalSplit, N> o_esplarray;
for (auto& elem : o_esplarray)
elem = StructExternalSplit(random_value<int>(gen), random_value<int>(gen));
std::ostringstream os; {
OArchive oar(os);
oar(o_podarray);
oar(o_iserarray);
oar(o_isplarray);
oar(o_eserarray);
oar(o_esplarray);
}
std::array<int, N> i_podarray;
std::array<StructInternalSerialize, N> i_iserarray;
std::array<StructInternalSplit, N> i_isplarray;
std::array<StructExternalSerialize, N> i_eserarray;
std::array<StructExternalSplit, N> i_esplarray;
std::istringstream is(os.str()); {
IArchive iar(is);
iar(i_podarray);
iar(i_iserarray);
iar(i_isplarray);
iar(i_eserarray);
iar(i_esplarray);
}
check_collection(i_podarray, o_podarray);
check_collection(i_iserarray, o_iserarray);
check_collection(i_isplarray, o_isplarray);
check_collection(i_eserarray, o_eserarray);
check_collection(i_esplarray, o_esplarray);
}
}
template <typename IArchive, typename OArchive>
void test_array() {
aux_test_array<IArchive, OArchive, 0>();
aux_test_array<IArchive, OArchive, 100>();
}
TEST_SUITE_BEGIN("array");
CREATE_TEST_CASES_FOR_ALL_ARCHIVE("array", test_array)
TEST_SUITE_END();