diff --git a/modules/gfx/tests/test_color.cc b/modules/gfx/tests/test_color.cc index 8430f9c4d3865c72ad5e04ee77613cb3d1b53df7..88856fb1762fa5b636fc2f4ec449ea735865c62f 100644 --- a/modules/gfx/tests/test_color.cc +++ b/modules/gfx/tests/test_color.cc @@ -46,135 +46,137 @@ namespace { } } +#define FIXED_BOOST_WARN_CLOSE(F1,F2,F3) BOOST_WARN_CLOSE(static_cast<float>(F1), static_cast<float>(F2), static_cast<float>(F3)) + BOOST_AUTO_TEST_SUITE(gfx) BOOST_AUTO_TEST_CASE(default_color) { Color c; - BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetAlpha(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetAlpha(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); } BOOST_AUTO_TEST_CASE(set_rgb) { Color c; c = RGB(1.0f,0.0f,0.0f); // red - BOOST_WARN_CLOSE(c.GetAlpha(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),0.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetAlpha(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),0.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = RGB(1.0f,1.0f,0.0f); // yellow - BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),1.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),1.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = RGB(0.0f,1.0f,0.0f); // green - BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),2.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),2.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = RGB(0.0f,1.0f,1.0f); // cyan - BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),3.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),3.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = RGB(0.0f,0.0f,1.0f); // blue - BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),4.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),4.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = RGB(1.0f,0.0f,1.0f); // purple - BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),5.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),5.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); } BOOST_AUTO_TEST_CASE(set_hsv) { Color c; c = HSV(0.0f/6.0,1.0f,1.0f); // red - BOOST_WARN_CLOSE(c.GetAlpha(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),0.0f/6.0,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetAlpha(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),0.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = HSV(0.0f/6.0,0.5,1.0f); // light red - BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),0.5f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),0.5f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),0.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),0.5f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),0.5f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),0.5f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),0.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),0.5f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = HSV(1.0f/6.0,1.0f,1.0f); // yellow - BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),1.0f/6.0,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),1.0f/6.0,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = HSV(2.0/6.0,1.0f,1.0f); // green - BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),2.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),2.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = HSV(2.0/6.0,0.5,1.0f); // light green - BOOST_WARN_CLOSE(c.GetRed(),0.5f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),0.5f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),2.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),0.5f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),0.5f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),0.5f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),2.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),0.5f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = HSV(3.0/6.0,1.0f,1.0f); // cyan - BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),3.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),3.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = HSV(4.0/6.0,1.0f,1.0f); // blue - BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),4.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),4.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = HSV(4.0/6.0,0.5,1.0f); // light blue - BOOST_WARN_CLOSE(c.GetRed(),0.5f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),0.5f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),4.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),0.5f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),0.5f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),0.5f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),4.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),0.5f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); c = HSV(5.0/6.0,1.0f,1.0f); // purple - BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); - BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetHue(),5.0f/6.0f,tolerance); - BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); - BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetRed(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetGreen(),0.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetBlue(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetHue(),5.0f/6.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetSat(),1.0f,tolerance); + FIXED_BOOST_WARN_CLOSE(c.GetVal(),1.0f,tolerance); } BOOST_AUTO_TEST_CASE(set_char)