make the path view independent of type of connection
[mussa.git] / alg / test / test_color.cpp
1 #include <boost/test/auto_unit_test.hpp>
2 #include <boost/test/floating_point_comparison.hpp>
3 #include <string>
4 #include <sstream>
5
6 #include "alg/color.hpp"
7
8 using namespace std;
9
10 BOOST_AUTO_TEST_CASE ( color )
11 {
12   const float tolerance = 1e-6;
13   const float zero = 0.0;
14   const float dotone = 0.1;
15   const float dottwo = 0.2;
16   const float dotthree = 0.3;
17   const float dotfour = 0.4;
18   Color c1;
19   BOOST_CHECK_CLOSE (c1.r(), zero, tolerance );
20   BOOST_CHECK_CLOSE (c1.g(), zero, tolerance );
21   BOOST_CHECK_CLOSE (c1.b(), zero, tolerance );
22   BOOST_CHECK_CLOSE (c1.a(), zero, tolerance );
23
24   Color c2(dotone, dottwo, dotthree, dotfour);
25   BOOST_CHECK_CLOSE (c2.r(), dotone, tolerance );
26   BOOST_CHECK_CLOSE (c2.g(), dottwo, tolerance );
27   BOOST_CHECK_CLOSE (c2.b(), dotthree, tolerance );
28   BOOST_CHECK_CLOSE (c2.a(), dotfour, tolerance );
29
30   Color c3(c2);
31   BOOST_CHECK_CLOSE (c3.r(), dotone, tolerance );
32   BOOST_CHECK_CLOSE (c3.g(), dottwo, tolerance );
33   BOOST_CHECK_CLOSE (c3.b(), dotthree, tolerance );
34   BOOST_CHECK_CLOSE (c3.a(), dotfour, tolerance );
35   BOOST_CHECK_EQUAL ( c2, c3 );
36
37   const float *colors = c3.get();
38   BOOST_CHECK_CLOSE (colors[Color::RedChannel   ], dotone, tolerance );
39   BOOST_CHECK_CLOSE (colors[Color::GreenChannel ], dottwo, tolerance );
40   BOOST_CHECK_CLOSE (colors[Color::BlueChannel  ], dotthree, tolerance );
41   BOOST_CHECK_CLOSE (colors[Color::AlphaChannel ], dotfour, tolerance );
42 }