Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:27

0001 #include <cppunit/extensions/HelperMacros.h>
0002 #include <iostream>
0003 #include <memory>
0004 #include <string>
0005 #include <vector>
0006 
0007 #include "DetectorDescription/Core/interface/DDStrVector.h"
0008 #include "cppunit/TestAssert.h"
0009 #include "cppunit/TestFixture.h"
0010 
0011 class testDDStrVector : public CppUnit::TestFixture {
0012   CPPUNIT_TEST_SUITE(testDDStrVector);
0013   CPPUNIT_TEST(checkAgaistOld);
0014   CPPUNIT_TEST_SUITE_END();
0015 
0016 public:
0017   void setUp() override {}
0018   void tearDown() override {}
0019   void buildIt();
0020   void testloading();
0021   void checkAgaistOld();
0022 };
0023 
0024 CPPUNIT_TEST_SUITE_REGISTRATION(testDDStrVector);
0025 
0026 void testDDStrVector::buildIt() {
0027   auto strVec = std::make_unique<std::vector<std::string>>();
0028   strVec->emplace_back("One");
0029   strVec->emplace_back("Two");
0030   strVec->emplace_back("Three");
0031 
0032   DDStrVector testVec("TestVector", std::move(strVec));
0033   std::cerr << testVec << std::endl;
0034 }
0035 
0036 void testDDStrVector::testloading() {
0037   auto strVec = std::make_unique<std::vector<std::string>>();
0038   strVec->emplace_back("One");
0039   strVec->emplace_back("Two");
0040   strVec->emplace_back("Three");
0041 
0042   DDStrVector testVec("TestVector", std::move(strVec));
0043   std::ostringstream os;
0044   os << testVec;
0045   std::string str("DDStrVector name=GLOBAL:TestVector size=3 vals=( One Two Three )");
0046   if (os.str() != str)
0047     std::cerr << "not the same!" << std::endl;
0048   CPPUNIT_ASSERT(os.str() == str);
0049 }
0050 
0051 void testDDStrVector::checkAgaistOld() {
0052   buildIt();
0053   testloading();
0054 }