00001 #include <boost/test/auto_unit_test.hpp> 00002 00003 #include "Hex.hpp" 00004 00005 using namespace benzene; 00006 00007 //--------------------------------------------------------------------------- 00008 00009 namespace { 00010 00011 BOOST_AUTO_TEST_CASE(HexColor_Iterator) 00012 { 00013 BWIterator itColor; 00014 BOOST_CHECK(itColor); 00015 BOOST_CHECK_EQUAL(*itColor, BLACK); 00016 ++itColor; 00017 BOOST_CHECK(itColor); 00018 BOOST_CHECK_EQUAL(*itColor, WHITE); 00019 ++itColor; 00020 BOOST_CHECK(!itColor); 00021 } 00022 00023 BOOST_AUTO_TEST_CASE(HexColor_CheckingValidityAndRange) 00024 { 00025 BOOST_CHECK(HexColorUtil::isValidColor(BLACK)); 00026 BOOST_CHECK(HexColorUtil::isValidColor(WHITE)); 00027 BOOST_CHECK(HexColorUtil::isValidColor(EMPTY)); 00028 BOOST_CHECK(HexColorUtil::isBlackWhite(BLACK)); 00029 BOOST_CHECK(HexColorUtil::isBlackWhite(WHITE)); 00030 BOOST_CHECK(!HexColorUtil::isBlackWhite(EMPTY)); 00031 } 00032 00033 BOOST_AUTO_TEST_CASE(HexColor_StringConversion) 00034 { 00035 BOOST_CHECK_EQUAL(HexColorUtil::toString(BLACK), "black"); 00036 BOOST_CHECK_EQUAL(HexColorUtil::toString(WHITE), "white"); 00037 BOOST_CHECK_EQUAL(HexColorUtil::toString(EMPTY), "empty"); 00038 } 00039 00040 BOOST_AUTO_TEST_CASE(HexColor_GetComplement) 00041 { 00042 BOOST_CHECK_EQUAL(HexColorUtil::otherColor(BLACK), WHITE); 00043 BOOST_CHECK_EQUAL(HexColorUtil::otherColor(WHITE), BLACK); 00044 BOOST_CHECK_EQUAL(HexColorUtil::otherColor(EMPTY), EMPTY); 00045 00046 BOOST_CHECK_EQUAL(!BLACK, WHITE); 00047 BOOST_CHECK_EQUAL(!WHITE, BLACK); 00048 BOOST_CHECK_EQUAL(!EMPTY, EMPTY); 00049 00050 for (ColorIterator color; color; ++color) { 00051 BOOST_CHECK_EQUAL(!(*color), HexColorUtil::otherColor(*color)); 00052 } 00053 } 00054 00055 BOOST_AUTO_TEST_CASE(HexColorSet_CheckingValidity) 00056 { 00057 BOOST_CHECK(HexColorSetUtil::isValid(BLACK_ONLY)); 00058 BOOST_CHECK(HexColorSetUtil::isValid(WHITE_ONLY)); 00059 BOOST_CHECK(HexColorSetUtil::isValid(EMPTY_ONLY)); 00060 BOOST_CHECK(HexColorSetUtil::isValid(NOT_BLACK)); 00061 BOOST_CHECK(HexColorSetUtil::isValid(NOT_WHITE)); 00062 BOOST_CHECK(HexColorSetUtil::isValid(NOT_EMPTY)); 00063 BOOST_CHECK(HexColorSetUtil::isValid(ALL_COLORS)); 00064 } 00065 00066 BOOST_AUTO_TEST_CASE(HexColorSet_StringConversion) 00067 { 00068 BOOST_CHECK_EQUAL(HexColorSetUtil::toString(BLACK_ONLY), "black_only"); 00069 BOOST_CHECK_EQUAL(HexColorSetUtil::toString(WHITE_ONLY), "white_only"); 00070 BOOST_CHECK_EQUAL(HexColorSetUtil::toString(EMPTY_ONLY), "empty_only"); 00071 BOOST_CHECK_EQUAL(HexColorSetUtil::toString(NOT_BLACK), "not_black"); 00072 BOOST_CHECK_EQUAL(HexColorSetUtil::toString(NOT_WHITE), "not_white"); 00073 BOOST_CHECK_EQUAL(HexColorSetUtil::toString(NOT_EMPTY), "not_empty"); 00074 BOOST_CHECK_EQUAL(HexColorSetUtil::toString(ALL_COLORS), "all_colors"); 00075 BOOST_CHECK_EQUAL(HexColorSetUtil::fromString("black_only"), BLACK_ONLY); 00076 BOOST_CHECK_EQUAL(HexColorSetUtil::fromString("white_only"), WHITE_ONLY); 00077 BOOST_CHECK_EQUAL(HexColorSetUtil::fromString("empty_only"), EMPTY_ONLY); 00078 BOOST_CHECK_EQUAL(HexColorSetUtil::fromString("not_black"), NOT_BLACK); 00079 BOOST_CHECK_EQUAL(HexColorSetUtil::fromString("not_white"), NOT_WHITE); 00080 BOOST_CHECK_EQUAL(HexColorSetUtil::fromString("not_empty"), NOT_EMPTY); 00081 BOOST_CHECK_EQUAL(HexColorSetUtil::fromString("all_colors"), ALL_COLORS); 00082 } 00083 00084 BOOST_AUTO_TEST_CASE(HexColorSet_CheckingInclusion) 00085 { 00086 BOOST_CHECK( HexColorSetUtil::InSet(BLACK, BLACK_ONLY)); 00087 BOOST_CHECK(!HexColorSetUtil::InSet(WHITE, BLACK_ONLY)); 00088 BOOST_CHECK(!HexColorSetUtil::InSet(EMPTY, BLACK_ONLY)); 00089 BOOST_CHECK(!HexColorSetUtil::InSet(BLACK, WHITE_ONLY)); 00090 BOOST_CHECK( HexColorSetUtil::InSet(WHITE, WHITE_ONLY)); 00091 BOOST_CHECK(!HexColorSetUtil::InSet(EMPTY, WHITE_ONLY)); 00092 BOOST_CHECK(!HexColorSetUtil::InSet(BLACK, EMPTY_ONLY)); 00093 BOOST_CHECK( HexColorSetUtil::InSet(WHITE, NOT_BLACK)); 00094 BOOST_CHECK(!HexColorSetUtil::InSet(WHITE, NOT_WHITE)); 00095 BOOST_CHECK( HexColorSetUtil::InSet(EMPTY, NOT_WHITE)); 00096 BOOST_CHECK( HexColorSetUtil::InSet(BLACK, NOT_EMPTY)); 00097 BOOST_CHECK( HexColorSetUtil::InSet(WHITE, NOT_EMPTY)); 00098 BOOST_CHECK(!HexColorSetUtil::InSet(EMPTY, NOT_EMPTY)); 00099 BOOST_CHECK( HexColorSetUtil::InSet(BLACK, ALL_COLORS)); 00100 BOOST_CHECK( HexColorSetUtil::InSet(WHITE, ALL_COLORS)); 00101 BOOST_CHECK( HexColorSetUtil::InSet(EMPTY, ALL_COLORS)); 00102 } 00103 00104 BOOST_AUTO_TEST_CASE(HexColorSet_ColorToColorSet) 00105 { 00106 BOOST_CHECK_EQUAL(HexColorSetUtil::Only(BLACK), BLACK_ONLY); 00107 BOOST_CHECK_EQUAL(HexColorSetUtil::Only(WHITE), WHITE_ONLY); 00108 BOOST_CHECK_EQUAL(HexColorSetUtil::Only(EMPTY), EMPTY_ONLY); 00109 BOOST_CHECK_EQUAL(HexColorSetUtil::NotColor(BLACK), NOT_BLACK); 00110 BOOST_CHECK_EQUAL(HexColorSetUtil::NotColor(WHITE), NOT_WHITE); 00111 BOOST_CHECK_EQUAL(HexColorSetUtil::NotColor(EMPTY), NOT_EMPTY); 00112 BOOST_CHECK_EQUAL(HexColorSetUtil::ColorOrEmpty(BLACK), NOT_WHITE); 00113 BOOST_CHECK_EQUAL(HexColorSetUtil::ColorOrEmpty(WHITE), NOT_BLACK); 00114 BOOST_CHECK_EQUAL(HexColorSetUtil::ColorOrEmpty(EMPTY), EMPTY_ONLY); 00115 } 00116 00117 } 00118 00119 //---------------------------------------------------------------------------