Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HashSetTest.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 /** @file HashSetTest.cpp
00003  */
00004 //---------------------------------------------------------------------------
00005 
00006 #include <boost/test/auto_unit_test.hpp>
00007 
00008 #include "HashSet.hpp"
00009 
00010 using namespace benzene;
00011 
00012 //---------------------------------------------------------------------------
00013 
00014 namespace {
00015 
00016 BOOST_AUTO_TEST_CASE(HashSet_AllTests)
00017 {
00018     HashSet hm(5);
00019 
00020     // check size()
00021     BOOST_CHECK_EQUAL(hm.size(), 32u);
00022     BOOST_CHECK_EQUAL(hm.count(), 0u);
00023 
00024     // table is empty, so get better fail!
00025     BOOST_CHECK(!hm.exists(1));
00026 
00027     // check add()/exists()
00028     hm.add(1);
00029     BOOST_CHECK(hm.exists(1));
00030     BOOST_CHECK(!hm.exists(2));
00031     BOOST_CHECK_EQUAL(hm.count(), 1u);
00032 
00033     // check collisions
00034     hm.add(33);
00035     BOOST_CHECK(hm.exists(1));
00036     BOOST_CHECK(hm.exists(33));
00037     BOOST_CHECK_EQUAL(hm.count(), 2u);
00038 
00039     HashSet mm(5);
00040     mm = hm;
00041     BOOST_CHECK(mm.exists(1));
00042     BOOST_CHECK(mm.exists(33));
00043     BOOST_CHECK_EQUAL(mm.count(), 2u);
00044 
00045     HashSet blah(mm);
00046     BOOST_CHECK(blah.exists(1));
00047     BOOST_CHECK(blah.exists(33));
00048     BOOST_CHECK_EQUAL(blah.count(), 2u);
00049 
00050     hm.clear();
00051     BOOST_CHECK(!hm.exists(1));
00052     BOOST_CHECK(!hm.exists(33));
00053     BOOST_CHECK_EQUAL(hm.count(), 0u);
00054 }
00055 
00056 }
00057 
00058 //---------------------------------------------------------------------------


6 Jan 2011 Doxygen 1.6.3