]>
git.saurik.com Git - wxWidgets.git/blob - tests/geometry/point.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/geometry/point.cpp
3 // Purpose: wxPoint unit test
4 // Author: Wlodzimierz ABX Skiba
7 // Copyright: (c) 2004 wxWindows
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
21 #include "wx/gdicmn.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 class PointTestCase
: public CppUnit::TestCase
34 CPPUNIT_TEST_SUITE( PointTestCase
);
35 CPPUNIT_TEST( Operators
);
36 CPPUNIT_TEST_SUITE_END();
40 DECLARE_NO_COPY_CLASS(PointTestCase
)
43 class RealPointTestCase
: public CppUnit::TestCase
46 RealPointTestCase() { }
49 CPPUNIT_TEST_SUITE( RealPointTestCase
);
50 CPPUNIT_TEST( Operators
);
51 CPPUNIT_TEST_SUITE_END();
55 DECLARE_NO_COPY_CLASS(RealPointTestCase
)
58 // register in the unnamed registry so that these tests are run by default
59 CPPUNIT_TEST_SUITE_REGISTRATION( PointTestCase
);
60 CPPUNIT_TEST_SUITE_REGISTRATION( RealPointTestCase
);
62 // also include in it's own registry so that these tests can be run alone
63 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PointTestCase
, "PointTestCase" );
64 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RealPointTestCase
, "RealPointTestCase" );
66 void PointTestCase::Operators()
74 CPPUNIT_ASSERT( p3
.x
== p5
.x
&& p3
.y
== p5
.y
);
75 CPPUNIT_ASSERT( p4
.x
== p6
.x
&& p4
.y
== p6
.y
);
76 CPPUNIT_ASSERT( p3
== p5
);
77 CPPUNIT_ASSERT( p4
== p6
);
78 CPPUNIT_ASSERT( p3
!= p4
);
81 CPPUNIT_ASSERT( p3
== p5
);
82 CPPUNIT_ASSERT( p4
== p6
);
86 CPPUNIT_ASSERT( p3
== p5
);
87 CPPUNIT_ASSERT( p4
== p6
);
90 CPPUNIT_ASSERT( p3
== p5
);
91 CPPUNIT_ASSERT( p4
== p6
);
94 void RealPointTestCase::Operators()
96 const double EPSILON
= 0.00001;
97 wxRealPoint
p1(1.2,3.4);
98 wxRealPoint
p2(8.7,5.4);
99 wxRealPoint
p3(9.9,8.8);
100 wxRealPoint
p4(7.5,2.0);
101 wxRealPoint p5
= p2
+ p1
;
102 wxRealPoint p6
= p2
- p1
;
104 CPPUNIT_ASSERT( p3 == p5 );
105 CPPUNIT_ASSERT( p4 == p6 );
106 CPPUNIT_ASSERT( p3 != p4 );
108 CPPUNIT_ASSERT( fabs( p3
.x
- p5
.x
) < EPSILON
&& fabs( p3
.y
- p5
.y
) < EPSILON
);
109 CPPUNIT_ASSERT( fabs( p4
.x
- p6
.x
) < EPSILON
&& fabs( p4
.y
- p6
.y
) < EPSILON
);