package cgeo.geocaching.location;

import org.junit.Assert;
import org.junit.Test;

/**
 * Test the UTMPoint parsing and formatting.
 */
public class UTMPointFormatTest {

    @Test
    public static void testParseUTMStringSimple() {
        final UTMPoint utm = new UTMPoint("54S 293848 3915114");

        Assert.assertEquals(54, utm.getZoneNumber());
        Assert.assertEquals('S', utm.getZoneLetter());
        Assert.assertEquals(293848, utm.getEasting(), 1.1d);
        Assert.assertEquals(3915114, utm.getNorthing(), 1.1d);
    }

    @Test
    public static void testParseUTMStringWithEandN() {
        final UTMPoint utm = new UTMPoint("54S E 293848 N 3915114");

        Assert.assertEquals(54, utm.getZoneNumber());
        Assert.assertEquals('S', utm.getZoneLetter());
        Assert.assertEquals(293848, utm.getEasting(), 1.1d);
        Assert.assertEquals(3915114, utm.getNorthing(), 1.1d);
    }

    @Test
    public static void testParseUTMStringWithDecimals() {
        final UTMPoint utm = new UTMPoint("54S 293848.4 3915114.5");

        Assert.assertEquals(54, utm.getZoneNumber());
        Assert.assertEquals('S', utm.getZoneLetter());
        Assert.assertEquals(293848.4, utm.getEasting(), 1.1d);
        Assert.assertEquals(3915114.5, utm.getNorthing(), 1.1d);
    }

    @Test
    public static void testParseUTMStringWithLowerCaseLetters() {
        final UTMPoint utm = new UTMPoint("54s e 293848 n 3915114");

        Assert.assertEquals(54, utm.getZoneNumber());
        Assert.assertEquals('S', utm.getZoneLetter());
        Assert.assertEquals(293848, utm.getEasting(), 1.1d);
        Assert.assertEquals(3915114, utm.getNorthing(), 1.1d);
    }

    @Test
    public static void testParseUTMStringWithCommaAsDecimalSeparator() {
        final UTMPoint utm = new UTMPoint("54S 293848,4 3915114,5");

        Assert.assertEquals(54, utm.getZoneNumber());
        Assert.assertEquals('S', utm.getZoneLetter());
        Assert.assertEquals(293848.4, utm.getEasting(), 1.1d);
        Assert.assertEquals(3915114.5, utm.getNorthing(), 1.1d);
    }

    @Test
    public static void testParseUTMStringWithBlankAfterZoneNumber() {
        final UTMPoint utm = new UTMPoint("54 S 293848 3915114");

        Assert.assertEquals(54, utm.getZoneNumber());
        Assert.assertEquals('S', utm.getZoneLetter());
        Assert.assertEquals(293848, utm.getEasting(), 1.1d);
        Assert.assertEquals(3915114, utm.getNorthing(), 1.1d);
    }

    @Test
    public static void testParseUTMStringWithSingleDigitZoneNumber() {
        final UTMPoint utm = new UTMPoint("5S 293848 3915114");

        Assert.assertEquals(5, utm.getZoneNumber());
        Assert.assertEquals('S', utm.getZoneLetter());
        Assert.assertEquals(293848, utm.getEasting(), 1.1d);
        Assert.assertEquals(3915114, utm.getNorthing(), 1.1d);
    }

    @SuppressWarnings("unused")
    @Test(expected = UTMPoint.ParseException.class)
    public static void testParseUTMStringWithException() {
        new UTMPoint("5S blah blub");
    }

    @Test
    public static void testToString() {
        Assert.assertEquals("54S E 293848 N 3915114", new UTMPoint(54, 'S', 293848, 3915114).toString());
    }

    @Test
    public static void testToStringWithRoundedDecimals() {
        Assert.assertEquals("54S E 293848 N 3915114", new UTMPoint(54, 'S', 293847.5, 3915114.3).toString());
    }

}

@@ -178,39 +178,32 @@
 Test%0A    public 
-static 
 void testParseUT
@@ -216,24 +216,24 @@
 gSimple() %7B%0A
+
         fina
@@ -539,39 +539,32 @@
 Test%0A    public 
-static 
 void testParseUT
@@ -907,39 +907,32 @@
 Test%0A    public 
-static 
 void testParseUT
@@ -1282,39 +1282,32 @@
 Test%0A    public 
-static 
 void testParseUT
@@ -1661,39 +1661,32 @@
 Test%0A    public 
-static 
 void testParseUT
@@ -2051,39 +2051,32 @@
 Test%0A    public 
-static 
 void testParseUT
@@ -2431,39 +2431,32 @@
 Test%0A    public 
-static 
 void testParseUT
@@ -2800,40 +2800,8 @@
  %7D%0A%0A
-    @SuppressWarnings(%22unused%22)%0A
     
@@ -2851,39 +2851,32 @@
 ass)%0A    public 
-static 
 void testParseUT
@@ -2958,39 +2958,32 @@
 Test%0A    public 
-static 
 void testToStrin
@@ -3103,32 +3103,32 @@
    %7D%0A%0A    @Test%0A
+
     public stati
@@ -3126,15 +3126,8 @@
 lic 
-static 
 void

revert to non static test methods