File indexing completed on 2024-04-06 12:05:27
0001 #include <cppunit/extensions/HelperMacros.h>
0002
0003 #include "DetectorDescription/Core/interface/DDName.h"
0004 #include "DetectorDescription/Core/interface/Singleton.h"
0005 #include "cppunit/TestAssert.h"
0006 #include "cppunit/TestFixture.h"
0007
0008 class testDDName : public CppUnit::TestFixture {
0009 CPPUNIT_TEST_SUITE(testDDName);
0010 CPPUNIT_TEST(checkNames);
0011 CPPUNIT_TEST_SUITE_END();
0012
0013 public:
0014 void setUp() override {}
0015 void tearDown() override {}
0016 void buildIt();
0017 void testloading();
0018 void checkNames();
0019 };
0020
0021 CPPUNIT_TEST_SUITE_REGISTRATION(testDDName);
0022
0023 void testDDName::buildIt() {
0024 DDName name;
0025 DDName anotherName;
0026 std::cerr << "\nDDName name=" << name << " id=" << name.id() << ", another name=" << anotherName
0027 << " id=" << anotherName.id();
0028 int a[100000]{};
0029 for (int i : a) {
0030 DDName myName(std::to_string(i));
0031 }
0032 DDName::Registry& reg = DDI::Singleton<DDName::Registry>::instance();
0033 DDName::Registry::size_type sz = reg.size();
0034 std::cerr << "\nTotal DDNames: " << sz;
0035 }
0036
0037 void testDDName::testloading() {
0038 DDName name;
0039 DDName anotherName;
0040 std::ostringstream os;
0041 os << "DDName name=" << name << " id=" << name.id() << ", another name=" << anotherName << " id=" << anotherName.id();
0042 std::string str("DDName name=anonymous:anonymous id=0, another name=anonymous:anonymous id=0");
0043 if (os.str() != str)
0044 std::cerr << "not the same!" << std::endl;
0045 CPPUNIT_ASSERT(os.str() == str);
0046 }
0047
0048 void testDDName::checkNames() {
0049 buildIt();
0050 testloading();
0051 }