Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

StateDBTest.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 /** @file StateDBTest.cpp
00003  */
00004 //---------------------------------------------------------------------------
00005 #include <boost/test/auto_unit_test.hpp>
00006 
00007 #include "StateDB.hpp"
00008 
00009 using namespace benzene;
00010 
00011 //---------------------------------------------------------------------------
00012 
00013 namespace {
00014 
00015 BOOST_AUTO_TEST_CASE(StateDB_StateSet)
00016 {
00017     StoneBoard b1(3, 3, "Bbw"
00018                         ".Ww"
00019                         "..W");
00020     StoneBoard rb1(b1);
00021     rb1.RotateBoard();
00022 
00023     HexState sb1(b1, BLACK);
00024     HexState srb1(rb1, BLACK);
00025 
00026     StateSet set;
00027     BOOST_CHECK(!set.Exists(sb1));
00028 
00029     set.Insert(sb1);
00030     BOOST_CHECK(set.Exists(sb1));
00031     BOOST_CHECK(set.Exists(srb1));
00032     
00033     StoneBoard b2(3, 3);
00034     HexState sb2(b2, BLACK);
00035     BOOST_CHECK(!set.Exists(sb2));
00036 }
00037 
00038 BOOST_AUTO_TEST_CASE(StateDB_StateMap)
00039 {
00040     StoneBoard b1(3, 3, "Bbw"
00041                         ".Ww"
00042                         "..W");
00043     StoneBoard rb1(b1);
00044     rb1.RotateBoard();
00045     StoneBoard b2(3, 5, "Bbw"
00046                         ".Ww"
00047                         "..W"
00048                         "..."
00049                         "...");
00050     StoneBoard rb2(b2);
00051     rb2.RotateBoard();
00052 
00053     HexState sb1(b1, BLACK);
00054     HexState sb2(b2, BLACK);
00055     HexState srb1(rb1, BLACK);
00056     HexState srb2(rb2, BLACK);
00057 
00058     StateMap<int> map;
00059     BOOST_CHECK(!map.Exists(sb1));
00060     
00061     map[sb1] = 5;
00062     BOOST_CHECK(map.Exists(sb1));
00063     BOOST_CHECK(map.Exists(srb1));
00064     BOOST_CHECK(!map.Exists(sb2));
00065     BOOST_CHECK(!map.Exists(srb2));    
00066     BOOST_CHECK_EQUAL(map[sb1], 5);
00067     BOOST_CHECK_EQUAL(map[srb1], 5);
00068 
00069     map[srb2] = 1;
00070     BOOST_CHECK(map.Exists(sb2));
00071     BOOST_CHECK(map.Exists(srb2));
00072     BOOST_CHECK_EQUAL(map[sb1], 5);
00073     BOOST_CHECK_EQUAL(map[srb1], 5);
00074     BOOST_CHECK_EQUAL(map[sb2], 1);
00075     BOOST_CHECK_EQUAL(map[srb2], 1);
00076 }
00077 
00078 }
00079 
00080 //---------------------------------------------------------------------------


6 Jan 2011 Doxygen 1.6.3