diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-02-28 22:16:38 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-02-28 22:16:38 +0100 |
| commit | 3b84568a8c300c6993928c5e8dfe5d038f94ce10 (patch) | |
| tree | d87ac3442462a15321fc3f6a49c3ff913d2d1b4a /tests | |
| parent | 2f8702fb5f2529a05ab239b480fbfd9afc0bed27 (diff) | |
| parent | 8df3d95d50180e8130342684afadb5d8d95616ac (diff) | |
| download | cgeo-3b84568a8c300c6993928c5e8dfe5d038f94ce10.zip cgeo-3b84568a8c300c6993928c5e8dfe5d038f94ce10.tar.gz cgeo-3b84568a8c300c6993928c5e8dfe5d038f94ce10.tar.bz2 | |
Merge branch 'release' into upstream
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/src/cgeo/geocaching/WaypointTest.java | 34 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java | 2 |
2 files changed, 35 insertions, 1 deletions
diff --git a/tests/src/cgeo/geocaching/WaypointTest.java b/tests/src/cgeo/geocaching/WaypointTest.java index 3ddc32c..9868f81 100644 --- a/tests/src/cgeo/geocaching/WaypointTest.java +++ b/tests/src/cgeo/geocaching/WaypointTest.java @@ -1,9 +1,12 @@ package cgeo.geocaching; import cgeo.geocaching.enumerations.WaypointType; +import cgeo.geocaching.geopoint.Geopoint; import android.test.AndroidTestCase; +import java.util.Collection; + public class WaypointTest extends AndroidTestCase { public static void testOrder() { @@ -42,4 +45,35 @@ public class WaypointTest extends AndroidTestCase { waypoint.setGeocode("p1"); assertEquals("P1", waypoint.getGeocode()); } + + public static void testParseNoWaypointFromNote() { + final String note = "1 T 126\n" + + "2 B 12\n" + + "3 S 630\n" + + "4c P 51\n" + + "L 1\n" + + "E 14\n" + + "J 11\n" + + "U 12\n" + + "D 1\n" + + "M 7\n" + + "N 5\n" + + "5 IFG 257"; + assertTrue(Waypoint.parseWaypointsFromNote(note).isEmpty()); + } + + public static void testParseWaypointFromNote() { + final String note = "Dummy note\nn 45° 3.5 e 27° 7.5\nNothing else"; + final Collection<Waypoint> waypoints = Waypoint.parseWaypointsFromNote(note); + assertEquals(1, waypoints.size()); + final Geopoint coords = waypoints.iterator().next().getCoords(); + assertEquals(45, coords.getLatDeg()); + assertEquals(3.5, coords.getLatMinRaw()); + assertEquals(27, coords.getLonDeg()); + assertEquals(7.5, coords.getLonMinRaw()); + final String note2 = "Waypoint on two lines\nN 45°3.5\nE 27°7.5\nNothing else"; + final Collection<Waypoint> waypoints2 = Waypoint.parseWaypointsFromNote(note2); + assertEquals(1, waypoints2.size()); + assertEquals(coords, waypoints2.iterator().next().getCoords()); + } } diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java index 28dbe77..1a24609 100644 --- a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java +++ b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java @@ -108,7 +108,7 @@ public class GeoPointParserTest extends AndroidTestCase { } public static void testMeridian() { - assertEquals(new Geopoint(123, 0), GeopointParser.parse("N 123° 00.000 00° 00.000")); + assertEquals(new Geopoint(23, 0), GeopointParser.parse("N 23° 00.000 00° 00.000")); } public static void testEquatorMeridian() { |
