Changeset 18817 in josm for trunk/test/unit
- Timestamp:
- 2023-08-22T20:05:49+02:00 (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/io/GpxReaderTest.java
r18801 r18817 5 5 import static org.junit.jupiter.api.Assertions.assertThrows; 6 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 import static org.junit.jupiter.api.Assertions.fail; 7 8 8 9 import java.io.ByteArrayInputStream; … … 14 15 import java.util.Map; 15 16 17 import org.junit.jupiter.params.ParameterizedTest; 18 import org.junit.jupiter.params.provider.ValueSource; 16 19 import org.openstreetmap.josm.TestUtils; 17 20 import org.openstreetmap.josm.data.Bounds; … … 82 85 /** 83 86 * Tests invalid data. 84 * @throws Exception always SAXException85 87 */ 86 88 @Test 87 void testException() throws Exception{89 void testException() { 88 90 assertThrows(SAXException.class, 89 91 () -> new GpxReader(new ByteArrayInputStream("--foo--bar--".getBytes(StandardCharsets.UTF_8))).parse(true)); … … 100 102 GpxReaderTest.parseGpxData(TestUtils.getRegressionDataFile(15634, "drumlish.gpx")).getMetaBounds()); 101 103 } 104 105 @ParameterizedTest 106 @ValueSource(strings = { 107 "<gpx><wpt></wpt></gpx>", 108 }) 109 void testIncompleteLocations(String gpx) { 110 SAXException saxException = assertThrows(SAXException.class, 111 () -> new GpxReader(new ByteArrayInputStream(gpx.getBytes(StandardCharsets.UTF_8))).parse(true)); 112 final String type; 113 if ("<wpt>".regionMatches(0, gpx, 5, 4)) { 114 type = "wpt"; 115 } else { 116 fail("You need to add code to tell us what the exception for \"" + gpx + "\" should be"); 117 type = null; 118 } 119 assertEquals(type + " element does not have valid latitude and/or longitude.", saxException.getMessage()); 120 } 102 121 }
Note:
See TracChangeset
for help on using the changeset viewer.