This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sean Gillies
committed
Nov 30, 2015
1 parent
4d6c20e
commit 0ffa7ed
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import unittest | ||
|
||
from mapbox.polyline.codec import PolylineCodec | ||
|
||
|
||
class PolylineCodecTestCase(unittest.TestCase): | ||
def setUp(self): | ||
self.codec = PolylineCodec() | ||
|
||
def test_decode_multiple_points(self): | ||
d = self.codec.decode('gu`wFnfys@???nKgE??gE?????oK????fE??fE') | ||
self.assertEqual(d, [ | ||
(40.641, -8.654), | ||
(40.641, -8.654), | ||
(40.641, -8.656), | ||
(40.642, -8.656), | ||
(40.642, -8.655), | ||
(40.642, -8.655), | ||
(40.642, -8.655), | ||
(40.642, -8.653), | ||
(40.642, -8.653), | ||
(40.642, -8.653), | ||
(40.641, -8.653), | ||
(40.641, -8.654) | ||
]) | ||
|
||
def test_decode_official_example(self): | ||
d = self.codec.decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@') | ||
self.assertEqual(d, [ | ||
(38.500, -120.200), | ||
(40.700, -120.950), | ||
(43.252, -126.453) | ||
]) | ||
|
||
def test_decode_single_point(self): | ||
d = self.codec.decode('gu`wFf`ys@') | ||
self.assertEqual(d, [ | ||
(40.641, -8.653) | ||
]) | ||
|
||
def test_encode_multiple_points(self): | ||
e = self.codec.encode([ | ||
(40.641, -8.654), | ||
(40.641, -8.654), | ||
(40.641, -8.656), | ||
(40.642, -8.656), | ||
(40.642, -8.655), | ||
(40.642, -8.655), | ||
(40.642, -8.655), | ||
(40.642, -8.653), | ||
(40.642, -8.653), | ||
(40.642, -8.653), | ||
(40.641, -8.653), | ||
(40.641, -8.654) | ||
]) | ||
self.assertEqual(e, 'gu`wFnfys@???nKgE??gE?????oK????fE??fE') | ||
|
||
def test_encode_official_example(self): | ||
e = self.codec.encode([ | ||
(38.500, -120.200), | ||
(40.700, -120.950), | ||
(43.252, -126.453) | ||
]) | ||
self.assertEqual(e, '_p~iF~ps|U_ulLnnqC_mqNvxq`@') | ||
|
||
def test_encode_single_point(self): | ||
e = self.codec.encode([ | ||
(40.641, -8.653) | ||
]) | ||
self.assertEqual(e, 'gu`wFf`ys@') |