Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <cppunit/extensions/HelperMacros.h>
0002 
0003 #include "DetectorDescription/DDCMS/interface/DDSolidShapes.h"
0004 
0005 #include <iostream>
0006 
0007 #include "cppunit/TestAssert.h"
0008 #include "cppunit/TestFixture.h"
0009 
0010 using namespace cms;
0011 using namespace std;
0012 
0013 class testDDSolidLegacyShapes : public CppUnit::TestFixture {
0014   CPPUNIT_TEST_SUITE(testDDSolidLegacyShapes);
0015   CPPUNIT_TEST(checkDDSolidLegacyShapes);
0016   CPPUNIT_TEST_SUITE_END();
0017 
0018 public:
0019   void setUp() override;
0020   void tearDown() override {}
0021   void checkDDSolidLegacyShapes();
0022 
0023 private:
0024   std::string solidName_;
0025 };
0026 
0027 CPPUNIT_TEST_SUITE_REGISTRATION(testDDSolidLegacyShapes);
0028 
0029 void testDDSolidLegacyShapes::setUp() { solidName_ = "Trap"; }
0030 
0031 void testDDSolidLegacyShapes::checkDDSolidLegacyShapes() {
0032   cms::DDSolidShape shape = cms::dd::value(cms::DDSolidShapeMap, solidName_);
0033   CPPUNIT_ASSERT(shape == cms::DDSolidShape::ddtrap);
0034 
0035   std::string name = cms::dd::name(cms::DDSolidShapeMap, shape);
0036   CPPUNIT_ASSERT(name == solidName_);
0037 
0038   cms::DDSolidShape invalidShape = cms::dd::value(cms::DDSolidShapeMap, "Blah Blah Blah");
0039   CPPUNIT_ASSERT(invalidShape == cms::DDSolidShape::dd_not_init);
0040 
0041   std::string invalidName = cms::dd::name(cms::DDSolidShapeMap, invalidShape);
0042   CPPUNIT_ASSERT(invalidName == std::string("Solid not initialized"));
0043 
0044   LegacySolidShape invalidLegacyShape = cms::dd::value(cms::LegacySolidShapeMap, invalidShape);
0045   CPPUNIT_ASSERT(invalidLegacyShape == LegacySolidShape::dd_not_init);
0046 
0047   LegacySolidShape legacyBox = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddbox);
0048   CPPUNIT_ASSERT(legacyBox == LegacySolidShape::ddbox);
0049 
0050   LegacySolidShape legacyTubs = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddtubs);
0051   CPPUNIT_ASSERT(legacyTubs == LegacySolidShape::ddtubs);
0052 
0053   LegacySolidShape legacyTrap = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddtrap);
0054   CPPUNIT_ASSERT(legacyTrap == LegacySolidShape::ddtrap);
0055 
0056   LegacySolidShape legacyCons = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddcons);
0057   CPPUNIT_ASSERT(legacyCons == LegacySolidShape::ddcons);
0058 
0059   LegacySolidShape legacyPcon = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddpolycone);
0060   CPPUNIT_ASSERT(legacyPcon == LegacySolidShape::ddpolycone_rz);
0061 
0062   LegacySolidShape legacyPolyhedra = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddpolyhedra);
0063   CPPUNIT_ASSERT(legacyPolyhedra == LegacySolidShape::ddpolyhedra_rz);
0064 
0065   LegacySolidShape legacyTorus = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddtorus);
0066   CPPUNIT_ASSERT(legacyTorus == LegacySolidShape::ddtorus);
0067 
0068   LegacySolidShape legacyUnion = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddunion);
0069   CPPUNIT_ASSERT(legacyUnion == LegacySolidShape::ddunion);
0070 
0071   LegacySolidShape legacySubtraction = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddsubtraction);
0072   CPPUNIT_ASSERT(legacySubtraction == LegacySolidShape::ddsubtraction);
0073 
0074   LegacySolidShape legacyIntersection = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddintersection);
0075   CPPUNIT_ASSERT(legacyIntersection == LegacySolidShape::ddintersection);
0076 
0077   LegacySolidShape legacyShapeless = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddshapeless);
0078   CPPUNIT_ASSERT(legacyShapeless == LegacySolidShape::ddshapeless);
0079 
0080   LegacySolidShape legacyAssembly = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddassembly);
0081   CPPUNIT_ASSERT(legacyAssembly == LegacySolidShape::ddassembly);
0082 
0083   LegacySolidShape legacyPseudotrap = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddpseudotrap);
0084   CPPUNIT_ASSERT(legacyPseudotrap == LegacySolidShape::ddpseudotrap);
0085 
0086   LegacySolidShape legacyTrunctubs = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddtrunctubs);
0087   CPPUNIT_ASSERT(legacyTrunctubs == LegacySolidShape::ddtrunctubs);
0088 
0089   LegacySolidShape legacySphere = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddsphere);
0090   CPPUNIT_ASSERT(legacySphere == LegacySolidShape::ddsphere);
0091 
0092   LegacySolidShape legacyEllipticaltube = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddellipticaltube);
0093   CPPUNIT_ASSERT(legacyEllipticaltube == LegacySolidShape::ddellipticaltube);
0094 
0095   LegacySolidShape legacyCuttubs = cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddcuttubs);
0096   CPPUNIT_ASSERT(legacyCuttubs == LegacySolidShape::ddcuttubs);
0097 
0098   LegacySolidShape legacyExtrudedpolygon =
0099       cms::dd::value(cms::LegacySolidShapeMap, cms::DDSolidShape::ddextrudedpolygon);
0100   CPPUNIT_ASSERT(legacyExtrudedpolygon == LegacySolidShape::ddextrudedpolygon);
0101 
0102   int ids[] = {0,  0,  1,  1,  2,  2,  3,  3,  4,  4,  5,  5,  7,  5,  6,  6,  8,  6,  9,  9,  10,
0103                10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 22};
0104   int i = 0;
0105   for (const auto it : LegacySolidShapeMap) {
0106     CPPUNIT_ASSERT(static_cast<int>(it.value) == ids[i++]);
0107     CPPUNIT_ASSERT(static_cast<int>(it.name) == ids[i++]);
0108   }
0109 }