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