added wxRect::operator+() and *() (union and intersection); also made other operators friends instead of members (patch 1589175)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46191 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -87,6 +87,10 @@ void PointTestCase::Operators()
|
||||
p6 = p2; p6 = p2 - s;
|
||||
CPPUNIT_ASSERT( p3 == p5 );
|
||||
CPPUNIT_ASSERT( p4 == p6 );
|
||||
p5 = p2; p5 = s + p2;
|
||||
p6 = p2; p6 = s - p2;
|
||||
CPPUNIT_ASSERT( p3 == p5 );
|
||||
CPPUNIT_ASSERT( p4 == -p6 );
|
||||
p5 = p2; p5 += s;
|
||||
p6 = p2; p6 -= s;
|
||||
CPPUNIT_ASSERT( p3 == p5 );
|
||||
|
@@ -129,6 +129,14 @@ void RectTestCase::Operators()
|
||||
( data.GetSecond() + data.GetFirst() ) == data.GetResult()
|
||||
);
|
||||
}
|
||||
|
||||
// test operator*() which returns the intersection of two rectangles
|
||||
wxRect r1 = wxRect(0, 2, 3, 4);
|
||||
wxRect r2 = wxRect(1, 2, 7, 8);
|
||||
r1 *= r2;
|
||||
CPPUNIT_ASSERT(wxRect(1, 2, 2, 4) == r1);
|
||||
|
||||
CPPUNIT_ASSERT( (r1 * wxRect()).IsEmpty() );
|
||||
}
|
||||
|
||||
void RectTestCase::Union()
|
||||
|
@@ -58,6 +58,8 @@ void SizeTestCase::Operators()
|
||||
CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==2 );
|
||||
s3 = s1 * 2;
|
||||
CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
|
||||
s3 = 2 * s1;
|
||||
CPPUNIT_ASSERT( s3.GetWidth()==2 && s3.GetHeight()==4 );
|
||||
s3 = s3 / 2;
|
||||
CPPUNIT_ASSERT( s3.GetWidth()==1 && s3.GetHeight()==2 );
|
||||
|
||||
|
Reference in New Issue
Block a user