Changeset 36198 in osm for applications
- Timestamp:
- 2023-12-27T16:17:21+01:00 (11 months ago)
- Location:
- applications/viewer/jmapviewer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/TileRange.java
r33285 r36198 48 48 * Returns size 49 49 * @return size 50 * @throws ArithmeticException – if the result overflows an int (see {@link Math#multiplyExact(int, int)}) 50 51 */ 51 public int size() {52 public int size() throws ArithmeticException { 52 53 int xSpan = maxX - minX + 1; 53 54 int ySpan = maxY - minY + 1; 54 return xSpan * ySpan;55 return Math.multiplyExact(xSpan, ySpan); 55 56 } 56 57 } -
applications/viewer/jmapviewer/test/org/openstreetmap/gui/jmapviewer/TileRangeTest.java
r36140 r36198 4 4 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 7 8 import org.junit.jupiter.api.Test; … … 21 22 new TileXY(6, 6), 10).size()); 22 23 } 24 25 /** 26 * Ensure that something exceptional happens when an integer overflow happens 27 */ 28 @Test 29 void testSizeTooLarge() { 30 final TileRange allZ16 = new TileRange(new TileXY(0, 0), new TileXY(1 << 16, 1 << 16), 16); 31 assertThrows(ArithmeticException.class, allZ16::size); 32 } 23 33 }
Note:
See TracChangeset
for help on using the changeset viewer.