00001 //--------------------------------------------------------------------------- 00002 /** @file RingGodelTest.cpp 00003 */ 00004 //--------------------------------------------------------------------------- 00005 #include <boost/test/auto_unit_test.hpp> 00006 00007 #include "RingGodel.hpp" 00008 00009 using namespace benzene; 00010 00011 //--------------------------------------------------------------------------- 00012 00013 namespace { 00014 00015 BOOST_AUTO_TEST_CASE(RingGodel_All) 00016 { 00017 RingGodel brd; 00018 PatternRingGodel pat; 00019 00020 brd.SetEmpty(); 00021 pat.SetEmpty(); 00022 00023 // empty mask matches empty brd 00024 BOOST_CHECK(pat.MatchesGodel(brd)); 00025 00026 // color of a slice not in mask does not affect matching. 00027 for (ColorIterator c1; c1; ++c1) { 00028 pat.SetSliceToColor(0, *c1); 00029 for (ColorIterator c2; c2; ++c2) { 00030 brd.SetSliceToColor(0, *c2); 00031 BOOST_CHECK(pat.MatchesGodel(brd)); 00032 } 00033 } 00034 00035 // color of slices in mask does affect matching. 00036 brd.SetEmpty(); 00037 pat.SetEmpty(); 00038 pat.AddSliceToMask(0); 00039 for (ColorIterator c1; c1; ++c1) { 00040 pat.SetSliceToColor(0, *c1); 00041 for (ColorIterator c2; c2; ++c2) { 00042 brd.SetSliceToColor(0, *c2); 00043 BOOST_CHECK_EQUAL(pat.MatchesGodel(brd), *c1 == *c2); 00044 } 00045 } 00046 00047 // check that a B,W,or BW slice matches a BW slice, and that E 00048 // does not match BW. 00049 brd.SetEmpty(); 00050 pat.SetEmpty(); 00051 pat.AddSliceToMask(0); 00052 00053 brd.AddColorToSlice(0, BLACK); 00054 brd.AddColorToSlice(0, WHITE); 00055 brd.RemoveColorFromSlice(0, EMPTY); 00056 00057 pat.SetSliceToColor(0, EMPTY); 00058 BOOST_CHECK(!pat.MatchesGodel(brd)); 00059 pat.SetSliceToColor(0, BLACK); 00060 BOOST_CHECK(pat.MatchesGodel(brd)); 00061 pat.SetSliceToColor(0, WHITE); 00062 BOOST_CHECK(pat.MatchesGodel(brd)); 00063 pat.SetSliceToColor(0, WHITE); 00064 pat.AddColorToSlice(0, BLACK); 00065 BOOST_CHECK(pat.MatchesGodel(brd)); 00066 00067 // check that a BW slice matches only BW. 00068 brd.SetEmpty(); 00069 pat.SetEmpty(); 00070 pat.AddSliceToMask(0); 00071 00072 pat.AddColorToSlice(0, BLACK); 00073 pat.AddColorToSlice(0, WHITE); 00074 pat.RemoveColorFromSlice(0, EMPTY); 00075 00076 brd.SetSliceToColor(0, EMPTY); 00077 BOOST_CHECK(!pat.MatchesGodel(brd)); 00078 brd.SetSliceToColor(0, BLACK); 00079 BOOST_CHECK(!pat.MatchesGodel(brd)); 00080 brd.SetSliceToColor(0, WHITE); 00081 BOOST_CHECK(!pat.MatchesGodel(brd)); 00082 brd.SetSliceToColor(0, WHITE); 00083 brd.AddColorToSlice(0, BLACK); 00084 BOOST_CHECK(pat.MatchesGodel(brd)); 00085 } 00086 00087 } 00088 00089 //---------------------------------------------------------------------------