1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
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.
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.
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/>.
23
//---------------------------------------------------------------------------
31
#include <cxxtest/TestSuite.h>
33
#include "../WColor.h"
34
#include "WColorTraits.h"
37
* Unit tests the color helping functions
39
class WColorTest : public CxxTest::TestSuite
44
* Red in HSV is ( 0, 1, 1 ) and in RGB ( 1, 0, 0 )
45
* Green in HSV is ( 0.3, 1, 1 ) and in RGB ( 0, 1, 0 )
46
* and checks some dark green
48
void testHSVConversion( void )
50
WColor c = convertHSVtoRGBA( 0, 1, 1 );
51
TS_ASSERT_DELTA( c[0], 1, 0.00001 );
52
TS_ASSERT_DELTA( c[1], 0, 0.00001 );
53
TS_ASSERT_DELTA( c[2], 0, 0.00001 );
54
c = convertHSVtoRGBA( 1, 1, 1 ); // this is also red
55
TS_ASSERT_DELTA( c[0], 1, 0.00001 );
56
TS_ASSERT_DELTA( c[1], 0, 0.00001 );
57
TS_ASSERT_DELTA( c[2], 0, 0.00001 );
58
c = convertHSVtoRGBA( 1.0 / 3.0, 1, 1 );
59
TS_ASSERT_DELTA( c[0], 0, 0.00001 );
60
TS_ASSERT_DELTA( c[1], 1, 0.00001 );
61
TS_ASSERT_DELTA( c[2], 0, 0.00001 );
62
c = convertHSVtoRGBA( 0.3, 0.3, 0.3 ); // dark green
63
TS_ASSERT_DELTA( c[0], 0.2280, 0.0001 );
64
TS_ASSERT_DELTA( c[1], 0.3, 0.0001 );
65
TS_ASSERT_DELTA( c[2], 0.2099, 0.0001 );
69
#endif // WCOLOR_TEST_H