Skip to content

Commit b80aed5

Browse files
committed
add math module unit tests
1 parent 9596a2f commit b80aed5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_math.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import math
2+
13
import pathins.math
24
import pytest
35

@@ -26,6 +28,26 @@ def test_round_point():
2628
#
2729

2830

31+
def test_linear_distance_between_coordinates():
32+
tests = (
33+
[(0, 0), (40, 0), 40],
34+
[(0, 0), (0, 40), 40],
35+
[(0, 0), (10, 10), 14.1421356],
36+
[(0, 0), (0, 0), 0],
37+
[(0, 0), (-40, 0), 40],
38+
[(0, 0), (-10, -10), 14.1421356],
39+
)
40+
41+
for test in tests:
42+
test_result = pathins.math.linear_distance_between_coordinates(test[0], test[1])
43+
assert math.isclose(test_result, test[2], rel_tol=1e-3) is True
44+
45+
46+
#
47+
# pathins.math.midpoint_between_coordinates
48+
#
49+
50+
2951
def test_midpoint_between_coordinates():
3052
# test list definitions: [coord1, coord2, expected midpoint]
3153
tests = [

0 commit comments

Comments
 (0)