Changeset 18826 in josm for trunk/test
- Timestamp:
- 2023-09-12T18:04:57+02:00 (14 months ago)
- Location:
- trunk/test
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/protobuf/ProtobufParserTest.java
r17867 r18826 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 import java.util.stream.Stream; 7 6 8 import org.junit.jupiter.api.Test; 9 import org.junit.jupiter.params.ParameterizedTest; 10 import org.junit.jupiter.params.provider.Arguments; 11 import org.junit.jupiter.params.provider.MethodSource; 7 12 8 13 /** … … 49 54 assertEquals(4_294_967_297L, ProtobufParser.encodeZigZag(Integer.MIN_VALUE - 1L).longValue()); 50 55 } 56 57 static Stream<Arguments> testDecode() { 58 return Stream.of( 59 Arguments.of(21L, 42L), 60 Arguments.of(9223372036854775785L, -46L) 61 ); 62 } 63 64 @ParameterizedTest 65 @MethodSource 66 void testDecode(long expected, long toDecode) { 67 assertEquals(expected, ProtobufParser.decodeZigZag(toDecode)); 68 } 69 70 static Stream<Arguments> testDecodeVarInt() { 71 return Stream.of( 72 Arguments.of(1, new int[] {0x01}), 73 Arguments.of(150, new int[] {0x96, 0x01}), 74 Arguments.of(9223372036854775806L, new int[] {0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}), 75 Arguments.of(Long.MAX_VALUE, new int[] {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}) 76 ); 77 } 78 79 @ParameterizedTest 80 @MethodSource 81 void testDecodeVarInt(long expected, int[] bytes) { 82 // Drop most significant bit 83 for (int i = 0; i < bytes.length; i++) { 84 bytes[i] = bytes[i] & 0x7F; 85 } 86 assertEquals(expected, ProtobufParser.convertByteArray(ProtobufTest.toByteArray(bytes), (byte) 7, 0, bytes.length)); 87 } 51 88 } -
trunk/test/unit/org/openstreetmap/josm/gui/io/importexport/OsmPbfImporterTest.java
r18695 r18826 5 5 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 6 6 import static org.junit.jupiter.api.Assertions.assertEquals; 7 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 8 import static org.junit.jupiter.api.Assertions.assertSame; 8 9 import static org.junit.jupiter.api.Assertions.assertThrows; … … 18 19 import org.junit.jupiter.api.BeforeAll; 19 20 import org.junit.jupiter.api.Test; 21 import org.junit.jupiter.params.ParameterizedTest; 22 import org.junit.jupiter.params.provider.ValueSource; 20 23 import org.openstreetmap.josm.TestUtils; 21 24 import org.openstreetmap.josm.data.coor.ILatLon; … … 23 26 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 24 27 import org.openstreetmap.josm.data.osm.DataSet; 28 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 25 29 import org.openstreetmap.josm.data.osm.Relation; 26 30 import org.openstreetmap.josm.data.osm.Way; … … 130 134 } 131 135 } 136 137 @Test 138 void testIdParsing() throws IOException, IllegalDataException { 139 final DataSet dataSet; 140 try (InputStream inputStream = TestUtils.getRegressionDataStream(23165, "largeIds.osm.pbf")) { 141 dataSet = importer.parseDataSet(inputStream, NullProgressMonitor.INSTANCE); 142 } 143 assertNotNull(dataSet.getPrimitiveById(9223372036854775806L, OsmPrimitiveType.NODE)); 144 assertNotNull(dataSet.getPrimitiveById(9223372036854775806L, OsmPrimitiveType.WAY)); 145 assertNotNull(dataSet.getPrimitiveById(9223372036854775806L, OsmPrimitiveType.RELATION)); 146 } 147 148 @ParameterizedTest 149 @ValueSource(strings = {"Downloads/24165.osm.pbf", "workspace/tasking-manager/frontend/24165.osmosis.osm.pbf", 150 "workspace/tasking-manager/frontend/24165.osmium.osm.pbf"}) 151 void test23165(String path) throws IOException { 152 try (InputStream is = Files.newInputStream(Paths.get("/Users/tsmock", path))) { 153 DataSet ds = assertDoesNotThrow(() -> importer.parseDataSet(is, NullProgressMonitor.INSTANCE)); 154 assertNotNull(ds.getPrimitiveById(22319993769L, OsmPrimitiveType.NODE)); 155 assertNotNull(ds.getPrimitiveById(32920002105L, OsmPrimitiveType.NODE)); 156 assertNotNull(ds.getPrimitiveById(29706529395L, OsmPrimitiveType.NODE)); 157 assertNotNull(ds.getPrimitiveById(23842321089L, OsmPrimitiveType.NODE)); 158 assertNotNull(ds.getPrimitiveById(31341235510L, OsmPrimitiveType.NODE)); 159 assertNotNull(ds.getPrimitiveById(30053292843L, OsmPrimitiveType.NODE)); 160 assertNotNull(ds.getPrimitiveById(28917983832L, OsmPrimitiveType.NODE)); 161 assertNotNull(ds.getPrimitiveById(29875275836L, OsmPrimitiveType.NODE)); 162 assertNotNull(ds.getPrimitiveById(32694472600L, OsmPrimitiveType.NODE)); 163 assertNotNull(ds.getPrimitiveById(22545520445L, OsmPrimitiveType.NODE)); 164 assertNotNull(ds.getPrimitiveById(23222110547L, OsmPrimitiveType.NODE)); 165 assertNotNull(ds.getPrimitiveById(2147640293L, OsmPrimitiveType.WAY)); 166 } 167 } 132 168 }
Note:
See TracChangeset
for help on using the changeset viewer.