]> git.saurik.com Git - wxWidgets.git/blame - tests/geometry/size.cpp
fixed Inflate() to not move the rectangle (patch 1114622)
[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 );
61 s3 = s3 / 2;
62 CPPUNIT_ASSERT( s3.GetWidth()==1 && s3.GetHeight()==2 );
63
64 s3 = s2;
65 CPPUNIT_ASSERT( s3 != s1 );
66 s3 = s1;
67 CPPUNIT_ASSERT( s3 == s1 );
68 s3 += s2;
69 CPPUNIT_ASSERT( s3.GetWidth()==4 && s3.GetHeight()==6 );
70 s3 -= s2;
71 CPPUNIT_ASSERT( s3 == s1 );
72 s3 *= 2;
73 CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
74 s3 /= 2;
75 CPPUNIT_ASSERT( s3 == s1 );
76}