Skip to content

Commit

Permalink
adding toString method and the related test
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt committed Sep 9, 2023
1 parent 2b294b3 commit 38d07b9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/io/github/makbn/jlmap/model/JLBounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

/**
* Represents a rectangular geographical area on a map.
* by: Mehdi Akbarian Rastaghi (@makbn)
* @author Mehdi Akbarian Rastaghi (@makbn)
*/
@Getter
@Setter
@Builder
@ToString
public class JLBounds {
/**
* the north-east point of the bounds.
Expand Down Expand Up @@ -161,4 +160,9 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(northEast, southWest);
}

@Override
public String toString() {
return String.format("[%s, %s]", northEast, southWest);
}
}
18 changes: 18 additions & 0 deletions src/test/java/io/github/makbn/jlmap/model/JLBoundsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apackage io.github.makbn.jlmap.model;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class JLBoundsTest {

@Test
void testToString() {
JLBounds bounds = JLBounds.builder()
.northEast(JLLatLng.builder().lat(10).lng(10).build())
.southWest(JLLatLng.builder().lat(40).lng(60).build())
.build();

assertEquals("[[10.000000, 10.000000], [40.000000, 60.000000]]", bounds.toString());
}
}

0 comments on commit 38d07b9

Please sign in to comment.