-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding toString method and the related test
- Loading branch information
Matt
committed
Sep 9, 2023
1 parent
38d07b9
commit 7ff1fc9
Showing
2 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/test/java/io/github/makbn/jlmap/model/JLLatLngTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package io.github.makbn.jlmap.model; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class JLLatLngTest { | ||
|
||
@Test | ||
void testEquals() { | ||
JLLatLng pointA = JLLatLng.builder() | ||
.lat(10) | ||
.lng(20) | ||
.build(); | ||
|
||
JLLatLng pointB = JLLatLng.builder() | ||
.lat(10.000) | ||
.lng(20.00) | ||
.build(); | ||
Assertions.assertEquals(pointA, pointB); | ||
} | ||
|
||
@Test | ||
void testNotEquals() { | ||
JLLatLng pointA = JLLatLng.builder() | ||
.lat(10) | ||
.lng(20) | ||
.build(); | ||
|
||
JLLatLng pointB = JLLatLng.builder() | ||
.lat(20) | ||
.lng(10) | ||
.build(); | ||
|
||
Assertions.assertNotEquals(pointA, pointB); | ||
} | ||
|
||
@Test | ||
void testDistanceCalculation_lng() { | ||
JLLatLng pointA = JLLatLng.builder() | ||
.lat(10) | ||
.lng(20) | ||
.build(); | ||
|
||
JLLatLng pointB = JLLatLng.builder() | ||
.lat(10) | ||
.lng(50) | ||
.build(); | ||
|
||
Assertions.assertTrue(Math.abs(3282 - Math.round(pointA.distanceTo(pointB)/ 1000)) < 0.01); | ||
} | ||
|
||
@Test | ||
void testDistanceCalculation_lat() { | ||
JLLatLng pointA = JLLatLng.builder() | ||
.lat(50) | ||
.lng(10) | ||
.build(); | ||
|
||
JLLatLng pointB = JLLatLng.builder() | ||
.lat(20) | ||
.lng(10) | ||
.build(); | ||
|
||
Assertions.assertTrue(Math.abs(3334 - Math.round(pointA.distanceTo(pointB)/ 1000)) < 0.01); | ||
} | ||
|
||
@Test | ||
void testDistanceCalculation_latLng() { | ||
JLLatLng pointA = JLLatLng.builder() | ||
.lat(50) | ||
.lng(80) | ||
.build(); | ||
|
||
JLLatLng pointB = JLLatLng.builder() | ||
.lat(30) | ||
.lng(10) | ||
.build(); | ||
|
||
Assertions.assertTrue(Math.abs(6113 - Math.round(pointA.distanceTo(pointB)/ 1000)) < 0.01); | ||
} | ||
} |