Changeset 9741 in josm for trunk/test/unit/org/openstreetmap


Ignore:
Timestamp:
2016-02-04T23:32:36+01:00 (9 years ago)
Author:
simon04
Message:

see #12486 - Gpx/image correlation: factor out classes Timezone, Offset

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java

    r9727 r9741  
    7373        i0.setExifTime(DateUtils.fromString("2016:01:03 11:59:54")); // 4 sec before start of GPX
    7474        i0.createTmp();
    75         assertEquals(Pair.create(0.0, -4L), CorrelateGpxWithImages.autoGuess(Collections.singletonList(i0), gpx));
     75        assertEquals(Pair.create(CorrelateGpxWithImages.Timezone.ZERO, CorrelateGpxWithImages.Offset.seconds(-4)),
     76                CorrelateGpxWithImages.autoGuess(Collections.singletonList(i0), gpx));
    7677    }
    7778
    7879    @Test
    7980    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));
     81        assertEquals("+1:00", new CorrelateGpxWithImages.Timezone(1).formatTimezone());
     82        assertEquals("+6:30", new CorrelateGpxWithImages.Timezone(6.5).formatTimezone());
     83        assertEquals("-6:30", new CorrelateGpxWithImages.Timezone(-6.5).formatTimezone());
     84        assertEquals("+3:08", new CorrelateGpxWithImages.Timezone(Math.PI).formatTimezone());
     85        assertEquals("+2:43", new CorrelateGpxWithImages.Timezone(Math.E).formatTimezone());
    8586    }
    8687
    8788    @Test
    8889    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);
     90        assertEquals(1, CorrelateGpxWithImages.Timezone.parseTimezone("+01:00").getHours(), 1e-3);
     91        assertEquals(1, CorrelateGpxWithImages.Timezone.parseTimezone("+1:00").getHours(), 1e-3);
     92        assertEquals(1.5, CorrelateGpxWithImages.Timezone.parseTimezone("+01:30").getHours(), 1e-3);
     93        assertEquals(11.5, CorrelateGpxWithImages.Timezone.parseTimezone("+11:30").getHours(), 1e-3);
     94    }
     95
     96    @Test
     97    public void testFormatOffest() throws ParseException {
     98        assertEquals("0", CorrelateGpxWithImages.Offset.seconds(0).formatOffset());
     99        assertEquals("123", CorrelateGpxWithImages.Offset.seconds(123).formatOffset());
     100        assertEquals("-4242", CorrelateGpxWithImages.Offset.seconds(-4242).formatOffset());
    93101    }
    94102
    95103    @Test
    96104    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"));
     105        assertEquals(0, CorrelateGpxWithImages.Offset.parseOffset("0").getSeconds());
     106        assertEquals(4242L, CorrelateGpxWithImages.Offset.parseOffset("4242").getSeconds());
     107        assertEquals(-4242L, CorrelateGpxWithImages.Offset.parseOffset("-4242").getSeconds());
     108        assertEquals(0L, CorrelateGpxWithImages.Offset.parseOffset("-0").getSeconds());
    101109    }
    102110}
Note: See TracChangeset for help on using the changeset viewer.