Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frederickjansen committed Jun 26, 2019
1 parent 5e43466 commit 59495b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
flake8==2.2.4
nose==1.3.4
nose==1.3.7
coverage==4.5.3
18 changes: 17 additions & 1 deletion test/test_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ def test_decode_official_example(self):
(43.252, -126.453)
])

def test_decode_geojson(self):
d = polyline.decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@', geojson=True)
self.assertEqual(d, [
(-120.200, 38.500),
(-120.950, 40.700),
(-126.453, 43.252)
])

def test_decode_official_example_precision(self):
d = polyline.decode('_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI', 6)
self.assertEqual(d, [
Expand Down Expand Up @@ -111,6 +119,14 @@ def test_encode_official_example(self):
])
self.assertEqual(e, '_p~iF~ps|U_ulLnnqC_mqNvxq`@')

def test_encode_geojson(self):
e = polyline.encode([
(-120.200, 38.500),
(-120.950, 40.700),
(-126.453, 43.252)
], geojson=True)
self.assertEqual(e, '_p~iF~ps|U_ulLnnqC_mqNvxq`@')

def test_encode_official_example_precision(self):
e = polyline.encode([
(38.500, -120.200),
Expand Down Expand Up @@ -178,7 +194,7 @@ def generator():
else:
okays += 1

assert okays == waypoints
self.assertEqual(okays, waypoints)
print("encoded and decoded {0:.2f}% correctly for {1} waypoints @ {2} wp/sec".format(
100 * okays / float(waypoints),
waypoints,
Expand Down

0 comments on commit 59495b8

Please sign in to comment.