InferiorCellsTest.cpp
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 #include <boost/test/auto_unit_test.hpp>
00007 
00008 #include "Hex.hpp"
00009 #include "InferiorCells.hpp"
00010 
00011 using namespace benzene;
00012 
00013 
00014 
00015 namespace {
00016 
00017 BOOST_AUTO_TEST_CASE(InferiorCells_Basic)
00018 {
00019     
00020 }
00021 
00022 BOOST_AUTO_TEST_CASE(InferiorCells_Dominated) 
00023 {
00024     HexPoint a1 = HEX_CELL_A1;
00025     HexPoint b1 = HEX_CELL_B1;
00026     HexPoint c1 = HEX_CELL_C1;   
00027     HexPoint a2 = HEX_CELL_A2;
00028     HexPoint b2 = HEX_CELL_B2;
00029     HexPoint c2 = HEX_CELL_C2;
00030     HexPoint a3 = HEX_CELL_A3;
00031     HexPoint b3 = HEX_CELL_B3;
00032     HexPoint c3 = HEX_CELL_C3;
00033     InferiorCells inf;
00034     bitset_t dom;
00035 
00036     
00037     inf.Clear();
00038     inf.AddDominated(a1, b1);
00039     inf.AddDominated(c1, b1);
00040     dom = inf.Dominated();
00041     BOOST_CHECK_EQUAL(dom.count(), 2u);
00042     BOOST_CHECK(dom.test(a1));
00043     BOOST_CHECK(dom.test(c1));
00044     BOOST_CHECK(!dom.test(b1));
00045                 
00046     
00047     inf.Clear();
00048     inf.AddDominated(b1, a1);
00049     inf.AddDominated(b1, c1);
00050     dom = inf.Dominated();
00051     BOOST_CHECK_EQUAL(dom.count(), 1u);
00052     BOOST_CHECK(!dom.test(a1));
00053     BOOST_CHECK(!dom.test(c1));
00054     BOOST_CHECK(dom.test(b1));
00055     
00056     
00057     
00058     
00059     
00060     
00061     
00062     inf.Clear();
00063     inf.AddDominated(a1, b1);
00064     inf.AddDominated(b1, c1);
00065 
00066     inf.AddDominated(a2, b2);
00067     inf.AddDominated(b2, c2);
00068     inf.AddVulnerable(c2, c3);
00069 
00070     dom = inf.Dominated();
00071     BOOST_CHECK(dom.test(a1));
00072     BOOST_CHECK(dom.test(b1));
00073     BOOST_CHECK(!dom.test(c1));
00074     
00075     BOOST_CHECK(dom.test(a2));
00076     BOOST_CHECK(!dom.test(b2));
00077     BOOST_CHECK(!dom.test(c2));    
00078     BOOST_CHECK(!dom.test(c3));
00079 
00080     
00081     
00082     
00083     
00084     
00085     inf.Clear();
00086     inf.AddDominated(a1, b1);
00087     inf.AddDominated(b1, a1);
00088     dom = inf.Dominated();
00089     BOOST_CHECK_EQUAL(dom.count(), 1u);
00090     BOOST_CHECK(dom.test(a1) != dom.test(b1));
00091 
00092     
00093     
00094     
00095     
00096     
00097     
00098     
00099     
00100     
00101     inf.Clear();
00102     inf.AddDominated(a1, b1);
00103     inf.AddDominated(b1, c1);
00104     inf.AddDominated(c1, a1);
00105     inf.AddDominated(b2, a2);
00106     inf.AddDominated(a2, b1);
00107     dom = inf.Dominated();
00108 
00109     BOOST_CHECK_EQUAL(dom.count(), 4u);
00110     BOOST_CHECK(dom.test(b2));
00111     BOOST_CHECK(dom.test(a2));
00112     BOOST_CHECK(!dom.test(a1) || !dom.test(b1) || !dom.test(c1));
00113 
00114     
00115     
00116     
00117     
00118     
00119     
00120     
00121     
00122     
00123     inf.AddDominated(c1, a3);
00124     inf.AddDominated(a3, b3);
00125     inf.AddDominated(b3, a3);
00126     dom = inf.Dominated();
00127     
00128     BOOST_CHECK_EQUAL(dom.count(), 6u);
00129     BOOST_CHECK(dom.test(b2));
00130     BOOST_CHECK(dom.test(a2));
00131     BOOST_CHECK(dom.test(a1));
00132     BOOST_CHECK(dom.test(b1));
00133     BOOST_CHECK(dom.test(c1));
00134     BOOST_CHECK(dom.test(a3) != dom.test(b3));
00135 
00136 
00137     
00138     
00139     
00140     
00141     
00142     
00143     
00144     inf.Clear();
00145     inf.AddDominated(a1, b1);
00146     inf.AddDominated(b1, a1);
00147     inf.AddDominated(b1, c1);
00148     inf.AddDominated(c1, b1);
00149     dom = inf.Dominated();
00150     BOOST_CHECK_EQUAL(dom.count(), 2u);
00151     BOOST_CHECK(!dom.test(a1) || !dom.test(b1) || !dom.test(c1));
00152     
00153 }
00154 
00155 }
00156 
00157