Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HexBoardTest.cpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file HexBoardTest.cpp
00003  */
00004 //----------------------------------------------------------------------------
00005 
00006 #include <boost/test/auto_unit_test.hpp>
00007 
00008 #include "HexBoard.hpp"
00009 #include "VCSet.hpp"
00010 
00011 using namespace benzene;
00012 
00013 //---------------------------------------------------------------------------
00014 
00015 namespace {
00016 
00017 //---------------------------------------------------------------------------
00018 
00019 BOOST_AUTO_TEST_CASE(HexBoard_PlayAndUndo)
00020 {
00021     ICEngine ice;
00022     VCBuilderParam param;
00023     HexBoard brd(7, 7, ice, param);
00024     brd.ComputeAll(BLACK);
00025     BOOST_CHECK(!brd.Cons(BLACK).Exists(NORTH, HEX_CELL_A4, VC::FULL));
00026 
00027     brd.PlayMove(BLACK, HEX_CELL_B2);
00028     BOOST_CHECK_EQUAL(brd.GetPosition().GetColor(HEX_CELL_B2), BLACK);
00029     BOOST_CHECK(brd.Cons(BLACK).Exists(NORTH, HEX_CELL_A4, VC::FULL));
00030 
00031     brd.UndoMove();
00032     BOOST_CHECK(brd.GetPosition().IsEmpty(HEX_CELL_B2));
00033     BOOST_CHECK(!brd.Cons(BLACK).Exists(NORTH, HEX_CELL_A4, VC::FULL));
00034 }
00035 
00036 BOOST_AUTO_TEST_CASE(HexBoard_CopyConstructor)
00037 {
00038     ICEngine ice;
00039     VCBuilderParam param;
00040     HexBoard brd(7, 7, ice, param);
00041     brd.ComputeAll(BLACK);
00042     brd.PlayMove(BLACK, HEX_CELL_B2);
00043     BOOST_CHECK_EQUAL(brd.GetPosition().GetColor(HEX_CELL_B2), BLACK);
00044     BOOST_CHECK(brd.Cons(BLACK).Exists(NORTH, HEX_CELL_A4, VC::FULL));
00045 
00046     HexBoard cpy(brd);
00047     BOOST_CHECK_EQUAL(cpy.GetPosition().GetColor(HEX_CELL_B2), BLACK);
00048     BOOST_CHECK(cpy.Cons(BLACK).Exists(NORTH, HEX_CELL_A4, VC::FULL));
00049 
00050     brd.UndoMove();
00051     BOOST_CHECK_EQUAL(cpy.GetPosition().GetColor(HEX_CELL_B2), BLACK);
00052     BOOST_CHECK(cpy.Cons(BLACK).Exists(NORTH, HEX_CELL_A4, VC::FULL));    
00053 }
00054 
00055 //---------------------------------------------------------------------------
00056 
00057 } // namespace
00058 
00059 //---------------------------------------------------------------------------


6 Jan 2011 Doxygen 1.6.3