]>
git.saurik.com Git - wxWidgets.git/blob - tests/geometry/rect.cpp
85954dd277a95948cb2048123efa2235897ea53b
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/geometry/rect.cpp
3 // Purpose: wxRect unit test
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2004 wxWindows
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
23 #include "wx/gdicmn.h"
25 // ----------------------------------------------------------------------------
27 // ----------------------------------------------------------------------------
29 class RectTestCase
: public CppUnit::TestCase
35 CPPUNIT_TEST_SUITE( RectTestCase
);
36 CPPUNIT_TEST( Union
);
37 CPPUNIT_TEST_SUITE_END();
41 DECLARE_NO_COPY_CLASS(RectTestCase
)
44 // register in the unnamed registry so that these tests are run by default
45 CPPUNIT_TEST_SUITE_REGISTRATION( RectTestCase
);
47 // also include in it's own registry so that these tests can be run alone
48 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RectTestCase
, "RectTestCase" );
50 void RectTestCase::Union()
52 static const struct RectData
58 wxRect
GetFirst() const { return wxRect(x1
, y1
, w1
, h1
); }
59 wxRect
GetSecond() const { return wxRect(x2
, y2
, w2
, h2
); }
60 wxRect
GetResult() const { return wxRect(x
, y
, w
, h
); }
63 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
64 { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
65 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
66 { 1, 1, 1, 1, 4, 4, 1, 1, 1, 1, 4, 4 },
67 { 1, 1, 2, 2, 4, 4, 1, 1, 1, 1, 4, 4 },
68 { 2, 2, 2, 2, 4, 4, 4, 4, 2, 2, 6, 6 },
69 { 1, 1, 4, 4, 4, 4, 1, 1, 1, 1, 4, 4 },
72 for ( size_t n
= 0; n
< WXSIZEOF(s_rects
); n
++ )
74 const RectData
& data
= s_rects
[n
];
77 data
.GetFirst().Union(data
.GetSecond()) == data
.GetResult()
81 data
.GetSecond().Union(data
.GetFirst()) == data
.GetResult()