From 0f75b5d2c4d5edcf13fb4822231156f602c17bc4 Mon Sep 17 00:00:00 2001 From: Ansgar Philippsen <ansgar.philippsen@gmail.com> Date: Fri, 13 Jul 2012 13:59:10 -0400 Subject: [PATCH] fix for previous fix that failed to fix previous fix (all in the name of anal type checking) --- modules/gfx/tests/test_color.cc | 200 ++++++++++++++++---------------- 1 file changed, 101 insertions(+), 99 deletions(-) diff --git a/modules/gfx/tests/test_color.cc b/modules/gfx/tests/test_color.cc index 8430f9c4d..88856fb17 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) -- GitLab