 |
Belle II Software
release-05-01-25
|
1 #include <framework/utilities/Stream.h>
2 #include <framework/dataobjects/RelationContainer.h>
3 #include <framework/dataobjects/RelationElement.h>
4 #include <framework/datastore/DataStore.h>
5 #include <framework/gearbox/Gearbox.h>
6 #include <framework/gearbox/GearDir.h>
11 #include <gtest/gtest.h>
22 relCont->setToName(
"b");
23 relCont->setFromDurability(DataStore::c_Event);
24 relCont->setToDurability(DataStore::c_Event);
26 TClonesArray& relations = relCont->elements();
28 for (
int i = 0; i < 100; i++)
29 new(relations.AddrAt(relations.GetLast() + 1))
RelationElement(0, i + 1, 42.0);
37 ASSERT_NE(rel,
nullptr);
41 for (
int i = 0; i < 100; i++) {
48 void checkGbContents()
50 const Gearbox& gb = Gearbox::getInstance();
56 checkObject(
dynamic_cast<const RelationContainer*
>(detector.getTObject(
"RelationContainer")));
62 TVector3 v(1.0, 2.0, 3.0);
63 std::string vStr = Stream::serializeAndEncode(&v);
67 TObject* obj = Stream::deserializeEncodedRawData(vStr);
68 auto*
v2 =
dynamic_cast<TVector3*
>(obj);
69 ASSERT_NE(v2,
nullptr);
70 EXPECT_TRUE(*v2 == v);
75 std::string relStr = Stream::serializeAndEncode(relCont);
77 obj = Stream::deserializeEncodedRawData(relStr);
91 std::string truncated = vStr.substr(0, 12);
92 TObject* broken_obj = Stream::deserializeEncodedRawData(truncated);
93 EXPECT_TRUE(broken_obj ==
nullptr);
97 TEST(StreamTest, GearboxRaw)
99 Gearbox& gb = Gearbox::getInstance();
100 vector<string> backends;
101 backends.emplace_back(
"file:/framework/tests/");
103 gb.
open(
"object_base64.xml");
const std::vector< double > v2
MATLAB generated random vector.
virtual const TObject * getTObject(const std::string &path) const noexcept(false) override
Get the parameter path as a TObject.
const RelationElement & getElement(int i) const
Get reference to RelationElement at index i.
Class to store relations between StoreArrays in the DataStore.
int getEntries() const
Get number of elements.
Class to store a single element of a relation.
void setFromName(const std::string &name)
Set name of the StoreArray we relate from.
Abstract base class for different kinds of events.
Singleton class responsible for loading detector parameters from an XML file.
GearDir is the basic class used for accessing the parameter store.
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
index_type getToIndex(size_t n=0) const
Get nth index we point to.
const std::string & getFromName() const
Get name of the StoreArray we relate from.
void open(const std::string &name="Belle2.xml", size_t cacheSize=c_DefaultCacheSize)
Open connection to backend and parse tree.
weight_type getWeight(size_t n=0) const
Get nth weight we point to.
const std::string & getToName() const
Get name of the StoreArray we relate to.
void setBackends(const std::vector< std::string > &backends)
Select the backends to use to find resources.