]> git.saurik.com Git - wxWidgets.git/blame - tests/geometry/size.cpp
don't use WPARAM in the header (build fix after r59336)
[wxWidgets.git] / tests / geometry / size.cpp
CommitLineData
3e8f9a49
WS
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/geometry/size.cpp
3// Purpose: wxSize unit test
d76bb5b2 4// Author: Wlodzimierz ABX Skiba
3e8f9a49
WS
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
28class SizeTestCase : public CppUnit::TestCase
29{
30public:
31 SizeTestCase() { }
32
33private:
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
44CPPUNIT_TEST_SUITE_REGISTRATION( SizeTestCase );
45
46// also include in it's own registry so that these tests can be run alone
47CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SizeTestCase, "SizeTestCase" );
48
49void 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 );
bc5e942b
VZ
61 s3 = 2 * s1;
62 CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
3e8f9a49
WS
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}