예제 #1
0
 def testDrawTextPointAndStr(self):
     overload = Overload()
     self.assertEqual(overload.drawText(Point(), Str()), Overload.Function0)
     self.assertEqual(overload.drawText(Point(), ''), Overload.Function0)
     self.assertEqual(overload.drawText(PointF(), Str()),
                      Overload.Function1)
     self.assertEqual(overload.drawText(PointF(), ''), Overload.Function1)
예제 #2
0
 def testEqualOperator(self):
     '''Test PointF class == operator.'''
     pt1 = PointF(5.0, 2.3)
     pt2 = PointF(5.0, 2.3)
     pt3 = PointF(0.5, 3.2)
     self.assertTrue(pt1 == pt1)
     self.assertTrue(pt1 == pt2)
     self.assertFalse(pt1 == pt3)
예제 #3
0
 def testNumpyAsIs(self):
     x, y = (0.1, 0.2)
     p = PointF(numpy.float32(x), numpy.float32(y))
     self.assertAlmostEqual(p.x(), x)
     self.assertAlmostEqual(p.y(), y)
예제 #4
0
 def testNumpyConverted(self):
     x, y = (0.1, 0.2)
     p = PointF(float(numpy.float32(x)), float(numpy.float32(y)))
     self.assertAlmostEqual(p.x(), x)
     self.assertAlmostEqual(p.y(), y)
예제 #5
0
 def testModifiedMethod(self):
     pt1 = PointF(0.0, 0.0)
     pt2 = PointF(10.0, 10.0)
     expected = PointF((pt1.x() + pt2.x()) / 2.0, (pt1.y() + pt2.y()) / 2.0)
     self.assertEqual(pt1.midpoint(pt2), expected)
예제 #6
0
 def testConstructor(self):
     '''Test PointF class constructor.'''
     pt = PointF(5.0, 2.3)
     self.assertEqual(pt.x(), 5.0)
     self.assertEqual(pt.y(), 2.3)
예제 #7
0
 def testPlusOperator(self):
     '''Test PointF class + operator.'''
     pt1 = PointF(5.0, 2.3)
     pt2 = PointF(0.5, 3.2)
     self.assertEqual(pt1 + pt2, PointF(5.0 + 0.5, 2.3 + 3.2))
예제 #8
0
 def testOverloadMethodReceivingRelatedContainerTypes(self):
     self.assertEqual(ListUser.ListOfPointF, ListUser.listOfPoints([PointF()]))
     self.assertEqual(ListUser.ListOfPoint, ListUser.listOfPoints([Point()]))
예제 #9
0
 def testNumpyAsIs(self):
     x, y = (0.1, 0.2)
     p = PointF(numpy.float32(x), numpy.float32(y))
     self.assertAlmostEqual(p.x(), x)
     self.assertAlmostEqual(p.y(), y)
예제 #10
0
 def testNumpyConverted(self):
     x, y = (0.1, 0.2)
     p = PointF(float(numpy.float32(x)), float(numpy.float32(y)))
     self.assertAlmostEqual(p.x(), x)
     self.assertAlmostEqual(p.y(), y)
예제 #11
0
 def testModifiedMethod(self):
     pt1 = PointF(0.0, 0.0)
     pt2 = PointF(10.0, 10.0)
     expected = PointF((pt1.x() + pt2.x()) / 2.0, (pt1.y() + pt2.y()) / 2.0)
     self.assertEqual(pt1.midpoint(pt2), expected)
예제 #12
0
 def testConstructor(self):
     '''Test PointF class constructor.'''
     pt = PointF(5.0, 2.3)
     self.assertEqual(pt.x(), 5.0)
     self.assertEqual(pt.y(), 2.3)