Commit 55244187 authored by Matthieu Dorier's avatar Matthieu Dorier

improved tests

parent 301fd5cf
#include <map>
#include <boost/serialization/map.hpp>
#include "PtrTest.hpp"
#include "CppUnitAdditionalMacros.hpp"
#include "TestObjects.hpp"
......@@ -92,3 +94,42 @@ void PtrTest::testPtrLoad() {
CPPUNIT_ASSERT(objB == *ptrB);
}
void PtrTest::testPtrLoadFromArray() {
auto mds = (*datastore)["matthieu"];
auto run = mds[42];
auto subrun = run[3];
auto event = subrun[22];
CPPUNIT_ASSERT(mds.valid());
CPPUNIT_ASSERT(run.valid());
CPPUNIT_ASSERT(subrun.valid());
CPPUNIT_ASSERT(event.valid());
std::vector<TestObjectA> vecA(3);
vecA[0].x() = 43;
vecA[0].y() = 4.3;
vecA[1].x() = 44;
vecA[1].y() = 4.4;
vecA[2].x() = 45;
vecA[2].y() = 4.5;
auto prodIDvec = event.store("somekey", vecA);
auto ptrToVecA = datastore->makePtr<TestObjectA>(prodIDvec,1);
CPPUNIT_ASSERT(vecA[1] == *ptrToVecA);
std::map<unsigned,TestObjectA> mapA;
mapA[0].x() = 43;
mapA[0].y() = 4.3;
mapA[1].x() = 44;
mapA[1].y() = 4.4;
mapA[2].x() = 45;
mapA[2].y() = 4.5;
auto prodIDmap = event.store("somekey", mapA);
auto ptrToMapA = datastore->makePtr<TestObjectA,std::map<unsigned,TestObjectA>>(prodIDmap,1);
CPPUNIT_ASSERT(mapA[1] == *ptrToMapA);
}
......@@ -12,6 +12,7 @@ class PtrTest : public CppUnit::TestFixture
CPPUNIT_TEST( testFillDataStore );
CPPUNIT_TEST( testMakePtr );
CPPUNIT_TEST( testPtrLoad );
CPPUNIT_TEST( testPtrLoadFromArray );
CPPUNIT_TEST_SUITE_END();
public:
......@@ -22,6 +23,7 @@ class PtrTest : public CppUnit::TestFixture
void testFillDataStore();
void testMakePtr();
void testPtrLoad();
void testPtrLoadFromArray();
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment