diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2013-01-13 08:15:14 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2013-01-13 08:15:14 +0100 |
commit | 6e66c8f2da1d6893e2d9e100957a966bc3f9e69a (patch) | |
tree | 68ebc5a56b37fce66666cba53b0e724d00818733 /tests/src/cgeo/geocaching/geopoint | |
parent | f7a00e91647494e6a66d304bbee4862d0b637e3c (diff) | |
download | cgeo-6e66c8f2da1d6893e2d9e100957a966bc3f9e69a.zip cgeo-6e66c8f2da1d6893e2d9e100957a966bc3f9e69a.tar.gz cgeo-6e66c8f2da1d6893e2d9e100957a966bc3f9e69a.tar.bz2 |
fix #2389: Parse errors in cgeocoords
Diffstat (limited to 'tests/src/cgeo/geocaching/geopoint')
-rw-r--r-- | tests/src/cgeo/geocaching/geopoint/GeopointTest.java | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java index 93b1339..1401cb6 100644 --- a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java +++ b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java @@ -1,10 +1,10 @@ package cgeo.geocaching.geopoint; -import junit.framework.Assert; - import android.os.Bundle; import android.test.AndroidTestCase; +import junit.framework.Assert; + public class GeopointTest extends AndroidTestCase { public static void testCreation() { @@ -234,4 +234,67 @@ public class GeopointTest extends AndroidTestCase { assertEquals(125.663703918457, (new Geopoint(48.0, 2.0)).getElevation(), 0.1); } + private static void assertParseException(Runnable runnable) { + try { + runnable.run(); + Assert.fail("Should have thrown Geopoint.ParseException"); + } catch (Geopoint.ParseException e) { + //success + } + } + + public static void testParseParam1() { + assertParseException(new Runnable() { + + @SuppressWarnings("unused") + @Override + public void run() { + new Geopoint("some nonsense text"); + } + }); + } + + public static void testParseParam2() throws Exception { + assertParseException(new Runnable() { + + @SuppressWarnings("unused") + @Override + public void run() { + new Geopoint("latitude", "longitude"); + } + }); + } + + public static void testParseParam6() throws Exception { + assertParseException(new Runnable() { + + @SuppressWarnings("unused") + @Override + public void run() { + new Geopoint("latDir", "latDeg", "latDegFrac", "lonDir", "lonDeg", "lonDegFrac"); + } + }); + } + + public static void testParseParam8() throws Exception { + assertParseException(new Runnable() { + + @SuppressWarnings("unused") + @Override + public void run() { + new Geopoint("latDir", "latDeg", "latMin", "latMinFrac", "lonDir", "lonDeg", "lonMin", "lonMinFrac"); + } + }); + } + + public static void testParseParam10() throws Exception { + assertParseException(new Runnable() { + + @SuppressWarnings("unused") + @Override + public void run() { + new Geopoint("latDir", "latDeg", "latMin", "latSec", "latSecFrac", "lonDir", "lonDeg", "lonMin", "lonSec", "lonSecFrac"); + } + }); + } } |