File: test_floatpoint.py

package info (click to toggle)
gamera 1:3.4.2+git20160808.1725654-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 22,312 kB
  • ctags: 24,991
  • sloc: xml: 122,324; ansic: 52,869; cpp: 50,664; python: 35,034; makefile: 118; sh: 101
file content (19 lines) | stat: -rw-r--r-- 496 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from gamera.gameracore import FloatPoint as FP
from math import sqrt

def test_floatpoint():
   p = FP(2, 3)
   assert p.x == 2.0 and p.y == 3.0

   assert FP(2, 2) + FP(1, 2) == FP(3, 4)
   assert FP(2, 2) * FP(2, 3) == FP(4, 6)
   assert FP(2, 2) - FP(2, 4) == FP(0, -2)
   assert FP(2, 2) / FP(2, 3) == FP(1, 2.0/3.0)

   assert FP(0, 0).distance(FP(-3, -3)) == sqrt(18)

   assert repr(FP(2, 3)) == "FloatPoint(2, 3)"

def test_floatpoint_leak():
   for i in xrange(1000):
      p = FP(i, i)