Changeset 11086 in josm for trunk/test/unit/org
- Timestamp:
- 2016-10-07T03:10:00+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java
r11045 r11086 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertTrue; 5 7 6 8 import java.text.DecimalFormat; … … 8 10 import org.junit.Rule; 9 11 import org.junit.Test; 12 import org.openstreetmap.josm.data.Bounds; 10 13 import org.openstreetmap.josm.testutils.JOSMTestRules; 11 14 … … 23 26 @Rule 24 27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 25 public JOSMTestRules test = new JOSMTestRules(); 28 public JOSMTestRules test = new JOSMTestRules().projection(); 26 29 27 30 private static final double EPSILON = 1e-6; … … 101 104 102 105 /** 106 * Test {@link LatLon#toIntervalLat} 107 */ 108 @Test 109 public void testToIntervalLat() { 110 assertEquals(-90.0, LatLon.toIntervalLat(-90.0), 0); 111 assertEquals(0.0, LatLon.toIntervalLat(0.0), 0); 112 assertEquals(90.0, LatLon.toIntervalLat(90.0), 0); 113 114 assertEquals(-90.0, LatLon.toIntervalLat(-91.0), 0); 115 assertEquals(90.0, LatLon.toIntervalLat(91.0), 0); 116 } 117 118 /** 103 119 * Test of {@link LatLon#toIntervalLon} 104 120 */ … … 133 149 .withPrefabValues(DecimalFormat.class, new DecimalFormat("00.0"), new DecimalFormat("00.000")) 134 150 .verify(); 151 } 152 153 /** 154 * Unit test of {@link LatLon#LatLon(LatLon)}. 155 */ 156 @Test 157 public void testCopyConstructor() { 158 assertEquals(LatLon.NORTH_POLE, new LatLon(LatLon.NORTH_POLE)); 159 assertEquals(LatLon.SOUTH_POLE, new LatLon(LatLon.SOUTH_POLE)); 160 assertEquals(new LatLon(1, 2), new LatLon(new LatLon(1, 2))); 135 161 } 136 162 … … 150 176 151 177 /** 152 * Tests the methods {@link LatLon#latToString(CoordinateFormat)}, {@link LatLon#lonToString(CoordinateFormat)}. 178 * Test of {@link LatLon#distance} 179 */ 180 @Test 181 public void testDistance() { 182 assertEquals(0.0, LatLon.ZERO.distance(LatLon.ZERO), 0); 183 assertEquals(90.0, LatLon.ZERO.distance(LatLon.NORTH_POLE), 0); 184 assertEquals(180.0, LatLon.SOUTH_POLE.distance(LatLon.NORTH_POLE), 0); 185 } 186 187 /** 188 * Test of {@link LatLon#distanceSq} 189 */ 190 @Test 191 public void testDistanceSq() { 192 assertEquals(0.0, LatLon.ZERO.distanceSq(LatLon.ZERO), 0); 193 assertEquals(90d*90d, LatLon.ZERO.distanceSq(LatLon.NORTH_POLE), 0); 194 assertEquals(180d*180d, LatLon.SOUTH_POLE.distanceSq(LatLon.NORTH_POLE), 0); 195 } 196 197 /** 198 * Tests the methods {@link LatLon#latToString}, {@link LatLon#lonToString}, {@link LatLon#toStringCSV}. 153 199 */ 154 200 @Test 155 201 public void testFormatting() { 156 202 LatLon c = new LatLon(47.000000, 19.000000); 203 assertEquals("47.0;19.0", c.toStringCSV(";")); 157 204 assertEquals("47.0", c.latToString(CoordinateFormat.DECIMAL_DEGREES)); 158 205 assertEquals("19.0", c.lonToString(CoordinateFormat.DECIMAL_DEGREES)); … … 163 210 assertEquals("5942074.0724311", c.latToString(CoordinateFormat.EAST_NORTH)); 164 211 assertEquals("2115070.3250722", c.lonToString(CoordinateFormat.EAST_NORTH)); 212 c = new LatLon(-47.000000, -19.000000); 213 assertEquals("47°00'00.0\"S", c.latToString(CoordinateFormat.DEGREES_MINUTES_SECONDS)); 214 assertEquals("19°00'00.0\"W", c.lonToString(CoordinateFormat.DEGREES_MINUTES_SECONDS)); 215 assertEquals("47°00.000'S", c.latToString(CoordinateFormat.NAUTICAL)); 216 assertEquals("19°00.000'W", c.lonToString(CoordinateFormat.NAUTICAL)); 165 217 } 166 218 167 219 /** 168 220 * Test {@link LatLon#interpolate(LatLon, double)} 169 * @since 10915170 221 */ 171 222 @Test … … 187 238 188 239 /** 240 * Test {@link LatLon#isOutSideWorld} 241 */ 242 @Test 243 public void testIsOutSideWorld() { 244 assertFalse(LatLon.ZERO.isOutSideWorld()); 245 assertTrue(LatLon.NORTH_POLE.isOutSideWorld()); 246 assertTrue(LatLon.SOUTH_POLE.isOutSideWorld()); 247 assertTrue(new LatLon(-181, 0).isOutSideWorld()); 248 assertTrue(new LatLon(181, 0).isOutSideWorld()); 249 } 250 251 /** 252 * Test {@link LatLon#isValid} 253 */ 254 @Test 255 public void testIsValid() { 256 assertTrue(LatLon.ZERO.isValid()); 257 assertTrue(LatLon.NORTH_POLE.isValid()); 258 assertTrue(LatLon.SOUTH_POLE.isValid()); 259 260 assertFalse(new LatLon(-91, 0).isValid()); 261 assertFalse(new LatLon(91, 0).isValid()); 262 assertFalse(new LatLon(0, -181).isValid()); 263 assertFalse(new LatLon(0, 181).isValid()); 264 } 265 266 /** 267 * Test {@link LatLon#isWithin} 268 */ 269 @Test 270 public void testIsWithin() { 271 assertTrue(LatLon.ZERO.isWithin(new Bounds(LatLon.ZERO))); 272 assertFalse(LatLon.ZERO.isWithin(new Bounds(LatLon.NORTH_POLE))); 273 } 274 275 /** 189 276 * Test {@link LatLon#getCenter(LatLon)} 190 * @since 10915191 277 */ 192 278 @Test
Note:
See TracChangeset
for help on using the changeset viewer.