]>
git.saurik.com Git - wxWidgets.git/blob - tests/geometry/point.cpp
32b46c7700d43d918435c70dd30b2b35f5b80cfb
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"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class PointTestCase
: public CppUnit::TestCase
36 CPPUNIT_TEST_SUITE( PointTestCase
);
37 CPPUNIT_TEST( Operators
);
38 CPPUNIT_TEST_SUITE_END();
42 DECLARE_NO_COPY_CLASS(PointTestCase
)
45 class RealPointTestCase
: public CppUnit::TestCase
48 RealPointTestCase() { }
51 CPPUNIT_TEST_SUITE( RealPointTestCase
);
52 CPPUNIT_TEST( Operators
);
53 CPPUNIT_TEST_SUITE_END();
57 DECLARE_NO_COPY_CLASS(RealPointTestCase
)
60 // register in the unnamed registry so that these tests are run by default
61 CPPUNIT_TEST_SUITE_REGISTRATION( PointTestCase
);
62 CPPUNIT_TEST_SUITE_REGISTRATION( RealPointTestCase
);
64 // also include in its own registry so that these tests can be run alone
65 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PointTestCase
, "PointTestCase" );
66 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RealPointTestCase
, "RealPointTestCase" );
68 void PointTestCase::Operators()
76 CPPUNIT_ASSERT( p3
.x
== p5
.x
&& p3
.y
== p5
.y
);
77 CPPUNIT_ASSERT( p4
.x
== p6
.x
&& p4
.y
== p6
.y
);
78 CPPUNIT_ASSERT( p3
== p5
);
79 CPPUNIT_ASSERT( p4
== p6
);
80 CPPUNIT_ASSERT( p3
!= p4
);
83 CPPUNIT_ASSERT( p3
== p5
);
84 CPPUNIT_ASSERT( p4
== p6
);
88 CPPUNIT_ASSERT( p3
== p5
);
89 CPPUNIT_ASSERT( p4
== p6
);
92 CPPUNIT_ASSERT( p3
== p5
);
93 CPPUNIT_ASSERT( p4
== -p6
);
96 CPPUNIT_ASSERT( p3
== p5
);
97 CPPUNIT_ASSERT( p4
== p6
);
100 void RealPointTestCase::Operators()
102 const double EPSILON
= 0.00001;
103 wxRealPoint
p1(1.2,3.4);
104 wxRealPoint
p2(8.7,5.4);
105 wxRealPoint
p3(9.9,8.8);
106 wxRealPoint
p4(7.5,2.0);
107 wxRealPoint p5
= p2
+ p1
;
108 wxRealPoint p6
= p2
- p1
;
110 CPPUNIT_ASSERT( p3 == p5 );
111 CPPUNIT_ASSERT( p4 == p6 );
112 CPPUNIT_ASSERT( p3 != p4 );
114 CPPUNIT_ASSERT( fabs( p3
.x
- p5
.x
) < EPSILON
&& fabs( p3
.y
- p5
.y
) < EPSILON
);
115 CPPUNIT_ASSERT( fabs( p4
.x
- p6
.x
) < EPSILON
&& fabs( p4
.y
- p6
.y
) < EPSILON
);