blob: dc06e4ba2febd4e3e1e9ca7a37d5e7e289675586 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package moe.nea.firmament.test.util.math
import java.util.stream.Stream
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.DynamicTest
import org.junit.jupiter.api.TestFactory
import kotlin.streams.asStream
import net.minecraft.world.phys.Vec2
import moe.nea.firmament.util.math.Projections
class ProjectionsBoxTest {
val Double.degrees get() = Math.toRadians(this)
@TestFactory
fun testProjections(): Stream<DynamicTest> {
return sequenceOf(
0.0.degrees to Vec2(1F, 0F),
63.4349.degrees to Vec2(0.5F, 1F),
).map { (angle, expected) ->
DynamicTest.dynamicTest("ProjectionsBoxTest::projectAngleOntoUnitBox(${angle})") {
val actual = Projections.Two.projectAngleOntoUnitBox(angle)
fun msg() = "Expected (${expected.x}, ${expected.y}) got (${actual.x}, ${actual.y})"
Assertions.assertEquals(expected.x, actual.x, 0.0001F, ::msg)
Assertions.assertEquals(expected.y, actual.y, 0.0001F, ::msg)
}
}.asStream()
}
}
|