Add Rect unit tests
This commit is contained in:
parent
27518c68df
commit
1dffc67339
|
@ -3,7 +3,7 @@ package net.shadowfacts.shadowui.geometry
|
|||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class Point(val x: Double, val y: Double) {
|
||||
data class Point(val x: Double, val y: Double) {
|
||||
|
||||
constructor(x: Int, y: Int): this(x.toDouble(), y.toDouble())
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package net.shadowfacts.shadowui.geometry
|
||||
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class RectTest {
|
||||
|
||||
@Test
|
||||
fun testTrailingEdges() {
|
||||
val rect = Rect(25.0, 50.0, 100.0, 200.0)
|
||||
assertEquals(125.0, rect.right)
|
||||
assertEquals(250.0, rect.bottom)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCenter() {
|
||||
val rect = Rect(25.0, 50.0, 100.0, 200.0)
|
||||
assertEquals(75.0, rect.midX)
|
||||
assertEquals(150.0, rect.midY)
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPoints() {
|
||||
val rect = Rect(25.0, 50.0, 100.0, 200.0)
|
||||
assertEquals(Point(25.0, 50.0), rect.origin)
|
||||
assertEquals(Point(75.0, 150.0), rect.center)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSize() {
|
||||
val rect = Rect(25.0, 50.0, 100.0, 200.0)
|
||||
assertEquals(Size(100.0, 200.0), rect.size)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue