Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:08

0001 #include "cppunit/extensions/HelperMacros.h"
0002 #include <algorithm>
0003 #include <iterator>
0004 #include <iostream>
0005 #include "DataFormats/Common/interface/AssociationMap.h"
0006 
0007 class testOneToOneAssociation : public CppUnit::TestFixture {
0008   CPPUNIT_TEST_SUITE(testOneToOneAssociation);
0009   CPPUNIT_TEST(checkAll);
0010   CPPUNIT_TEST_SUITE_END();
0011 
0012 public:
0013   void setUp() {}
0014   void tearDown() {}
0015   void checkAll();
0016   void dummy();
0017 };
0018 
0019 CPPUNIT_TEST_SUITE_REGISTRATION(testOneToOneAssociation);
0020 
0021 void testOneToOneAssociation::checkAll() {
0022   typedef std::vector<int> CKey;
0023   typedef std::vector<double> CVal;
0024   typedef edm::AssociationMap<edm::OneToOne<CKey, CVal, unsigned char> > Assoc;
0025   Assoc v;
0026   CPPUNIT_ASSERT(v.empty());
0027   CPPUNIT_ASSERT(v.size() == 0);
0028 }
0029 
0030 // just check that some stuff compiles
0031 void testOneToOneAssociation::dummy() {
0032   typedef std::vector<int> CKey;
0033   typedef std::vector<double> CVal;
0034   typedef edm::AssociationMap<edm::OneToOne<CKey, CVal, unsigned char> > Assoc;
0035   Assoc v;
0036   v.insert(edm::Ref<CKey>(), edm::Ref<CVal>());
0037   v.insert(Assoc::value_type(edm::Ref<CKey>(), edm::Ref<CVal>()));
0038   Assoc::const_iterator b = v.begin(), e = v.end();
0039   ++b;
0040   ++e;
0041   Assoc::const_iterator f = v.find(edm::Ref<CKey>());
0042   v.numberOfAssociations(edm::Ref<CKey>());
0043   const edm::Ref<CVal>& x = v[edm::Ref<CKey>()];
0044   x.id();
0045   ++f;
0046   int n = v.numberOfAssociations(edm::Ref<CKey>());
0047   ++n;
0048   edm::Ref<Assoc> r;
0049   v[edm::Ref<CKey>()];
0050   v.erase(edm::Ref<CKey>());
0051   v.clear();
0052   CPPUNIT_ASSERT(v.size() == 0);
0053   v.post_insert();
0054 }