Changeset 9727 in josm


Ignore:
Timestamp:
2016-02-03T21:07:14+01:00 (6 years ago)
Author:
simon04
Message:

Add further CorrelateGpxWithImages unit tests

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r9726 r9727  
    13181318    }
    13191319
    1320     private static String formatTimezone(double timezone) {
     1320    static String formatTimezone(double timezone) {
    13211321        StringBuilder ret = new StringBuilder();
    13221322
     
    13371337    }
    13381338
    1339     private static double parseTimezone(String timezone) throws ParseException {
     1339    static double parseTimezone(String timezone) throws ParseException {
    13401340
    13411341        if (timezone.isEmpty())
     
    14081408    }
    14091409
    1410     private static long parseOffset(String offset) throws ParseException {
     1410    static long parseOffset(String offset) throws ParseException {
    14111411        String error = tr("Error while parsing offset.\nExpected format: {0}", "number");
    14121412
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java

    r9726 r9727  
    44import static org.junit.Assert.assertEquals;
    55
     6import java.text.ParseException;
    67import java.util.Arrays;
    78import java.util.Collections;
     
    7475        assertEquals(Pair.create(0.0, -4L), CorrelateGpxWithImages.autoGuess(Collections.singletonList(i0), gpx));
    7576    }
     77
     78    @Test
     79    public void testFormatTimezone() throws Exception {
     80        assertEquals("+1:00", CorrelateGpxWithImages.formatTimezone(1));
     81        assertEquals("+6:30", CorrelateGpxWithImages.formatTimezone(6.5));
     82        assertEquals("-6:30", CorrelateGpxWithImages.formatTimezone(-6.5));
     83        assertEquals("+3:08", CorrelateGpxWithImages.formatTimezone(Math.PI));
     84        assertEquals("+2:43", CorrelateGpxWithImages.formatTimezone(Math.E));
     85    }
     86
     87    @Test
     88    public void testParseTimezone() throws ParseException {
     89        assertEquals(1, CorrelateGpxWithImages.parseTimezone("+01:00"), 1e-3);
     90        assertEquals(1, CorrelateGpxWithImages.parseTimezone("+1:00"), 1e-3);
     91        assertEquals(1.5, CorrelateGpxWithImages.parseTimezone("+01:30"), 1e-3);
     92        assertEquals(11.5, CorrelateGpxWithImages.parseTimezone("+11:30"), 1e-3);
     93    }
     94
     95    @Test
     96    public void testParseOffest() throws ParseException {
     97        assertEquals(0, CorrelateGpxWithImages.parseOffset("0"));
     98        assertEquals(4242L, CorrelateGpxWithImages.parseOffset("4242"));
     99        assertEquals(-4242L, CorrelateGpxWithImages.parseOffset("-4242"));
     100        assertEquals(0L, CorrelateGpxWithImages.parseOffset("-0"));
     101    }
    76102}
Note: See TracChangeset for help on using the changeset viewer.