Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <cppunit/extensions/HelperMacros.h>
0002 
0003 #include "FWCore/Utilities/interface/IndexSet.h"
0004 
0005 class testIndexSet : public CppUnit::TestFixture {
0006   CPPUNIT_TEST_SUITE(testIndexSet);
0007   CPPUNIT_TEST(test);
0008   CPPUNIT_TEST_SUITE_END();
0009 
0010 public:
0011   void setUp() {}
0012   void tearDown() {}
0013 
0014   void test();
0015   template <typename T>
0016   void testIterators(T& array);
0017   template <typename T>
0018   void testIterator(T iter, T end);
0019 };
0020 
0021 ///registration of the test so that the runner can find it
0022 CPPUNIT_TEST_SUITE_REGISTRATION(testIndexSet);
0023 
0024 void testIndexSet::test() {
0025   edm::IndexSet set;
0026   CPPUNIT_ASSERT(set.empty());
0027   CPPUNIT_ASSERT(set.size() == 0);
0028   CPPUNIT_ASSERT(!set.has(0));
0029 
0030   set.reserve(10);
0031 
0032   CPPUNIT_ASSERT(set.empty());
0033   CPPUNIT_ASSERT(set.size() == 0);
0034   CPPUNIT_ASSERT(!set.has(0));
0035 
0036   set.insert(0);
0037   CPPUNIT_ASSERT(!set.empty());
0038   CPPUNIT_ASSERT(set.size() == 1);
0039   CPPUNIT_ASSERT(set.has(0));
0040   CPPUNIT_ASSERT(!set.has(1));
0041 
0042   set.insert(2);
0043   CPPUNIT_ASSERT(set.size() == 2);
0044   CPPUNIT_ASSERT(set.has(0));
0045   CPPUNIT_ASSERT(!set.has(1));
0046   CPPUNIT_ASSERT(set.has(2));
0047   CPPUNIT_ASSERT(!set.has(3));
0048 
0049   set.insert(20);
0050   CPPUNIT_ASSERT(set.size() == 3);
0051   CPPUNIT_ASSERT(set.has(0));
0052   CPPUNIT_ASSERT(!set.has(1));
0053   CPPUNIT_ASSERT(set.has(2));
0054   CPPUNIT_ASSERT(!set.has(3));
0055   CPPUNIT_ASSERT(!set.has(19));
0056   CPPUNIT_ASSERT(set.has(20));
0057   CPPUNIT_ASSERT(!set.has(21));
0058 
0059   set.insert(2);
0060   CPPUNIT_ASSERT(set.size() == 3);
0061   CPPUNIT_ASSERT(set.has(2));
0062 
0063   set.clear();
0064   CPPUNIT_ASSERT(set.empty());
0065   CPPUNIT_ASSERT(set.size() == 0);
0066   CPPUNIT_ASSERT(!set.has(0));
0067   CPPUNIT_ASSERT(!set.has(1));
0068   CPPUNIT_ASSERT(!set.has(2));
0069   CPPUNIT_ASSERT(!set.has(3));
0070 }