Changeset 9861 in josm for trunk/test/unit/org
- Timestamp:
- 2016-02-23T21:01:34+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java
r9810 r9861 4 4 import static org.junit.Assert.assertEquals; 5 5 6 import java.util.Locale; 7 8 import org.junit.Before; 6 9 import org.junit.Test; 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.projection.Projections; 7 12 8 13 /** … … 10 15 */ 11 16 public class LatLonTest { 17 18 /** 19 * Setup test. 20 */ 21 @Before 22 public void setUp() throws Exception { 23 Locale.setDefault(Locale.GERMAN); 24 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 25 } 12 26 13 27 private static final double EPSILON = 1e-6; … … 26 40 27 41 /** 28 * Test of {@link LatLon#roundToOsmPrecision Strict}42 * Test of {@link LatLon#roundToOsmPrecision} 29 43 */ 30 44 @Test 31 public void testRoundToOsmPrecision Strict() {45 public void testRoundToOsmPrecision() { 32 46 33 47 for (double value : SAMPLE_VALUES) { 34 assertEquals(LatLon.roundToOsmPrecision Strict(value), value, 0);48 assertEquals(LatLon.roundToOsmPrecision(value), value, 0); 35 49 } 36 50 37 assertEquals(LatLon.roundToOsmPrecision Strict(0.0), 0.0, 0);38 assertEquals(LatLon.roundToOsmPrecision Strict(-0.0), 0.0, 0);51 assertEquals(LatLon.roundToOsmPrecision(0.0), 0.0, 0); 52 assertEquals(LatLon.roundToOsmPrecision(-0.0), 0.0, 0); 39 53 40 assertEquals(LatLon.roundToOsmPrecision Strict(0.12345678), 0.1234568, 0);41 assertEquals(LatLon.roundToOsmPrecision Strict(0.123456789), 0.1234568, 0);54 assertEquals(LatLon.roundToOsmPrecision(0.12345678), 0.1234568, 0); 55 assertEquals(LatLon.roundToOsmPrecision(0.123456789), 0.1234568, 0); 42 56 43 assertEquals(LatLon.roundToOsmPrecision Strict(1.12345678), 1.1234568, 0);44 assertEquals(LatLon.roundToOsmPrecision Strict(1.123456789), 1.1234568, 0);57 assertEquals(LatLon.roundToOsmPrecision(1.12345678), 1.1234568, 0); 58 assertEquals(LatLon.roundToOsmPrecision(1.123456789), 1.1234568, 0); 45 59 46 assertEquals(LatLon.roundToOsmPrecision Strict(10.12345678), 10.1234568, 0);47 assertEquals(LatLon.roundToOsmPrecision Strict(10.123456789), 10.1234568, 0);60 assertEquals(LatLon.roundToOsmPrecision(10.12345678), 10.1234568, 0); 61 assertEquals(LatLon.roundToOsmPrecision(10.123456789), 10.1234568, 0); 48 62 49 assertEquals(LatLon.roundToOsmPrecision Strict(100.12345678), 100.1234568, 0);50 assertEquals(LatLon.roundToOsmPrecision Strict(100.123456789), 100.1234568, 0);63 assertEquals(LatLon.roundToOsmPrecision(100.12345678), 100.1234568, 0); 64 assertEquals(LatLon.roundToOsmPrecision(100.123456789), 100.1234568, 0); 51 65 52 assertEquals(LatLon.roundToOsmPrecision Strict(100.00000001), 100.0000000, 0);53 assertEquals(LatLon.roundToOsmPrecision Strict(100.000000001), 100.0000000, 0);54 assertEquals(LatLon.roundToOsmPrecision Strict(100.0000000001), 100.0000000, 0);55 assertEquals(LatLon.roundToOsmPrecision Strict(100.00000000001), 100.0000000, 0);56 assertEquals(LatLon.roundToOsmPrecision Strict(100.000000000001), 100.0000000, 0);57 assertEquals(LatLon.roundToOsmPrecision Strict(100.0000000000001), 100.0000000, 0);58 assertEquals(LatLon.roundToOsmPrecision Strict(100.00000000000001), 100.0000000, 0);59 assertEquals(LatLon.roundToOsmPrecision Strict(100.000000000000001), 100.0000000, 0);60 assertEquals(LatLon.roundToOsmPrecision Strict(100.0000000000000001), 100.0000000, 0);61 assertEquals(LatLon.roundToOsmPrecision Strict(100.00000000000000001), 100.0000000, 0);62 assertEquals(LatLon.roundToOsmPrecision Strict(100.000000000000000001), 100.0000000, 0);63 assertEquals(LatLon.roundToOsmPrecision Strict(100.0000000000000000001), 100.0000000, 0);64 assertEquals(LatLon.roundToOsmPrecision Strict(100.00000000000000000001), 100.0000000, 0);66 assertEquals(LatLon.roundToOsmPrecision(100.00000001), 100.0000000, 0); 67 assertEquals(LatLon.roundToOsmPrecision(100.000000001), 100.0000000, 0); 68 assertEquals(LatLon.roundToOsmPrecision(100.0000000001), 100.0000000, 0); 69 assertEquals(LatLon.roundToOsmPrecision(100.00000000001), 100.0000000, 0); 70 assertEquals(LatLon.roundToOsmPrecision(100.000000000001), 100.0000000, 0); 71 assertEquals(LatLon.roundToOsmPrecision(100.0000000000001), 100.0000000, 0); 72 assertEquals(LatLon.roundToOsmPrecision(100.00000000000001), 100.0000000, 0); 73 assertEquals(LatLon.roundToOsmPrecision(100.000000000000001), 100.0000000, 0); 74 assertEquals(LatLon.roundToOsmPrecision(100.0000000000000001), 100.0000000, 0); 75 assertEquals(LatLon.roundToOsmPrecision(100.00000000000000001), 100.0000000, 0); 76 assertEquals(LatLon.roundToOsmPrecision(100.000000000000000001), 100.0000000, 0); 77 assertEquals(LatLon.roundToOsmPrecision(100.0000000000000000001), 100.0000000, 0); 78 assertEquals(LatLon.roundToOsmPrecision(100.00000000000000000001), 100.0000000, 0); 65 79 66 assertEquals(LatLon.roundToOsmPrecision Strict(99.999999999999999999999), 100.0000000, 0);67 assertEquals(LatLon.roundToOsmPrecision Strict(99.99999999999999999999), 100.0000000, 0);68 assertEquals(LatLon.roundToOsmPrecision Strict(99.9999999999999999999), 100.0000000, 0);69 assertEquals(LatLon.roundToOsmPrecision Strict(99.999999999999999999), 100.0000000, 0);70 assertEquals(LatLon.roundToOsmPrecision Strict(99.99999999999999999), 100.0000000, 0);71 assertEquals(LatLon.roundToOsmPrecision Strict(99.9999999999999999), 100.0000000, 0);72 assertEquals(LatLon.roundToOsmPrecision Strict(99.999999999999999), 100.0000000, 0);73 assertEquals(LatLon.roundToOsmPrecision Strict(99.99999999999999), 100.0000000, 0);74 assertEquals(LatLon.roundToOsmPrecision Strict(99.9999999999999), 100.0000000, 0);75 assertEquals(LatLon.roundToOsmPrecision Strict(99.999999999999), 100.0000000, 0);76 assertEquals(LatLon.roundToOsmPrecision Strict(99.99999999999), 100.0000000, 0);77 assertEquals(LatLon.roundToOsmPrecision Strict(99.9999999999), 100.0000000, 0);78 assertEquals(LatLon.roundToOsmPrecision Strict(99.999999999), 100.0000000, 0);79 assertEquals(LatLon.roundToOsmPrecision Strict(99.99999999), 100.0000000, 0);80 assertEquals(LatLon.roundToOsmPrecision Strict(99.9999999), 99.9999999, 0);80 assertEquals(LatLon.roundToOsmPrecision(99.999999999999999999999), 100.0000000, 0); 81 assertEquals(LatLon.roundToOsmPrecision(99.99999999999999999999), 100.0000000, 0); 82 assertEquals(LatLon.roundToOsmPrecision(99.9999999999999999999), 100.0000000, 0); 83 assertEquals(LatLon.roundToOsmPrecision(99.999999999999999999), 100.0000000, 0); 84 assertEquals(LatLon.roundToOsmPrecision(99.99999999999999999), 100.0000000, 0); 85 assertEquals(LatLon.roundToOsmPrecision(99.9999999999999999), 100.0000000, 0); 86 assertEquals(LatLon.roundToOsmPrecision(99.999999999999999), 100.0000000, 0); 87 assertEquals(LatLon.roundToOsmPrecision(99.99999999999999), 100.0000000, 0); 88 assertEquals(LatLon.roundToOsmPrecision(99.9999999999999), 100.0000000, 0); 89 assertEquals(LatLon.roundToOsmPrecision(99.999999999999), 100.0000000, 0); 90 assertEquals(LatLon.roundToOsmPrecision(99.99999999999), 100.0000000, 0); 91 assertEquals(LatLon.roundToOsmPrecision(99.9999999999), 100.0000000, 0); 92 assertEquals(LatLon.roundToOsmPrecision(99.999999999), 100.0000000, 0); 93 assertEquals(LatLon.roundToOsmPrecision(99.99999999), 100.0000000, 0); 94 assertEquals(LatLon.roundToOsmPrecision(99.9999999), 99.9999999, 0); 81 95 } 82 96 … … 143 157 assertEquals(270, Math.toDegrees(e.bearing(c)), EPSILON); 144 158 } 159 160 /** 161 * Tests the methods {@link LatLon#latToString(CoordinateFormat)}, {@link LatLon#lonToString(CoordinateFormat)}. 162 */ 163 @Test 164 public void testFormatting() { 165 LatLon c = new LatLon(47.000000, 19.000000); 166 assertEquals("47.0", c.latToString(CoordinateFormat.DECIMAL_DEGREES)); 167 assertEquals("19.0", c.lonToString(CoordinateFormat.DECIMAL_DEGREES)); 168 assertEquals("47°00'00,0\"N", c.latToString(CoordinateFormat.DEGREES_MINUTES_SECONDS)); 169 assertEquals("19°00'00,0\"E", c.lonToString(CoordinateFormat.DEGREES_MINUTES_SECONDS)); 170 assertEquals("47°00,000'N", c.latToString(CoordinateFormat.NAUTICAL)); 171 assertEquals("19°00,000'E", c.lonToString(CoordinateFormat.NAUTICAL)); 172 assertEquals("5942074.0724311", c.latToString(CoordinateFormat.EAST_NORTH)); 173 assertEquals("2115070.3250722", c.lonToString(CoordinateFormat.EAST_NORTH)); 174 } 145 175 }
Note:
See TracChangeset
for help on using the changeset viewer.