8 #include <framework/utilities/Stream.h>
9 #include <framework/dataobjects/RelationContainer.h>
10 #include <framework/dataobjects/RelationElement.h>
11 #include <framework/datastore/DataStore.h>
12 #include <framework/gearbox/Gearbox.h>
13 #include <framework/gearbox/GearDir.h>
18 #include <gtest/gtest.h>
29 relCont->setToName(
"b");
30 relCont->setFromDurability(DataStore::c_Event);
31 relCont->setToDurability(DataStore::c_Event);
32 TClonesArray& relations = relCont->elements();
34 for (
int i = 0; i < 100; i++)
35 new (relations.AddrAt(relations.GetLast() + 1))
RelationElement(0, i + 1, 42.0);
43 ASSERT_NE(rel,
nullptr);
47 for (
int i = 0; i < 100; i++) {
54 void checkGbContents()
56 const Gearbox& gb = Gearbox::getInstance();
62 checkObject(
dynamic_cast<const RelationContainer*
>(detector.getTObject(
"RelationContainer")));
68 TVector3 v(1.0, 2.0, 3.0);
69 std::string vStr = Stream::serializeAndEncode(&v);
73 TObject* obj = Stream::deserializeEncodedRawData(vStr);
74 auto*
v2 =
dynamic_cast<TVector3*
>(obj);
75 ASSERT_NE(v2,
nullptr);
76 EXPECT_TRUE(*v2 == v);
81 std::string relStr = Stream::serializeAndEncode(relCont);
83 obj = Stream::deserializeEncodedRawData(relStr);
97 std::string truncated = vStr.substr(0, 12);
98 TObject* broken_obj = Stream::deserializeEncodedRawData(truncated);
99 EXPECT_TRUE(broken_obj ==
nullptr);
103 TEST(StreamTest, GearboxRaw)
105 Gearbox& gb = Gearbox::getInstance();
106 vector<string> backends;
107 backends.emplace_back(
"file:/framework/tests/");
109 gb.
open(
"object_base64.xml");
GearDir is the basic class used for accessing the parameter store.
Singleton class responsible for loading detector parameters from an XML file.
Class to store relations between StoreArrays in the DataStore.
const std::string & getToName() const
Get name of the StoreArray we relate to.
const RelationElement & getElement(int i) const
Get reference to RelationElement at index i.
int getEntries() const
Get number of elements.
const std::string & getFromName() const
Get name of the StoreArray we relate from.
void setFromName(const std::string &name)
Set name of the StoreArray we relate from.
Class to store a single element of a relation.
index_type getToIndex(size_t n=0) const
Get nth index we point to.
weight_type getWeight(size_t n=0) const
Get nth weight we point to.
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
virtual const TObject * getTObject(const std::string &path) const noexcept(false) override
Get the parameter path as a TObject.
void setBackends(const std::vector< std::string > &backends)
Select the backends to use to find resources.
void open(const std::string &name="Belle2.xml", size_t cacheSize=c_DefaultCacheSize)
Open connection to backend and parse tree.
Abstract base class for different kinds of events.
const std::vector< double > v2
MATLAB generated random vector.