18TEST(_GTestCbmDigiTimeslice, CheckSerialization)
22 int32_t maxUnit = (1 << 6) - 1;
23 int32_t maxLadd = (1 << 5) - 1;
24 int32_t maxHlad = (1 << 1) - 1;
25 int32_t maxModu = (1 << 5) - 1;
26 uint16_t maxChan = (1 << 11) - 1;
27 int32_t maxTime = (1 << 30) - 1;
28 uint16_t maxChrg = (1 << 5) - 1;
31 std::random_device rd;
32 std::mt19937 gen(rd());
33 std::uniform_int_distribution<uint64_t> rTsIndex(0);
34 std::uniform_int_distribution<uint64_t> rTsPos(0);
35 std::uniform_int_distribution<uint32_t> rTsNumMs(0);
36 std::uniform_int_distribution<uint32_t> rTsNumCp(0);
37 std::uniform_int_distribution<int32_t> rNumDigis(1, 10);
38 std::uniform_int_distribution<int32_t> rUnit(0, maxUnit);
39 std::uniform_int_distribution<int32_t> rLadd(0, maxLadd);
40 std::uniform_int_distribution<int32_t> rHlad(0, maxHlad);
41 std::uniform_int_distribution<int32_t> rModu(0, maxModu);
42 std::uniform_int_distribution<uint16_t> rChan(0, maxChan);
43 std::uniform_int_distribution<int32_t> rTime(0, maxTime);
44 std::uniform_int_distribution<uint16_t> rChrg(0, maxChrg);
48 uint64_t tsIndex = rTsIndex(gen);
49 uint64_t tsPos = rTsPos(gen);
50 uint32_t tsNumMs = rTsNumMs(gen);
51 uint32_t tsNumCp = rTsNumCp(gen);
52 tsWrite.
fDesc.index = tsIndex;
53 tsWrite.
fDesc.ts_pos = tsPos;
54 tsWrite.
fDesc.num_core_microslices = tsNumMs;
55 tsWrite.
fDesc.num_components = tsNumCp;
58 int32_t numDigis = rNumDigis(gen);
60 std::vector<int32_t> vAddr(numDigis);
61 std::vector<uint16_t> vChan(numDigis);
62 std::vector<int32_t> vTime(numDigis);
63 std::vector<uint16_t> vChrg(numDigis);
64 for (int32_t iDigi = 0; iDigi < numDigis; iDigi++) {
65 int32_t unit = rUnit(gen);
66 int32_t ladd = rLadd(gen);
67 int32_t hlad = rHlad(gen);
68 int32_t modu = rModu(gen);
70 uint16_t chan = rChan(gen);
71 int32_t time = rTime(gen);
72 uint16_t chrg = rChrg(gen);
82 boost::archive::binary_oarchive outArchive(s);
83 outArchive << tsWrite;
87 boost::archive::binary_iarchive inArchive(s);
91 EXPECT_EQ(tsRead.
fDesc.index, tsIndex);
92 EXPECT_EQ(tsRead.
fDesc.ts_pos, tsPos);
93 EXPECT_EQ(tsRead.
fDesc.num_core_microslices, tsNumMs);
94 EXPECT_EQ(tsRead.
fDesc.num_components, tsNumCp);
95 for (int32_t iDigi = 0; iDigi < numDigis; iDigi++) {