forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_MessageSet.cxx
More file actions
95 lines (81 loc) · 3.46 KB
/
test_MessageSet.cxx
File metadata and controls
95 lines (81 loc) · 3.46 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include <fairmq/Message.h>
#include "Framework/MessageSet.h"
#include <catch_amalgamated.hpp>
using namespace o2::framework;
TEST_CASE("MessageSet") {
o2::framework::MessageSet msgSet;
std::vector<fair::mq::MessagePtr> ptrs;
std::unique_ptr<fair::mq::Message> msg(nullptr);
std::unique_ptr<fair::mq::Message> msg2(nullptr);
ptrs.emplace_back(std::move(msg));
ptrs.emplace_back(std::move(msg2));
msgSet.add([&ptrs](size_t i) -> fair::mq::MessagePtr& { return ptrs[i]; }, 2);
REQUIRE(msgSet.messages.size() == 2);
REQUIRE(msgSet.messageMap.size() == 1);
REQUIRE(msgSet.pairMap.size() == 1);
REQUIRE(msgSet.messageMap[0].position == 0);
REQUIRE(msgSet.messageMap[0].size == 1);
REQUIRE(msgSet.pairMap[0].partIndex == 0);
REQUIRE(msgSet.pairMap[0].payloadIndex == 0);
}
TEST_CASE("MessageSetWithFunction") {
std::vector<fair::mq::MessagePtr> ptrs;
std::unique_ptr<fair::mq::Message> msg(nullptr);
std::unique_ptr<fair::mq::Message> msg2(nullptr);
ptrs.emplace_back(std::move(msg));
ptrs.emplace_back(std::move(msg2));
o2::framework::MessageSet msgSet([&ptrs](size_t i) -> fair::mq::MessagePtr& { return ptrs[i]; }, 2);
REQUIRE(msgSet.messages.size() == 2);
REQUIRE(msgSet.messageMap.size() == 1);
REQUIRE(msgSet.pairMap.size() == 1);
REQUIRE(msgSet.messageMap[0].position == 0);
REQUIRE(msgSet.messageMap[0].size == 1);
REQUIRE(msgSet.pairMap[0].partIndex == 0);
REQUIRE(msgSet.pairMap[0].payloadIndex == 0);
}
TEST_CASE("MessageSetWithMultipart") {
std::vector<fair::mq::MessagePtr> ptrs;
std::unique_ptr<fair::mq::Message> msg(nullptr);
std::unique_ptr<fair::mq::Message> msg2(nullptr);
std::unique_ptr<fair::mq::Message> msg3(nullptr);
ptrs.emplace_back(std::move(msg));
ptrs.emplace_back(std::move(msg2));
ptrs.emplace_back(std::move(msg3));
o2::framework::MessageSet msgSet([&ptrs](size_t i) -> fair::mq::MessagePtr& { return ptrs[i]; }, 3);
REQUIRE(msgSet.messages.size() == 3);
REQUIRE(msgSet.messageMap.size() == 1);
REQUIRE(msgSet.pairMap.size() == 2);
REQUIRE(msgSet.messageMap[0].position == 0);
REQUIRE(msgSet.messageMap[0].size == 2);
REQUIRE(msgSet.pairMap[0].partIndex == 0);
REQUIRE(msgSet.pairMap[0].payloadIndex == 0);
REQUIRE(msgSet.pairMap[1].partIndex == 0);
REQUIRE(msgSet.pairMap[1].payloadIndex == 1);
}
TEST_CASE("MessageSetAddPartRef") {
std::vector<fair::mq::MessagePtr> ptrs;
std::unique_ptr<fair::mq::Message> msg(nullptr);
std::unique_ptr<fair::mq::Message> msg2(nullptr);
ptrs.emplace_back(std::move(msg));
ptrs.emplace_back(std::move(msg2));
PartRef ref {std::move(msg), std::move(msg2)};
o2::framework::MessageSet msgSet;
msgSet.add(std::move(ref));
REQUIRE(msgSet.messages.size() == 2);
REQUIRE(msgSet.messageMap.size() == 1);
REQUIRE(msgSet.pairMap.size() == 1);
REQUIRE(msgSet.messageMap[0].position == 0);
REQUIRE(msgSet.messageMap[0].size == 1);
REQUIRE(msgSet.pairMap[0].partIndex == 0);
REQUIRE(msgSet.pairMap[0].payloadIndex == 0);
}