OpenWalnut  1.5.0dev
WColor_test.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WCOLOR_TEST_H
26 #define WCOLOR_TEST_H
27 
28 #include <sstream>
29 #include <string>
30 
31 #include <cxxtest/TestSuite.h>
32 
33 #include "../WColor.h"
34 #include "WColorTraits.h"
35 
36 /**
37  * Unit tests the color helping functions
38  */
39 class WColorTest : public CxxTest::TestSuite
40 {
41 public:
42  /**
43  * Red in HSV is ( 0, 1, 1 ) and in RGB ( 1, 0, 0 )
44  * Green in HSV is ( 0.3, 1, 1 ) and in RGB ( 0, 1, 0 )
45  * and checks some dark green
46  */
47  void testHSVConversion( void )
48  {
49  WColor c = convertHSVtoRGBA( 0, 1, 1 );
50  TS_ASSERT_DELTA( c[0], 1, 0.00001 );
51  TS_ASSERT_DELTA( c[1], 0, 0.00001 );
52  TS_ASSERT_DELTA( c[2], 0, 0.00001 );
53  c = convertHSVtoRGBA( 1, 1, 1 ); // this is also red
54  TS_ASSERT_DELTA( c[0], 1, 0.00001 );
55  TS_ASSERT_DELTA( c[1], 0, 0.00001 );
56  TS_ASSERT_DELTA( c[2], 0, 0.00001 );
57  c = convertHSVtoRGBA( 1.0 / 3.0, 1, 1 );
58  TS_ASSERT_DELTA( c[0], 0, 0.00001 );
59  TS_ASSERT_DELTA( c[1], 1, 0.00001 );
60  TS_ASSERT_DELTA( c[2], 0, 0.00001 );
61  c = convertHSVtoRGBA( 0.3, 0.3, 0.3 ); // dark green
62  TS_ASSERT_DELTA( c[0], 0.2280, 0.0001 );
63  TS_ASSERT_DELTA( c[1], 0.3, 0.0001 );
64  TS_ASSERT_DELTA( c[2], 0.2099, 0.0001 );
65  }
66 };
67 
68 #endif // WCOLOR_TEST_H
Unit tests the color helping functions.
Definition: WColor_test.h:40
void testHSVConversion(void)
Red in HSV is ( 0, 1, 1 ) and in RGB ( 1, 0, 0 ) Green in HSV is ( 0.3, 1, 1 ) and in RGB ( 0,...
Definition: WColor_test.h:47