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)
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)
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)
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)
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)
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)
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))
def testOverloadMethodReceivingRelatedContainerTypes(self): self.assertEqual(ListUser.ListOfPointF, ListUser.listOfPoints([PointF()])) self.assertEqual(ListUser.ListOfPoint, ListUser.listOfPoints([Point()]))