source: josm/trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxTimezoneTest.java

Last change on this file was 18853, checked in by taylor.smock, 16 months ago

See #16567: Update to JUnit 5

This removes new JOSMTestRules() with no additional setup and most
JOSMFixture calls.

Removing the bare JOSMTestRules speeds up the test suite since there are two
fewer System.gc() calls per test.

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.gpx;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5
6import java.text.ParseException;
7
8import org.junit.jupiter.api.Test;
9import org.openstreetmap.josm.testutils.annotations.Timezone;
10
11/**
12 * Unit tests of {@link GpxTimezone} class.
13 */
14@Timezone
15class GpxTimezoneTest {
16 /**
17 * Unit test of {@link GpxTimezone#formatTimezone}.
18 */
19 @Test
20 void testFormatTimezone() {
21 assertEquals("+1:00", new GpxTimezone(1).formatTimezone());
22 assertEquals("+6:30", new GpxTimezone(6.5).formatTimezone());
23 assertEquals("-6:30", new GpxTimezone(-6.5).formatTimezone());
24 assertEquals("+3:08", new GpxTimezone(Math.PI).formatTimezone());
25 assertEquals("+2:43", new GpxTimezone(Math.E).formatTimezone());
26 }
27
28 /**
29 * Unit test of {@link GpxTimezone#parseTimezone}.
30 * @throws ParseException in case of parsing error
31 */
32 @Test
33 void testParseTimezone() throws ParseException {
34 assertEquals(1, GpxTimezone.parseTimezone("+01:00").getHours(), 1e-3);
35 assertEquals(1, GpxTimezone.parseTimezone("+1:00").getHours(), 1e-3);
36 assertEquals(1.5, GpxTimezone.parseTimezone("+01:30").getHours(), 1e-3);
37 assertEquals(11.5, GpxTimezone.parseTimezone("+11:30").getHours(), 1e-3);
38 assertEquals(-11.5, GpxTimezone.parseTimezone("-11:30").getHours(), 1e-3);
39 }
40}
Note: See TracBrowser for help on using the repository browser.