|
8 | 8 | /** Tests size of rectangles defined by open location codes of various size. */
|
9 | 9 | @RunWith(JUnit4.class)
|
10 | 10 | public class PrecisionTest {
|
| 11 | + |
| 12 | + private static final double epsilon = 1e-10; |
11 | 13 |
|
12 | 14 | @Test
|
13 | 15 | public void testWidthInDegrees() {
|
14 |
| - Assert.assertEquals(new OpenLocationCode("67000000+").decode().getLongitudeWidth(), 20., 0); |
15 |
| - Assert.assertEquals(new OpenLocationCode("67890000+").decode().getLongitudeWidth(), 1., 0); |
16 |
| - Assert.assertEquals(new OpenLocationCode("6789CF00+").decode().getLongitudeWidth(), 0.05, 0); |
17 |
| - Assert.assertEquals(new OpenLocationCode("6789CFGH+").decode().getLongitudeWidth(), 0.0025, 0); |
| 16 | + Assert.assertEquals(new OpenLocationCode("67000000+").decode().getLongitudeWidth(), 20., epsilon); |
| 17 | + Assert.assertEquals(new OpenLocationCode("67890000+").decode().getLongitudeWidth(), 1., epsilon); |
| 18 | + Assert.assertEquals(new OpenLocationCode("6789CF00+").decode().getLongitudeWidth(), 0.05, epsilon); |
| 19 | + Assert.assertEquals(new OpenLocationCode("6789CFGH+").decode().getLongitudeWidth(), 0.0025, epsilon); |
18 | 20 | Assert.assertEquals(
|
19 |
| - new OpenLocationCode("6789CFGH+JM").decode().getLongitudeWidth(), 0.000125, 0); |
| 21 | + new OpenLocationCode("6789CFGH+JM").decode().getLongitudeWidth(), 0.000125, epsilon); |
20 | 22 | Assert.assertEquals(
|
21 |
| - new OpenLocationCode("6789CFGH+JMP").decode().getLongitudeWidth(), 0.00003125, 0); |
| 23 | + new OpenLocationCode("6789CFGH+JMP").decode().getLongitudeWidth(), 0.00003125, epsilon); |
22 | 24 | }
|
23 | 25 |
|
24 | 26 | @Test
|
25 | 27 | public void testHeightInDegrees() {
|
26 |
| - Assert.assertEquals(new OpenLocationCode("67000000+").decode().getLatitudeHeight(), 20., 0); |
27 |
| - Assert.assertEquals(new OpenLocationCode("67890000+").decode().getLatitudeHeight(), 1., 0); |
28 |
| - Assert.assertEquals(new OpenLocationCode("6789CF00+").decode().getLatitudeHeight(), 0.05, 0); |
29 |
| - Assert.assertEquals(new OpenLocationCode("6789CFGH+").decode().getLatitudeHeight(), 0.0025, 0); |
| 28 | + Assert.assertEquals(new OpenLocationCode("67000000+").decode().getLatitudeHeight(), 20., epsilon); |
| 29 | + Assert.assertEquals(new OpenLocationCode("67890000+").decode().getLatitudeHeight(), 1., epsilon); |
| 30 | + Assert.assertEquals(new OpenLocationCode("6789CF00+").decode().getLatitudeHeight(), 0.05, epsilon); |
| 31 | + Assert.assertEquals(new OpenLocationCode("6789CFGH+").decode().getLatitudeHeight(), 0.0025, epsilon); |
30 | 32 | Assert.assertEquals(
|
31 |
| - new OpenLocationCode("6789CFGH+JM").decode().getLatitudeHeight(), 0.000125, 0); |
| 33 | + new OpenLocationCode("6789CFGH+JM").decode().getLatitudeHeight(), 0.000125, epsilon); |
32 | 34 | Assert.assertEquals(
|
33 |
| - new OpenLocationCode("6789CFGH+JMP").decode().getLatitudeHeight(), 0.000025, 0); |
| 35 | + new OpenLocationCode("6789CFGH+JMP").decode().getLatitudeHeight(), 0.000025, epsilon); |
34 | 36 | }
|
35 | 37 | }
|
0 commit comments