diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/src/cgeo/geocaching/connector/gc/GCBaseTest.java | 13 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/connector/gc/UTFGridPositionTest.java | 34 |
2 files changed, 34 insertions, 13 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCBaseTest.java b/tests/src/cgeo/geocaching/connector/gc/GCBaseTest.java index d70ab9b..29fd886 100644 --- a/tests/src/cgeo/geocaching/connector/gc/GCBaseTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/GCBaseTest.java @@ -14,19 +14,6 @@ import junit.framework.TestCase; public class GCBaseTest extends TestCase { - public static void testSplitJSONKey() { - assertKey("(1, 2)", 1, 2); - assertKey("(12, 34)", 12, 34); - assertKey("(1234,56)", 1234, 56); - assertKey("(1234, 567)", 1234, 567); - } - - private static void assertKey(String key, int x, int y) { - final UTFGridPosition pos = UTFGridPosition.fromString(key); - assertEquals(x, pos.getX()); - assertEquals(y, pos.getY()); - } - public static void testSearchFromMap() { final MockedCache mockedCache = new GC2CJPF(); diff --git a/tests/src/cgeo/geocaching/connector/gc/UTFGridPositionTest.java b/tests/src/cgeo/geocaching/connector/gc/UTFGridPositionTest.java new file mode 100644 index 0000000..a742faf --- /dev/null +++ b/tests/src/cgeo/geocaching/connector/gc/UTFGridPositionTest.java @@ -0,0 +1,34 @@ +package cgeo.geocaching.connector.gc; + +import junit.framework.TestCase; + +public class UTFGridPositionTest extends TestCase { + + public static void testValidUTFGridPosition() { + assertNotNull(new UTFGridPosition(0, 0)); + } + + public static void testInvalidUTFGridPosition() { + boolean valid = true; + try { + assertNotNull(new UTFGridPosition(-1, 0)); + } catch (Exception e) { + valid = false; + } + assertFalse(valid); + } + + public static void testFromString() throws Exception { + assertXYFromString("(1, 2)", 1, 2); + assertXYFromString("(12, 34)", 12, 34); + assertXYFromString("(34,56)", 34, 56); + assertXYFromString("(34, 56)", 34, 56); + } + + private static void assertXYFromString(final String key, int x, int y) { + final UTFGridPosition pos = UTFGridPosition.fromString(key); + assertEquals(x, pos.getX()); + assertEquals(y, pos.getY()); + } + +} |
