testDDStrVector

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#include <cppunit/extensions/HelperMacros.h>
#include <iostream>
#include <memory>
#include <string>
#include <vector>

#include "DetectorDescription/Core/interface/DDStrVector.h"
#include "cppunit/TestAssert.h"
#include "cppunit/TestFixture.h"

class testDDStrVector : public CppUnit::TestFixture {
  CPPUNIT_TEST_SUITE(testDDStrVector);
  CPPUNIT_TEST(checkAgaistOld);
  CPPUNIT_TEST_SUITE_END();

public:
  void setUp() override {}
  void tearDown() override {}
  void buildIt();
  void testloading();
  void checkAgaistOld();
};

CPPUNIT_TEST_SUITE_REGISTRATION(testDDStrVector);

void testDDStrVector::buildIt() {
  auto strVec = std::make_unique<std::vector<std::string>>();
  strVec->emplace_back("One");
  strVec->emplace_back("Two");
  strVec->emplace_back("Three");

  DDStrVector testVec("TestVector", std::move(strVec));
  std::cerr << testVec << std::endl;
}

void testDDStrVector::testloading() {
  auto strVec = std::make_unique<std::vector<std::string>>();
  strVec->emplace_back("One");
  strVec->emplace_back("Two");
  strVec->emplace_back("Three");

  DDStrVector testVec("TestVector", std::move(strVec));
  std::ostringstream os;
  os << testVec;
  std::string str("DDStrVector name=GLOBAL:TestVector size=3 vals=( One Two Three )");
  if (os.str() != str)
    std::cerr << "not the same!" << std::endl;
  CPPUNIT_ASSERT(os.str() == str);
}

void testDDStrVector::checkAgaistOld() {
  buildIt();
  testloading();
}