]> git.saurik.com Git - wxWidgets.git/blob - tests/geometry/size.cpp
using ordinary Show for popup windows as on MSW which activates it as well, I'll...
[wxWidgets.git] / tests / geometry / size.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/geometry/size.cpp
3 // Purpose: wxSize unit test
4 // Author: Wlodzimierz ABX Skiba
5 // Created: 2004-12-14
6 // RCS-ID: $Id$
7 // Copyright: (c) 2004 wxWindows
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ----------------------------------------------------------------------------
11 // headers
12 // ----------------------------------------------------------------------------
13
14 #include "testprec.h"
15
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19
20 #ifndef WX_PRECOMP
21 #include "wx/gdicmn.h"
22 #endif // WX_PRECOMP
23
24 // ----------------------------------------------------------------------------
25 // test class
26 // ----------------------------------------------------------------------------
27
28 class SizeTestCase : public CppUnit::TestCase
29 {
30 public:
31 SizeTestCase() { }
32
33 private:
34 CPPUNIT_TEST_SUITE( SizeTestCase );
35 CPPUNIT_TEST( Operators );
36 CPPUNIT_TEST_SUITE_END();
37
38 void Operators();
39
40 DECLARE_NO_COPY_CLASS(SizeTestCase)
41 };
42
43 // register in the unnamed registry so that these tests are run by default
44 CPPUNIT_TEST_SUITE_REGISTRATION( SizeTestCase );
45
46 // also include in its own registry so that these tests can be run alone
47 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SizeTestCase, "SizeTestCase" );
48
49 void SizeTestCase::Operators()
50 {
51 wxSize s1(1,2);
52 wxSize s2(3,4);
53 wxSize s3;
54
55 s3 = s1 + s2;
56 CPPUNIT_ASSERT( s3.GetWidth()==4 && s3.GetHeight()==6 );
57 s3 = s2 - s1;
58 CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==2 );
59 s3 = s1 * 2;
60 CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
61 s3 = 2 * s1;
62 CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
63 s3 = s3 / 2;
64 CPPUNIT_ASSERT( s3.GetWidth()==1 && s3.GetHeight()==2 );
65
66 s3 = s2;
67 CPPUNIT_ASSERT( s3 != s1 );
68 s3 = s1;
69 CPPUNIT_ASSERT( s3 == s1 );
70 s3 += s2;
71 CPPUNIT_ASSERT( s3.GetWidth()==4 && s3.GetHeight()==6 );
72 s3 -= s2;
73 CPPUNIT_ASSERT( s3 == s1 );
74 s3 *= 2;
75 CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
76 s3 /= 2;
77 CPPUNIT_ASSERT( s3 == s1 );
78 }