Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:23

0001 /*----------------------------------------------------------------------
0002 
0003 Test program for edm::TypeIDBase class.
0004 Changed by Viji on 29-06-2005
0005 
0006  ----------------------------------------------------------------------*/
0007 
0008 #include <cassert>
0009 #include <iostream>
0010 #include <string>
0011 #include <cppunit/extensions/HelperMacros.h>
0012 #include "FWCore/Utilities/interface/TypeIDBase.h"
0013 
0014 class testTypeIDBase : public CppUnit::TestFixture {
0015   CPPUNIT_TEST_SUITE(testTypeIDBase);
0016 
0017   CPPUNIT_TEST(equalityTest);
0018   CPPUNIT_TEST(copyTest);
0019 
0020   CPPUNIT_TEST_SUITE_END();
0021 
0022 public:
0023   void setUp() {}
0024   void tearDown() {}
0025 
0026   void equalityTest();
0027   void copyTest();
0028 };
0029 
0030 ///registration of the test so that the runner can find it
0031 CPPUNIT_TEST_SUITE_REGISTRATION(testTypeIDBase);
0032 
0033 namespace edmtest {
0034   struct empty {};
0035 }  // namespace edmtest
0036 
0037 void testTypeIDBase::equalityTest()
0038 
0039 {
0040   edmtest::empty e;
0041   edm::TypeIDBase id1(typeid(e));
0042   edm::TypeIDBase id2(typeid(e));
0043 
0044   CPPUNIT_ASSERT(!(id1 < id2));
0045   CPPUNIT_ASSERT(!(id2 < id1));
0046 
0047   std::string n1(id1.name());
0048   std::string n2(id2.name());
0049 
0050   CPPUNIT_ASSERT(n1 == n2);
0051 }
0052 
0053 void testTypeIDBase::copyTest() {
0054   edmtest::empty e;
0055   edm::TypeIDBase id1(typeid(e));
0056 
0057   edm::TypeIDBase id3 = id1;
0058   CPPUNIT_ASSERT(!(id1 < id3));
0059   CPPUNIT_ASSERT(!(id3 < id1));
0060 
0061   std::string n1(id1.name());
0062   std::string n3(id3.name());
0063   CPPUNIT_ASSERT(n1 == n3);
0064 }
0065 #include <Utilities/Testing/interface/CppUnit_testdriver.icpp>