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 testValueMap : public CppUnit::TestFixture {
0008   CPPUNIT_TEST_SUITE(testValueMap);
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(testValueMap);
0020 
0021 void testValueMap::checkAll() {
0022   typedef std::vector<int> CKey;
0023   typedef double Val;
0024   typedef edm::AssociationMap<edm::OneToValue<CKey, Val, 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 testValueMap::dummy() {
0032   typedef std::vector<int> CKey;
0033   typedef double Val;
0034   typedef edm::AssociationMap<edm::OneToValue<CKey, Val, unsigned char> > Assoc;
0035   Assoc v;
0036   v.insert(edm::Ref<CKey>(), 3.145);
0037   v.insert(Assoc::value_type(edm::Ref<CKey>(), 3.145));
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 double& x = v[edm::Ref<CKey>()];
0044   double y = x;
0045   ++y;
0046   ++f;
0047   edm::Ref<Assoc> r;
0048   v.erase(edm::Ref<CKey>());
0049   v.clear();
0050   CPPUNIT_ASSERT(v.size() == 0);
0051   v.post_insert();
0052 }