]>
git.saurik.com Git - wxWidgets.git/blob - tests/graphics/colour.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/graphics/colour.cpp
3 // Purpose: wxColour unit test
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
20 #include "wx/colour.h"
21 #include "asserthelper.h"
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 class ColourTestCase
: public CppUnit::TestCase
33 CPPUNIT_TEST_SUITE( ColourTestCase
);
34 CPPUNIT_TEST( GetSetRGB
);
35 CPPUNIT_TEST_SUITE_END();
39 DECLARE_NO_COPY_CLASS(ColourTestCase
)
42 // register in the unnamed registry so that these tests are run by default
43 CPPUNIT_TEST_SUITE_REGISTRATION( ColourTestCase
);
45 // also include in it's own registry so that these tests can be run alone
46 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ColourTestCase
, "ColourTestCase" );
48 void ColourTestCase::GetSetRGB()
53 CPPUNIT_ASSERT_EQUAL( 0x56, (int)c
.Red() );
54 CPPUNIT_ASSERT_EQUAL( 0x34, (int)c
.Green() );
55 CPPUNIT_ASSERT_EQUAL( 0x12, (int)c
.Blue() );
56 CPPUNIT_ASSERT_EQUAL( wxALPHA_OPAQUE
, c
.Alpha() );
58 CPPUNIT_ASSERT_EQUAL( wxColour(0x123456), c
);
59 CPPUNIT_ASSERT_EQUAL( 0x123456, c
.GetRGB() );
61 c
.SetRGBA(0xaabbccdd);
63 CPPUNIT_ASSERT_EQUAL( 0xdd, (int)c
.Red() );
64 CPPUNIT_ASSERT_EQUAL( 0xcc, (int)c
.Green() );
65 CPPUNIT_ASSERT_EQUAL( 0xbb, (int)c
.Blue() );
66 CPPUNIT_ASSERT_EQUAL( 0xaa, (int)c
.Alpha() );
68 // FIXME: at least under wxGTK wxColour ctor doesn't take alpha channel
69 // into account: bug or feature?
70 //CPPUNIT_ASSERT_EQUAL( wxColour(0xaabbccdd), c );
71 CPPUNIT_ASSERT_EQUAL( 0xbbccdd, c
.GetRGB() );
72 CPPUNIT_ASSERT_EQUAL( 0xaabbccdd, c
.GetRGBA() );