MCPcopy Create free account
hub / github.com/Segs/Segs / test_vector

Function test_vector

3rd_party/cereal/unittests/vector.cpp:31–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29
30template <class IArchive, class OArchive>
31void test_vector()
32{
33 std::random_device rd;
34 std::mt19937 gen(rd());
35
36 for(int ii=0; ii<100; ++ii)
37 {
38 std::vector<int> o_podvector(100);
39 for(auto & elem : o_podvector)
40 elem = random_value<int>(gen);
41
42 std::vector<bool> o_boolvector; o_boolvector.resize(100);
43 for( size_t i = 0; i < 100; ++i )
44 o_boolvector[i] = (random_value<int>(gen) % 2) == 0;
45
46 std::vector<StructInternalSerialize> o_iservector(100);
47 for(auto & elem : o_iservector)
48 elem = StructInternalSerialize( random_value<int>(gen), random_value<int>(gen) );
49
50 std::vector<StructInternalSplit> o_isplvector(100);
51 for(auto & elem : o_isplvector)
52 elem = StructInternalSplit( random_value<int>(gen), random_value<int>(gen) );
53
54 std::vector<StructExternalSerialize> o_eservector(100);
55 for(auto & elem : o_eservector)
56 elem = StructExternalSerialize( random_value<int>(gen), random_value<int>(gen) );
57
58 std::vector<StructExternalSplit> o_esplvector(100);
59 for(auto & elem : o_esplvector)
60 elem = StructExternalSplit( random_value<int>(gen), random_value<int>(gen) );
61
62 std::ostringstream os;
63 {
64 OArchive oar(os);
65
66 oar(o_podvector);
67 oar(o_boolvector);
68 oar(o_iservector);
69 oar(o_isplvector);
70 oar(o_eservector);
71 oar(o_esplvector);
72 }
73
74 std::vector<int> i_podvector;
75 std::vector<bool> i_boolvector;
76 std::vector<StructInternalSerialize> i_iservector;
77 std::vector<StructInternalSplit> i_isplvector;
78 std::vector<StructExternalSerialize> i_eservector;
79 std::vector<StructExternalSplit> i_esplvector;
80
81 std::istringstream is(os.str());
82 {
83 IArchive iar(is);
84
85 iar(i_podvector);
86 iar(i_boolvector);
87 iar(i_iservector);
88 iar(i_isplvector);

Callers

nothing calls this directly

Calls 8

StructInternalSplitClass · 0.85
StructExternalSplitClass · 0.85
resizeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected