Skip to content

Commit 72b9f51

Browse files
authored
DPL: improve test (AliceO2Group#14847)
1 parent 159cf6a commit 72b9f51

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Framework/Core/test/test_MessageSet.cxx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,43 @@ TEST_CASE("MessageSetAddPartRef") {
9393
REQUIRE(msgSet.pairMap[0].partIndex == 0);
9494
REQUIRE(msgSet.pairMap[0].payloadIndex == 0);
9595
}
96+
97+
TEST_CASE("MessageSetAddMultiple")
98+
{
99+
std::vector<fair::mq::MessagePtr> ptrs;
100+
std::unique_ptr<fair::mq::Message> msg(nullptr);
101+
std::unique_ptr<fair::mq::Message> msg2(nullptr);
102+
ptrs.emplace_back(std::move(msg));
103+
ptrs.emplace_back(std::move(msg2));
104+
PartRef ref{std::move(msg), std::move(msg2)};
105+
o2::framework::MessageSet msgSet;
106+
msgSet.add(std::move(ref));
107+
PartRef ref2{std::move(msg), std::move(msg2)};
108+
msgSet.add(std::move(ref2));
109+
std::vector<fair::mq::MessagePtr> msgs;
110+
msgs.push_back(std::unique_ptr<fair::mq::Message>(nullptr));
111+
msgs.push_back(std::unique_ptr<fair::mq::Message>(nullptr));
112+
msgs.push_back(std::unique_ptr<fair::mq::Message>(nullptr));
113+
msgSet.add([&msgs](size_t i) {
114+
return std::move(msgs[i]);
115+
}, 3);
116+
117+
REQUIRE(msgSet.messages.size() == 7);
118+
REQUIRE(msgSet.messageMap.size() == 3);
119+
REQUIRE(msgSet.pairMap.size() == 4);
120+
REQUIRE(msgSet.messageMap[0].position == 0);
121+
REQUIRE(msgSet.messageMap[0].size == 1);
122+
REQUIRE(msgSet.messageMap[1].position == 2);
123+
REQUIRE(msgSet.messageMap[1].size == 1);
124+
REQUIRE(msgSet.messageMap[2].position == 4);
125+
REQUIRE(msgSet.messageMap[2].size == 2);
126+
127+
REQUIRE(msgSet.pairMap[0].partIndex == 0);
128+
REQUIRE(msgSet.pairMap[0].payloadIndex == 0);
129+
REQUIRE(msgSet.pairMap[1].partIndex == 1);
130+
REQUIRE(msgSet.pairMap[1].payloadIndex == 0);
131+
REQUIRE(msgSet.pairMap[2].partIndex == 2);
132+
REQUIRE(msgSet.pairMap[2].payloadIndex == 0);
133+
REQUIRE(msgSet.pairMap[3].partIndex == 2);
134+
REQUIRE(msgSet.pairMap[3].payloadIndex == 1);
135+
}

0 commit comments

Comments
 (0)