23 #include <gtest/gtest.h>
26 #ifndef SIMULATIONBASE
60 #ifndef SIMULATIONBASE
70 return StatusCode::SUCCESS;
75 void DataHandleTestTool ::
78 #ifndef SIMULATIONBASE
81 ASSERT_NE (0
u, muonsStore->size());
85 if (m_readFailure ==
true)
87 EXPECT_FALSE (readHandle.isPresent());
88 EXPECT_EQ (
nullptr, readHandle.get());
89 EXPECT_FALSE (readHandle.isValid());
92 EXPECT_TRUE (readHandle.isPresent());
93 EXPECT_EQ (muonsStore, readHandle.get());
94 EXPECT_TRUE (readHandle.isValid());
98 if (m_readDecorFailure ==
true)
100 EXPECT_TRUE(readDecorHandle.
isPresent());
102 EXPECT_ANY_THROW (readDecorHandle (*testMuon));
105 EXPECT_TRUE(readDecorHandle.
isPresent());
108 EXPECT_EQ (
acc (*testMuon), readDecorHandle (*testMuon));
113 EXPECT_EQ (1
u, m_readKeyArray.size());
114 auto handles = m_readKeyArray.makeHandles();
115 EXPECT_EQ (muonsStore, handles[0].
get());
118 EXPECT_EQ (0
u, m_readKeyArray.size());
121 if (!m_doWriteName.empty())
124 auto newMuons = std::make_unique<xAOD::MuonContainer>();
125 auto newAux = std::make_unique<xAOD::MuonAuxContainer>();
128 EXPECT_SUCCESS (writeHandle.record (std::move (newMuons), std::move (newAux)));
131 EXPECT_EQ (recordMuons, retrieveMuons);
134 EXPECT_EQ (recordAux, retrieveAux);
137 if (!m_doWriteDecorName.empty())
139 auto writeDecorHandle = SG::makeHandle<unsigned> (m_writeDecorKey);
140 EXPECT_TRUE(writeDecorHandle.isPresent());
141 EXPECT_FALSE(writeDecorHandle.isAvailable());
142 writeDecorHandle (*(*muonsStore)[0]) = 42
u;
144 EXPECT_EQ (42
u,
acc (*(*muonsStore)[0]));
147 if (!m_doWriteDecorNameExisting.empty())
149 auto writeDecorHandleExisting = SG::makeHandle<float> (m_writeDecorKeyExisting);
150 EXPECT_TRUE(writeDecorHandleExisting.isPresent());
151 EXPECT_TRUE(writeDecorHandleExisting.isAvailable());