2004-12-14 15:29:20 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: tests/geometry/size.cpp
|
|
|
|
// Purpose: wxSize unit test
|
2004-12-14 15:29:21 -05:00
|
|
|
// Author: Wlodzimierz ABX Skiba
|
2004-12-14 15:29:20 -05:00
|
|
|
// Created: 2004-12-14
|
|
|
|
// Copyright: (c) 2004 wxWindows
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "testprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/gdicmn.h"
|
|
|
|
#endif // WX_PRECOMP
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// test class
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class SizeTestCase : public CppUnit::TestCase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SizeTestCase() { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
CPPUNIT_TEST_SUITE( SizeTestCase );
|
|
|
|
CPPUNIT_TEST( Operators );
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
|
|
|
|
void Operators();
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_NO_COPY_CLASS(SizeTestCase);
|
2004-12-14 15:29:20 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// register in the unnamed registry so that these tests are run by default
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( SizeTestCase );
|
|
|
|
|
2011-04-30 06:57:04 -04:00
|
|
|
// also include in its own registry so that these tests can be run alone
|
2004-12-14 15:29:20 -05:00
|
|
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SizeTestCase, "SizeTestCase" );
|
|
|
|
|
|
|
|
void SizeTestCase::Operators()
|
|
|
|
{
|
|
|
|
wxSize s1(1,2);
|
|
|
|
wxSize s2(3,4);
|
|
|
|
wxSize s3;
|
|
|
|
|
|
|
|
s3 = s1 + s2;
|
|
|
|
CPPUNIT_ASSERT( s3.GetWidth()==4 && s3.GetHeight()==6 );
|
|
|
|
s3 = s2 - s1;
|
|
|
|
CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==2 );
|
|
|
|
s3 = s1 * 2;
|
|
|
|
CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
|
2007-05-23 21:47:29 -04:00
|
|
|
s3 = 2 * s1;
|
|
|
|
CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
|
2004-12-14 15:29:20 -05:00
|
|
|
s3 = s3 / 2;
|
|
|
|
CPPUNIT_ASSERT( s3.GetWidth()==1 && s3.GetHeight()==2 );
|
|
|
|
|
|
|
|
s3 = s2;
|
|
|
|
CPPUNIT_ASSERT( s3 != s1 );
|
|
|
|
s3 = s1;
|
|
|
|
CPPUNIT_ASSERT( s3 == s1 );
|
|
|
|
s3 += s2;
|
|
|
|
CPPUNIT_ASSERT( s3.GetWidth()==4 && s3.GetHeight()==6 );
|
|
|
|
s3 -= s2;
|
|
|
|
CPPUNIT_ASSERT( s3 == s1 );
|
|
|
|
s3 *= 2;
|
|
|
|
CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
|
|
|
|
s3 /= 2;
|
|
|
|
CPPUNIT_ASSERT( s3 == s1 );
|
|
|
|
}
|