Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:15

0001 /*----------------------------------------------------------------------
0002 
0003 Test program for edm::TypeID 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/TypeID.h"
0013 
0014 class testTypeid : public CppUnit::TestFixture {
0015   CPPUNIT_TEST_SUITE(testTypeid);
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(testTypeid);
0032 
0033 namespace edmtest {
0034   struct empty {};
0035 }  // namespace edmtest
0036 
0037 using std::cerr;
0038 using std::endl;
0039 
0040 void testTypeid::equalityTest()
0041 
0042 {
0043   edmtest::empty e;
0044   edm::TypeID id1(e);
0045   edm::TypeID id2(e);
0046 
0047   CPPUNIT_ASSERT(!(id1 < id2));
0048   CPPUNIT_ASSERT(!(id2 < id1));
0049 
0050   std::string n1(id1.name());
0051   std::string n2(id2.name());
0052 
0053   CPPUNIT_ASSERT(n1 == n2);
0054 }
0055 
0056 void testTypeid::copyTest() {
0057   edmtest::empty e;
0058   edm::TypeID id1(e);
0059 
0060   edm::TypeID id3 = id1;
0061   CPPUNIT_ASSERT(!(id1 < id3));
0062   CPPUNIT_ASSERT(!(id3 < id1));
0063 
0064   std::string n1(id1.name());
0065   std::string n3(id3.name());
0066   CPPUNIT_ASSERT(n1 == n3);
0067 }