Skip to content

Commit

Permalink
Added LineString Unit Test (#2518)
Browse files Browse the repository at this point in the history
* added linestring unit test

* hardcoded string

* order reverse
  • Loading branch information
anandwana001 authored Jun 26, 2024
1 parent 38f6658 commit 08765d6
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ class GeometryTest {
@Test
fun testPointIsEmpty() {
val point = point(x, y)
assertThat(POINT_IS_EMPTY).isEqualTo(point.isEmpty())

assertThat(point.isEmpty()).isEqualTo(false)
}

@Test
fun testPointArea() {
val point = point(x, y)
assertThat(POINT_AREA).isEqualTo(point.area)
assertThat(point.area).isEqualTo(0.0)
}

@Test
Expand Down Expand Up @@ -123,6 +124,17 @@ class GeometryTest {
assertThat(LineString(CLOSED_LOOP).isClosed()).isTrue()
}

@Test
fun testCenterOfLineString() {
assertThat(LineString(CLOSED_LOOP).center()).isEqualTo(COORDINATE_2)
assertThat(LineString(OPEN_LOOP).center()).isEqualTo(COORDINATE_2)
}

@Test
fun testAreaOfLineString() {
assertThat(LineString(CLOSED_LOOP).area).isEqualTo(0.0)
}

private fun point(x: Double, y: Double) = Point(Coordinates(x, y))

private fun linearRing(path: Path) = LinearRing(toCoordinateList(path))
Expand All @@ -143,8 +155,5 @@ class GeometryTest {

private val OPEN_LOOP = listOf(COORDINATE_1, COORDINATE_2, COORDINATE_3)
private val CLOSED_LOOP = listOf(COORDINATE_1, COORDINATE_2, COORDINATE_3, COORDINATE_1)

private const val POINT_AREA = 0.0
private const val POINT_IS_EMPTY = false
}
}

0 comments on commit 08765d6

Please sign in to comment.