1 #include <framework/pcore/MsgHandler.h>
4 #include <TClonesArray.h>
8 #include <gtest/gtest.h>
14 TEST(MsgHandlerTest, conversion)
17 TVector3 a(1.0, 2.0, 3.0);
18 handler.add(&a,
"vector");
19 TVector3 b(42.0, 7.0, -20.0);
20 handler.add(&b,
"vectorb");
21 TNamed c(
"abc",
"def");
22 handler.add(&c,
"named");
23 EvtMessage* msg = handler.encode_msg(MSG_EVENT);
27 vector<TObject*> objs;
30 ASSERT_EQ(3, objs.size());
31 ASSERT_EQ(3, names.size());
32 ASSERT_EQ(
"vector", names[0]);
33 ASSERT_EQ(
"vectorb", names[1]);
34 ASSERT_EQ(
"named", names[2]);
36 auto a2 =
dynamic_cast<TVector3*
>(objs[0]);
37 ASSERT_NE(a2,
nullptr);
38 EXPECT_TRUE(*a2 == a);
40 auto b2 =
dynamic_cast<TVector3*
>(objs[1]);
41 ASSERT_NE(b2,
nullptr);
42 EXPECT_TRUE(*b2 == b);
44 auto c2 =
dynamic_cast<TNamed*
>(objs[2]);
45 ASSERT_NE(c2,
nullptr);
46 EXPECT_TRUE(std::string(c2->GetName()) == c.GetName());
47 EXPECT_TRUE(std::string(c2->GetTitle()) == c.GetTitle());
52 TEST(MsgHandlerTest, compression)
54 TClonesArray longarray(
"Belle2::EventMetaData");
55 longarray.ExpandCreate(1000);
56 for (
int algo : {0, 1, 2}) {
57 for (
int level = 0; level < 10; ++level) {
59 handler.add(&longarray,
"mcparticles");
60 EvtMessage* msg = handler.encode_msg(MSG_EVENT);
63 vector<TObject*> objs;
66 ASSERT_EQ(1, objs.size());
67 ASSERT_EQ(1, names.size());
68 ASSERT_EQ(names[0],
"mcparticles");
69 for (
auto o : objs)
delete o;