From c6a27b3a452a59d8b28249a8640e631316f3bce9 Mon Sep 17 00:00:00 2001 From: Benedikt Schwab Date: Mon, 11 Sep 2023 19:17:12 +0200 Subject: [PATCH] replaced junit with kotest --- build.gradle.kts | 2 +- buildSrc/src/main/kotlin/Dependencies.kt | 4 +- .../rtron/math/SpiralSegment2DWriterTest.kt | 2 - .../io/rtron/math/analysis/FresnelTest.kt | 26 ++-- .../analysis/function/LinearFunctionTest.kt | 35 ++---- .../SectionedBivariateFunctionTest.kt | 14 +-- .../combination/ConcatenatedFunctionTest.kt | 28 ++--- .../euclidean/threed/Rotation3DTest.kt | 38 ++---- .../geometry/euclidean/threed/Vector3DTest.kt | 81 +++++------- .../euclidean/threed/curve/Curve3DTest.kt | 20 ++- .../euclidean/threed/curve/Line3DTest.kt | 14 +-- .../threed/curve/LineSegment3DTest.kt | 26 ++-- .../threed/curve/LineString3DTest.kt | 26 ++-- .../euclidean/threed/point/Pose3DTest.kt | 14 +-- .../euclidean/threed/solid/Cuboid3DTest.kt | 23 ++-- .../euclidean/threed/solid/Cylinder3DTest.kt | 17 ++- .../threed/surface/LinearRing3DUtilTest.kt | 14 +-- .../euclidean/threed/surface/Polygon3DTest.kt | 38 ++---- .../geometry/euclidean/twod/Pose2DTest.kt | 27 ++-- .../geometry/euclidean/twod/Rotation2DTest.kt | 50 +++----- .../euclidean/twod/curve/Arc2DTest.kt | 68 ++++------ .../twod/curve/CompositeCurve2DTest.kt | 14 +-- .../euclidean/twod/curve/CubicCurve2DTest.kt | 21 ++-- .../euclidean/twod/curve/LineSegment2DTest.kt | 39 +++--- .../twod/curve/ParametricCubicCurve2DTest.kt | 22 ++-- .../euclidean/twod/curve/Spiral2DTest.kt | 54 +++----- .../twod/curve/SpiralSegment2DTest.kt | 33 ++--- .../euclidean/twod/point/Vector2DTest.kt | 31 ++--- .../euclidean/twod/surface/Polygon2DTest.kt | 20 ++- .../io/rtron/math/linear/MatrixUtilsTest.kt | 14 +-- .../io/rtron/math/linear/RealMatrixTest.kt | 4 +- .../rtron/math/linear/RealVectorUtilsTest.kt | 19 ++- .../linear/SingularValueDecompositionTest.kt | 38 ++---- .../rtron/math/processing/Plane3DUtilTest.kt | 30 ++--- .../processing/Vector2DListExtensionsTest.kt | 33 ++--- .../processing/Vector3DListExtensionsTest.kt | 89 +++++-------- .../CoordinateReferenceSystemTest.kt | 28 ++--- .../math/range/DoubleRangeExtensionsTest.kt | 63 ++++------ .../range/DoubleRangeSetExtensionsTest.kt | 17 +-- .../io/rtron/math/range/RangeSetTest.kt | 46 +++---- .../kotlin/io/rtron/math/range/RangeTest.kt | 119 +++++++----------- .../math/std/DoubleArrayExtensionTest.kt | 28 ++--- .../io/rtron/math/transform/Affine2DTest.kt | 86 +++++-------- .../io/rtron/math/transform/Affine3DTest.kt | 93 ++++++-------- .../kotlin/io/rtron/std/CollectionsKtTest.kt | 102 ++++++--------- .../kotlin/io/rtron/std/IterableKtTest.kt | 35 +++--- .../test/kotlin/io/rtron/std/ListsKtTest.kt | 54 +++----- .../kotlin/io/rtron/std/SequencesKtTest.kt | 53 +++----- .../test/kotlin/io/rtron/std/SetsKtTest.kt | 14 +-- 49 files changed, 652 insertions(+), 1114 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2a9a3a63..a9604fe5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -70,7 +70,7 @@ allprojects { implementation(Dependencies.arrowCore) implementation(Dependencies.arrowOptics) - testImplementation(Dependencies.junit) + testImplementation(Dependencies.kotest) testImplementation(Dependencies.assertj) testImplementation(Dependencies.mockk) } diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index b75a3d7c..730021fe 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -22,7 +22,7 @@ object DependencyVersions { const val arrow = "1.2.1" // testing libraries - const val junit = "5.10.0" + const val kotest = "5.7.1" const val assertj = "3.24.2" const val mockk = "1.13.7" @@ -70,7 +70,7 @@ object Dependencies { const val arrowOpticsKspPlugin = "io.arrow-kt:arrow-optics-ksp-plugin:${DependencyVersions.arrow}" // testing libraries - const val junit = "org.junit.jupiter:junit-jupiter:${DependencyVersions.junit}" + const val kotest = "io.kotest:kotest-runner-junit5:${DependencyVersions.kotest}" const val assertj = "org.assertj:assertj-core:${DependencyVersions.assertj}" const val mockk = "io.mockk:mockk:${DependencyVersions.mockk}" diff --git a/rtron-math/src/test/kotlin/io/rtron/math/SpiralSegment2DWriterTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/SpiralSegment2DWriterTest.kt index e478385e..f2746489 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/SpiralSegment2DWriterTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/SpiralSegment2DWriterTest.kt @@ -27,12 +27,10 @@ import io.rtron.math.range.Range import io.rtron.math.range.arrange import io.rtron.math.std.PI import io.rtron.math.transform.AffineSequence2D -import org.junit.jupiter.api.Test import kotlin.io.path.Path object SpiralSegment2DWriterTest { - @Test fun writeSpiralSegment2DToCsvFile() { val path = Path("out/test_files/SpiralSegment2D/SpiralSegment2D-line.csv") val header = listOf("curvePosition", "x", "y") diff --git a/rtron-math/src/test/kotlin/io/rtron/math/analysis/FresnelTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/analysis/FresnelTest.kt index 3fc47622..f2c70459 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/analysis/FresnelTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/analysis/FresnelTest.kt @@ -16,32 +16,29 @@ package io.rtron.math.analysis +import io.kotest.core.spec.style.FunSpec import io.rtron.math.std.DBL_EPSILON import mu.KotlinLogging import org.apache.commons.csv.CSVFormat import org.apache.commons.csv.CSVRecord import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test import java.io.FileReader import kotlin.io.path.Path import kotlin.io.path.absolute import kotlin.io.path.exists -class FresnelTest { +class FresnelTest : FunSpec({ - private val logger = KotlinLogging.logger {} + val logger = KotlinLogging.logger {} - @Nested - inner class TestDatasetCalculation { + context("TestDatasetCalculation") { - @Test - fun `test against csv sample dataset`() { + test("test against csv sample dataset") { val filePath = Path("src/test/cpp/spiral/build/sampled_fresnel_integral.csv").absolute() if (!filePath.exists()) { logger.warn { "Dataset does not exist at $filePath, skipping test" } - return + return@test } val fileReader = FileReader(filePath.toFile()) @@ -59,28 +56,25 @@ class FresnelTest { } } - @Test - fun `test against sample value 1`() { + test("test against sample value 1") { val (actualX, actualY) = Fresnel.calculatePoint(-4.2284028867950161) assertThat(actualX).isCloseTo(-0.51547336206019945, Offset.offset(DBL_EPSILON)) assertThat(actualY).isCloseTo(-0.5736113070569262, Offset.offset(DBL_EPSILON)) } - @Test - fun `test against sample value 2`() { + test("test against sample value 2") { val (actualX, actualY) = Fresnel.calculatePoint(883.12677767970729) assertThat(actualX).isCloseTo(0.50035646758310326, Offset.offset(DBL_EPSILON)) assertThat(actualY).isCloseTo(0.49994666781760994, Offset.offset(DBL_EPSILON)) } - @Test - fun `test against sample value 3`() { + test("test against sample value 3") { val (actualX, actualY) = Fresnel.calculatePoint(-1.8154077322757265) assertThat(actualX).isCloseTo(-0.33992314562581244, Offset.offset(DBL_EPSILON)) assertThat(actualY).isCloseTo(-0.43687889962705617, Offset.offset(DBL_EPSILON)) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/LinearFunctionTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/LinearFunctionTest.kt index 2cb48ff9..cea82850 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/LinearFunctionTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/LinearFunctionTest.kt @@ -17,20 +17,16 @@ package io.rtron.math.analysis.function import arrow.core.Either +import io.kotest.core.spec.style.FunSpec import io.rtron.math.analysis.function.univariate.pure.LinearFunction import io.rtron.math.range.Range import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatIllegalArgumentException -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class LinearFunctionTest { +class LinearFunctionTest : FunSpec({ + context("TestValueCalculation") { - @Nested - inner class TestValueCalculation { - - @Test - fun `f(3)=5 times x plus 25 should be 40`() { + test("f(3)=5 times x plus 25 should be 40") { val linearFunction = LinearFunction(5.0, 25.0) val actualResult = linearFunction.value(3.0) @@ -39,8 +35,7 @@ internal class LinearFunctionTest { assertThat(actualResult.value).isEqualTo(40.0) } - @Test - fun `out of range value evaluation throws an IllegalArgumentException`() { + test("out of range value evaluation throws an IllegalArgumentException") { val linearFunction = LinearFunction(-5.0, 25.0, Range.closedOpen(1.0, 3.0)) val actualResult = linearFunction.value(3.0) @@ -50,11 +45,9 @@ internal class LinearFunctionTest { } } - @Nested - inner class TestFactoryMethodOfInclusivePoints { + context("TestFactoryMethodOfInclusivePoints") { - @Test - fun `basic creation of linear function with two points`() { + test("basic creation of linear function with two points") { val expectedLinearFunction = LinearFunction( -3.0 / 2.0, 13.0 / 2.0, @@ -66,8 +59,7 @@ internal class LinearFunctionTest { assertThat(actualLinearFunction).isEqualTo(expectedLinearFunction) } - @Test - fun `creation of linear function with two equal points throws an IllegalArgumentException`() { + test("creation of linear function with two equal points throws an IllegalArgumentException") { val x = 2.1 val y = 3.4 @@ -75,11 +67,9 @@ internal class LinearFunctionTest { } } - @Nested - inner class TestFactoryMethodOfInclusiveYValueAndUnitSlope { + context("TestFactoryMethodOfInclusiveYValueAndUnitSlope") { - @Test - fun `with positive unit slope`() { + test("with positive unit slope") { val expectedLinearFunction = LinearFunction( 1.0, 2.0, @@ -91,8 +81,7 @@ internal class LinearFunctionTest { assertThat(actualLinearFunction).isEqualTo(expectedLinearFunction) } - @Test - fun `with negative unit slope`() { + test("with negative unit slope") { val expectedLinearFunction = LinearFunction( -1.0, 17.0, @@ -104,4 +93,4 @@ internal class LinearFunctionTest { assertThat(actualLinearFunction).isEqualTo(expectedLinearFunction) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/bivariate/SectionedBivariateFunctionTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/bivariate/SectionedBivariateFunctionTest.kt index 90b4676e..1a838bde 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/bivariate/SectionedBivariateFunctionTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/bivariate/SectionedBivariateFunctionTest.kt @@ -17,20 +17,16 @@ package io.rtron.math.analysis.function.bivariate import arrow.core.Either +import io.kotest.core.spec.style.FunSpec import io.rtron.math.analysis.function.bivariate.combination.SectionedBivariateFunction import io.rtron.math.analysis.function.bivariate.pure.PlaneFunction import io.rtron.math.range.Range import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class SectionedBivariateFunctionTest { +class SectionedBivariateFunctionTest : FunSpec({ + context("TestCreation") { - @Nested - inner class TestCreation { - - @Test - fun `shifting with bivariate function of complete range should not throw an error`() { + test("shifting with bivariate function of complete range should not throw an error") { val planeFunction = PlaneFunction(1.0, 1.0, 0.0, Range.all(), Range.all()) val sectionedPlane = SectionedBivariateFunction(planeFunction, Range.closed(1.0, 3.0), Range.all()) @@ -40,4 +36,4 @@ internal class SectionedBivariateFunctionTest { assertThat(actualResult.value).isEqualTo(1.0) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/univariate/combination/ConcatenatedFunctionTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/univariate/combination/ConcatenatedFunctionTest.kt index 745c0abf..ff6ee5cc 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/univariate/combination/ConcatenatedFunctionTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/analysis/function/univariate/combination/ConcatenatedFunctionTest.kt @@ -18,15 +18,14 @@ package io.rtron.math.analysis.function.univariate.combination import arrow.core.Either import arrow.core.nonEmptyListOf +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -internal class ConcatenatedFunctionTest { +class ConcatenatedFunctionTest : FunSpec({ - class TestCreationOfLinearFunctions { + context("TestCreationOfLinearFunctions") { - @Test - fun `concatenated function with absolute start at 0`() { + test("concatenated function with absolute start at 0") { val starts = listOf(0.0, 5.0) val intercepts = listOf(0.0, -5.0) val concatenatedFunction = ConcatenatedFunction.ofLinearFunctions(starts, intercepts) @@ -45,8 +44,7 @@ internal class ConcatenatedFunctionTest { assertThat(actualResult4.value).isEqualTo(-5.0) } - @Test - fun `concatenated function with absolute start at -2`() { + test("concatenated function with absolute start at -2") { val starts = listOf(-2.0, 3.0) val intercepts = listOf(0.0, -5.0) val concatenatedFunction = ConcatenatedFunction.ofLinearFunctions(starts, intercepts) @@ -65,8 +63,7 @@ internal class ConcatenatedFunctionTest { assertThat(actualResult4.value).isEqualTo(-5.0) } - @Test - fun `concatenated function with absolute start at 2`() { + test("concatenated function with absolute start at 2") { val starts = listOf(2.0, 7.0) val intercepts = listOf(0.0, -5.0) val concatenatedFunction = ConcatenatedFunction.ofLinearFunctions(starts, intercepts) @@ -86,10 +83,9 @@ internal class ConcatenatedFunctionTest { } } - class TestCreationOfPolynomialFunctions { + context("TestCreationOfPolynomialFunctions") { - @Test - fun `concatenated function with absolute start at 0`() { + test("concatenated function with absolute start at 0") { val starts = nonEmptyListOf(0.0, 5.0) val coefficients = nonEmptyListOf( doubleArrayOf(2.0, 3.0, 4.0, 1.0), @@ -113,8 +109,7 @@ internal class ConcatenatedFunctionTest { assertThat(actualResult4.value).isEqualTo(49.0) } - @Test - fun `concatenated function with absolute start at -2`() { + test("concatenated function with absolute start at -2") { val starts = nonEmptyListOf(-2.0, 3.0) val coefficients = nonEmptyListOf( doubleArrayOf(2.0, 3.0, 4.0, 1.0), @@ -138,8 +133,7 @@ internal class ConcatenatedFunctionTest { assertThat(actualResult4.value).isEqualTo(49.0) } - @Test - fun `concatenated function with absolute start at 2`() { + test("concatenated function with absolute start at 2") { val starts = nonEmptyListOf(2.0, 7.0) val coefficients = nonEmptyListOf( doubleArrayOf(2.0, 3.0, 4.0, 1.0), @@ -163,4 +157,4 @@ internal class ConcatenatedFunctionTest { assertThat(actualResult4.value).isEqualTo(49.0) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/Rotation3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/Rotation3DTest.kt index fd99d189..2d283613 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/Rotation3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/Rotation3DTest.kt @@ -16,6 +16,7 @@ package io.rtron.math.geometry.euclidean.threed +import io.kotest.core.spec.style.FunSpec import io.rtron.math.std.DBL_EPSILON import io.rtron.math.std.DBL_EPSILON_3 import io.rtron.math.std.HALF_PI @@ -23,75 +24,62 @@ import io.rtron.math.std.QUARTER_PI import io.rtron.math.std.TWO_PI import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Rotation3DTest { +class Rotation3DTest : FunSpec({ + context("TestAngleAssignments") { - @Nested - inner class TestAngleAssignments { - - @Test - fun `heading assignment with half pi`() { + test("heading assignment with half pi") { val actualHeading = Rotation3D(HALF_PI, 0.0, 0.0).heading assertThat(actualHeading).isCloseTo(HALF_PI, Offset.offset(DBL_EPSILON)) } - @Test - fun `heading assignment with two pi`() { + test("heading assignment with two pi") { val actualHeading = Rotation3D(TWO_PI, 0.0, 0.0).heading assertThat(actualHeading).isCloseTo(0.0, Offset.offset(DBL_EPSILON_3)) } - @Test - fun `heading assignment with two and a half pi`() { + test("heading assignment with two and a half pi") { val actualHeading = Rotation3D(HALF_PI + TWO_PI, 0.0, 0.0).heading assertThat(actualHeading).isCloseTo(HALF_PI, Offset.offset(DBL_EPSILON_3)) } - @Test - fun `pitch assignment with quarter pi`() { + test("pitch assignment with quarter pi") { val actualPitch = Rotation3D(0.0, QUARTER_PI, 0.0).pitch assertThat(actualPitch).isCloseTo(QUARTER_PI, Offset.offset(DBL_EPSILON)) } - @Test - fun `pitch assignment with two pi`() { + test("pitch assignment with two pi") { val actualPitch = Rotation3D(0.0, TWO_PI, 0.0).pitch assertThat(actualPitch).isCloseTo(0.0, Offset.offset(DBL_EPSILON_3)) } - @Test - fun `pitch assignment with two and a half pi`() { + test("pitch assignment with two and a half pi") { val actualPitch = Rotation3D(0.0, QUARTER_PI + TWO_PI, 0.0).pitch assertThat(actualPitch).isCloseTo(QUARTER_PI, Offset.offset(DBL_EPSILON_3)) } - @Test - fun `roll assignment with quarter pi`() { + test("roll assignment with quarter pi") { val actualRoll = Rotation3D(0.0, 0.0, HALF_PI).roll assertThat(actualRoll).isCloseTo(HALF_PI, Offset.offset(DBL_EPSILON)) } - @Test - fun `roll assignment with two pi`() { + test("roll assignment with two pi") { val actualRoll = Rotation3D(0.0, 0.0, TWO_PI).roll assertThat(actualRoll).isCloseTo(0.0, Offset.offset(DBL_EPSILON_3)) } - @Test - fun `roll assignment with two and a half pi`() { + test("roll assignment with two and a half pi") { val actualRoll = Rotation3D(0.0, 0.0, HALF_PI + TWO_PI).roll assertThat(actualRoll).isCloseTo(HALF_PI, Offset.offset(DBL_EPSILON_3)) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/Vector3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/Vector3DTest.kt index c5b4fa0c..59c7138a 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/Vector3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/Vector3DTest.kt @@ -16,23 +16,19 @@ package io.rtron.math.geometry.euclidean.threed +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.booleans.shouldBeFalse +import io.kotest.matchers.booleans.shouldBeTrue import io.rtron.math.geometry.euclidean.threed.point.Vector3D import io.rtron.math.std.HALF_PI import io.rtron.math.std.PI import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Vector3DTest { +class Vector3DTest : FunSpec({ + context("Addition") { - @Nested - inner class Addition { - - @Test - fun `adding points with positive coordinates`() { + test("adding points with positive coordinates") { val pointA = Vector3D(1.0, 1.0, 1.0) val pointB = Vector3D(1.0, 1.0, 1.0) @@ -41,8 +37,7 @@ internal class Vector3DTest { assertThat(actualSum).isEqualTo(Vector3D(2.0, 2.0, 2.0)) } - @Test - fun `adding points with negative coordinates`() { + test("adding points with negative coordinates") { val pointA = Vector3D(-10.0, -5.0, -1.0) val pointB = Vector3D(10.0, 5.0, 1.0) @@ -52,11 +47,9 @@ internal class Vector3DTest { } } - @Nested - inner class Subtraction { + context("Subtraction") { - @Test - fun `subtracting points with positive coordinates`() { + test("subtracting points with positive coordinates") { val pointA = Vector3D(4.0, 3.0, 2.0) val pointB = Vector3D(2.0, 1.0, 0.0) @@ -66,40 +59,33 @@ internal class Vector3DTest { } } - @Nested - inner class ScalarMultiplication { + context("ScalarMultiplication") { - @Test - fun `scalar multiplication of basic point (1,1,1)`() { + test("scalar multiplication of basic point (1,1,1)") { val actualResult = Vector3D(1.0, 1.0, 1.0).scalarMultiply(4.0) assertThat(actualResult).isEqualTo(Vector3D(4.0, 4.0, 4.0)) } } - @Nested - inner class ScalarDivision { + context("ScalarDivision") { - @Test - fun `scalar division of basic point`() { + test("scalar division of basic point") { val actualResult = Vector3D(2.0, 4.0, 1.0).scalarDivide(4.0) assertThat(actualResult).isEqualTo(Vector3D(0.5, 1.0, 0.25)) } - @Test - fun `scalar division by zero throws error`() { + test("scalar division by zero throws error") { Assertions.assertThatIllegalArgumentException().isThrownBy { Vector3D(2.0, 4.0, 1.0).scalarDivide(0.0) } } } - @Nested - inner class Normalize { + context("Normalize") { - @Test - fun `normalized does not violate immutability principle`() { + test("normalized does not violate immutability principle") { val point = Vector3D(2.0, 4.0, 1.0) point.normalized() @@ -108,11 +94,9 @@ internal class Vector3DTest { } } - @Nested - inner class Angle { + context("Angle") { - @Test - fun `half pi angle between axes`() { + test("half pi angle between axes") { val pointA = Vector3D(1.0, 0.0, 0.0) val pointB = Vector3D(0.0, 1.0, 0.0) @@ -121,8 +105,7 @@ internal class Vector3DTest { assertThat(actualSum).isEqualTo(HALF_PI) } - @Test - fun `adding points with positive coordinates`() { + test("adding points with positive coordinates") { val pointA = Vector3D(1.0, 1.0, 1.0) val pointB = Vector3D(-1.0, -1.0, -1.0) @@ -132,38 +115,34 @@ internal class Vector3DTest { } } - @Nested - inner class Equality { - @Test - fun `zero point equals zero point`() { + context("Equality") { + + test("zero point equals zero point") { val pointA = Vector3D(0.0, 0.0, 0.0) val pointB = Vector3D(0.0, 0.0, 0.0) - assertTrue(pointA == pointB) + (pointA == pointB).shouldBeTrue() } - @Test - fun `positive point equals positive point`() { + test("positive point equals positive point") { val pointA = Vector3D(4.0, 0.0, 2.0) val pointB = Vector3D(4.0, 0.0, 2.0) - assertTrue(pointA == pointB) + (pointA == pointB).shouldBeTrue() } - @Test - fun `positive point unequals positive point`() { + test("positive point unequals positive point") { val pointA = Vector3D(2.0, 0.0, 2.0) val pointB = Vector3D(4.0, 0.0, 2.0) - assertFalse(pointA == pointB) + (pointA == pointB).shouldBeFalse() } - @Test - fun `positive point unequals positive point with epsilon`() { + test("positive point unequals positive point with epsilon") { val pointA = Vector3D(2.0, 0.0, 2.0) val pointB = Vector3D(0.0, 0.0, 1.99999) - assertFalse(pointA == pointB) + (pointA == pointB).shouldBeFalse() } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/Curve3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/Curve3DTest.kt index deb2b1c8..18f16f20 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/Curve3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/Curve3DTest.kt @@ -16,6 +16,7 @@ package io.rtron.math.geometry.euclidean.threed.curve +import io.kotest.core.spec.style.FunSpec import io.rtron.math.analysis.function.univariate.pure.LinearFunction import io.rtron.math.geometry.curved.oned.point.CurveRelativeVector1D import io.rtron.math.geometry.euclidean.threed.point.Vector3D @@ -26,17 +27,12 @@ import io.rtron.math.std.HALF_PI import io.rtron.math.std.QUARTER_PI import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test import kotlin.math.sqrt -internal class Curve3DTest { +class Curve3DTest : FunSpec({ + context("TestTorsion") { - @Nested - inner class TestTorsion { - - @Test - fun `curve with zero torsion`() { + test("curve with zero torsion") { val curveXY = LineSegment2D.of(Vector2D.ZERO, Vector2D.X_AXIS, 0.0) val heightFunction = LinearFunction.X_AXIS val curve3D = Curve3D(curveXY, heightFunction) @@ -48,8 +44,7 @@ internal class Curve3DTest { assertThat(actualPointGlobal).isEqualTo(Vector3D(0.5, 1.0, 0.0)) } - @Test - fun `curve with constant torsion of quarter pi`() { + test("curve with constant torsion of quarter pi") { val curveXY = LineSegment2D.of(Vector2D.ZERO, Vector2D.X_AXIS, 0.0) val heightFunction = LinearFunction.X_AXIS val torsionFunction = LinearFunction(0.0, QUARTER_PI) @@ -63,8 +58,7 @@ internal class Curve3DTest { assertThat(actualPointGlobal.z).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) } - @Test - fun `curve with constant torsion of half pi`() { + test("curve with constant torsion of half pi") { val curveXY = LineSegment2D.of(Vector2D.ZERO, Vector2D.X_AXIS, 0.0) val heightFunction = LinearFunction.X_AXIS val torsionFunction = LinearFunction(0.0, HALF_PI) @@ -77,4 +71,4 @@ internal class Curve3DTest { assertThat(actualPointGlobal).isEqualTo(Vector3D(0.5, 0.0, 1.0)) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/Line3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/Line3DTest.kt index 1ac177b2..ac683ec9 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/Line3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/Line3DTest.kt @@ -16,21 +16,17 @@ package io.rtron.math.geometry.euclidean.threed.curve +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.threed.point.Vector3D import org.assertj.core.api.Assertions.assertThatIllegalArgumentException -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Line3DTest { +class Line3DTest : FunSpec({ + context("Addition") { - @Nested - inner class Addition { - - @Test - fun `throws error if `() { + test("throws error if ") { val point = Vector3D(1.0, 1.0, 1.0) assertThatIllegalArgumentException().isThrownBy { Line3D(point, point, 0.0) } } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/LineSegment3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/LineSegment3DTest.kt index 943debb2..4b527ba4 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/LineSegment3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/LineSegment3DTest.kt @@ -16,18 +16,14 @@ package io.rtron.math.geometry.euclidean.threed.curve +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.threed.point.Vector3D import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class LineSegment3DTest { +class LineSegment3DTest : FunSpec({ + context("TestDistance") { - @Nested - inner class TestDistance { - - @Test - fun `point located on line segment returns zero distance`() { + test("point located on line segment returns zero distance") { val lineSegment = LineSegment3D(Vector3D.ZERO, Vector3D.X_AXIS, 0.0) val point = Vector3D(0.5, 0.0, 0.0) val expectedDistance = 0.0 @@ -37,8 +33,7 @@ internal class LineSegment3DTest { assertThat(actualResultingVertices).isEqualTo(expectedDistance) } - @Test - fun `point located outside of line segment returns the distance to closest boundary point`() { + test("point located outside of line segment returns the distance to closest boundary point") { val lineSegment = LineSegment3D(Vector3D.ZERO, Vector3D.X_AXIS, 0.0) val point = Vector3D(1.5, 0.0, 0.0) val expectedDistance = 0.5 @@ -48,8 +43,7 @@ internal class LineSegment3DTest { assertThat(actualResultingVertices).isEqualTo(expectedDistance) } - @Test - fun `point located not on line segment returns the correct distance`() { + test("point located not on line segment returns the correct distance") { val lineSegment = LineSegment3D(Vector3D.ZERO, Vector3D.X_AXIS, 0.0) val point = Vector3D(0.5, 2.3, 0.0) val expectedDistance = 2.3 @@ -59,8 +53,7 @@ internal class LineSegment3DTest { assertThat(actualResultingVertices).isEqualTo(expectedDistance) } - @Test - fun `boundary point of line segment returns the zero distance`() { + test("boundary point of line segment returns the zero distance") { val lineSegment = LineSegment3D(Vector3D.ZERO, Vector3D.X_AXIS, 0.0) val point = Vector3D.X_AXIS val expectedDistance = 0.0 @@ -70,8 +63,7 @@ internal class LineSegment3DTest { assertThat(actualResultingVertices).isEqualTo(expectedDistance) } - @Test - fun `point on line but outside of line segment return distances to the shortest boundary point`() { + test("point on line but outside of line segment return distances to the shortest boundary point") { val lineSegment = LineSegment3D(Vector3D.ZERO, Vector3D.X_AXIS, 0.0) val point = Vector3D(1.5, 0.0, 0.0) val expectedDistance = 0.5 @@ -81,4 +73,4 @@ internal class LineSegment3DTest { assertThat(actualResultingVertices).isEqualTo(expectedDistance) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/LineString3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/LineString3DTest.kt index d3eeafd6..b0eafb3b 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/LineString3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/curve/LineString3DTest.kt @@ -18,21 +18,17 @@ package io.rtron.math.geometry.euclidean.threed.curve import arrow.core.Either import arrow.core.nonEmptyListOf +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.curved.oned.point.CurveRelativeVector1D import io.rtron.math.geometry.euclidean.threed.point.Vector3D import io.rtron.math.std.DBL_EPSILON import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class LineString3DTest { +class LineString3DTest : FunSpec({ + context("TestLengthCalculation") { - @Nested - inner class TestLengthCalculation { - - @Test - fun `line string with two points should have a length of 1`() { + test("line string with two points should have a length of 1") { val lineString = LineString3D(nonEmptyListOf(Vector3D.ZERO, Vector3D.X_AXIS), 0.0) val actualLength = lineString.length @@ -40,8 +36,7 @@ internal class LineString3DTest { assertThat(actualLength).isEqualTo(1.0) } - @Test - fun `line string with multiple points should have a length of 1`() { + test("line string with multiple points should have a length of 1") { val pointA = Vector3D.ZERO val pointB = Vector3D(1.0, 0.0, 0.0) val pointC = Vector3D(1.0, 1.0, 0.0) @@ -54,11 +49,9 @@ internal class LineString3DTest { } } - @Nested - inner class TestPointCalculation { + context("TestPointCalculation") { - @Test - fun `line string with two points yields point in the middle`() { + test("line string with two points yields point in the middle") { val pointA = Vector3D.ZERO val pointB = Vector3D(0.0, 10.0, 0.0) val lineString = LineString3D(nonEmptyListOf(pointA, pointB), 0.0) @@ -72,8 +65,7 @@ internal class LineString3DTest { assertThat(actualReturn.value.z).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) } - @Test - fun `line string with multiple points yields point on the top`() { + test("line string with multiple points yields point on the top") { val pointA = Vector3D.ZERO val pointB = Vector3D(1.0, 0.0, 0.0) val pointC = Vector3D(1.0, 1.0, 0.0) @@ -89,4 +81,4 @@ internal class LineString3DTest { assertThat(actualReturn.value.z).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/point/Pose3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/point/Pose3DTest.kt index 33fd8030..b616a8c8 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/point/Pose3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/point/Pose3DTest.kt @@ -16,22 +16,18 @@ package io.rtron.math.geometry.euclidean.threed.point +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.threed.Pose3D import io.rtron.math.geometry.euclidean.threed.Rotation3D import io.rtron.math.geometry.euclidean.twod.Pose2D import io.rtron.math.geometry.euclidean.twod.Rotation2D import io.rtron.math.geometry.euclidean.twod.point.Vector2D import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Pose3DTest { +class Pose3DTest : FunSpec({ + context("TestConversionToPose2D") { - @Nested - inner class TestConversionToPose2D { - - @Test - fun `conversion to pose2D within x-z-plane `() { + test("conversion to pose2D within x-z-plane ") { val point = Vector3D(1.0, 2.0, 3.0) val rotation = Rotation3D(1.0, 2.0, 3.0) val pose3D = Pose3D(point, rotation) @@ -42,4 +38,4 @@ internal class Pose3DTest { assertThat(actualPose2D).isEqualTo(expectedPose2D) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/solid/Cuboid3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/solid/Cuboid3DTest.kt index 1593870c..91461a76 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/solid/Cuboid3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/solid/Cuboid3DTest.kt @@ -16,19 +16,15 @@ package io.rtron.math.geometry.euclidean.threed.solid +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.threed.point.Vector3D import io.rtron.math.geometry.euclidean.threed.surface.Polygon3D import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Cuboid3DTest { +class Cuboid3DTest : FunSpec({ + context("PolygonsGeneration") { - @Nested - inner class PolygonsGeneration { - - @Test - fun `correct number of polygons`() { + test("correct number of polygons") { val cuboid = Cuboid3D.UNIT val actualPolygons = cuboid.calculatePolygonsGlobalCS() @@ -36,8 +32,7 @@ internal class Cuboid3DTest { assertThat(actualPolygons).hasSize(6) } - @Test - fun `generated polygons list contain base polygon`() { + test("generated polygons list contain base polygon") { val length = 6.0 val width = 4.0 val cuboid = Cuboid3D(length = length, width = width, height = 1.0, tolerance = 0.0) @@ -52,8 +47,7 @@ internal class Cuboid3DTest { assertThat(actualPolygons).contains(expectedBasePolygon) } - @Test - fun `generated polygons list contain elevated polygon`() { + test("generated polygons list contain elevated polygon") { val length = 5.0 val width = 3.0 val height = 1.0 @@ -69,8 +63,7 @@ internal class Cuboid3DTest { assertThat(actualPolygons).contains(expectedBasePolygon) } - @Test - fun `generated polygons list contain front polygon`() { + test("generated polygons list contain front polygon") { val length = 5.0 val width = 3.0 val height = 1.0 @@ -86,4 +79,4 @@ internal class Cuboid3DTest { assertThat(actualPolygons).contains(expectedBasePolygon) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/solid/Cylinder3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/solid/Cylinder3DTest.kt index 9ebc78f8..8d325845 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/solid/Cylinder3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/solid/Cylinder3DTest.kt @@ -16,23 +16,20 @@ package io.rtron.math.geometry.euclidean.threed.solid +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.booleans.shouldBeTrue import io.rtron.math.std.DBL_EPSILON_1 import io.rtron.math.transform.AffineSequence3D -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Cylinder3DTest { +class Cylinder3DTest : FunSpec({ + context("PolygonsGeneration") { - @Nested - inner class PolygonsGeneration { - @Test - fun `polygons start at level zero`() { + test("polygons start at level zero") { val cylinder = Cylinder3D(0.5, 1.0, DBL_EPSILON_1, AffineSequence3D.EMPTY) val actualPolygons = cylinder.calculatePolygonsGlobalCS() - assertTrue(actualPolygons.any { polygon -> polygon.vertices.any { it.z == 0.0 } }) + actualPolygons.any { polygon -> polygon.vertices.any { it.z == 0.0 } }.shouldBeTrue() } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/surface/LinearRing3DUtilTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/surface/LinearRing3DUtilTest.kt index 9667a093..f9c12f2d 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/surface/LinearRing3DUtilTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/surface/LinearRing3DUtilTest.kt @@ -16,19 +16,15 @@ package io.rtron.math.geometry.euclidean.threed.surface +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.threed.point.Vector3D import io.rtron.math.processing.removeConsecutiveSideDuplicates import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class LinearRing3DUtilTest { +class LinearRing3DUtilTest : FunSpec({ + context("TestRemoveCuts") { - @Nested - inner class TestRemoveCuts { - - @Test - fun `remove cut with edge matching pattern`() { + test("remove cut with edge matching pattern") { val pointA = Vector3D.ZERO val pointB = Vector3D(-1.0, -1.0, 0.0) val pointC = Vector3D.X_AXIS @@ -41,4 +37,4 @@ internal class LinearRing3DUtilTest { assertThat(actualRemovedVerticesList).isEqualTo(expected) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/surface/Polygon3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/surface/Polygon3DTest.kt index 4aec2778..3dd6d2ef 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/surface/Polygon3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/threed/surface/Polygon3DTest.kt @@ -18,41 +18,34 @@ package io.rtron.math.geometry.euclidean.threed.surface import arrow.core.Either import arrow.core.nonEmptyListOf +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.threed.point.Vector3D import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatIllegalArgumentException -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Polygon3DTest { +class Polygon3DTest : FunSpec({ + context("TestCreation") { - @Nested - inner class TestCreation { - - @Test - fun `creation of polygon with only two points should fail`() { + test("creation of polygon with only two points should fail") { val pointA = Vector3D(0.0, 0.0, 0.0) val pointB = Vector3D(1.0, 1.0, 1.0) assertThatIllegalArgumentException().isThrownBy { Polygon3D(nonEmptyListOf(pointA, pointB), 0.0) } } - @Test - fun `creation of polygon with only one point should fail`() { + test("creation of polygon with only one point should fail") { val pointA = Vector3D(0.0, 0.0, 0.0) assertThatIllegalArgumentException().isThrownBy { Polygon3D(nonEmptyListOf(pointA), 0.0) } } - @Test - fun `creation of polygon with no point should fail`() { + test("creation of polygon with no point should fail") { val pointA = Vector3D(0.0, 0.0, 0.0) assertThatIllegalArgumentException().isThrownBy { Polygon3D(nonEmptyListOf(pointA), 0.0) } } - @Test - fun `creation of polygon with consecutive point duplicates should fail`() { + test("creation of polygon with consecutive point duplicates should fail") { val pointA = Vector3D(0.0, 0.0, 0.0) val pointB = Vector3D(1.0, 1.0, 1.0) @@ -60,8 +53,7 @@ internal class Polygon3DTest { .isThrownBy { Polygon3D(nonEmptyListOf(pointA, pointB, pointA), 0.0) } } - @Test - fun `creation of polygon with three colinear points should fail`() { + test("creation of polygon with three colinear points should fail") { val pointA = Vector3D(1.0, 2.0, 0.0) val pointB = Vector3D(2.0, 3.0, 0.0) val pointC = Vector3D(3.0, 4.0, 0.0) @@ -70,8 +62,7 @@ internal class Polygon3DTest { .isThrownBy { Polygon3D(nonEmptyListOf(pointA, pointB, pointC), 0.0) } } - @Test - fun `creation of polygon with non-planar points should fail`() { + test("creation of polygon with non-planar points should fail") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS val pointC = Vector3D.Y_AXIS @@ -82,11 +73,9 @@ internal class Polygon3DTest { } } - @Nested - inner class TestNormalCalculation { + context("TestNormalCalculation") { - @Test - fun `normal of triangle polygon`() { + test("normal of triangle polygon") { val pointA = Vector3D(1.0, 1.0, 1.0) val pointB = Vector3D(2.0, 1.0, 1.0) val pointC = Vector3D(2.0, 2.0, 1.0) @@ -99,8 +88,7 @@ internal class Polygon3DTest { assertThat(actualReturn.value).isEqualTo(Vector3D.Z_AXIS) } - @Test - fun `test planar quadrilateral polygon`() { + test("test planar quadrilateral polygon") { val planarQuadrilateral = Polygon3D( nonEmptyListOf( Vector3D.ZERO, @@ -119,4 +107,4 @@ internal class Polygon3DTest { assertThat(actualReturn.value).isEqualTo(expectedResult) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/Pose2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/Pose2DTest.kt index 93d7dbe7..23a131c2 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/Pose2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/Pose2DTest.kt @@ -16,47 +16,40 @@ package io.rtron.math.geometry.euclidean.twod +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.twod.point.Vector2D import io.rtron.math.std.PI import io.rtron.math.std.TWO_PI import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Pose2DTest { +class Pose2DTest : FunSpec({ + context("TestPointAssignment") { - @Nested - inner class TestPointAssignment { - - @Test - fun `assignment of positive point`() { + test("assignment of positive point") { val pose = Pose2D(Vector2D(5.0, 3.0), Rotation2D.ZERO) assertThat(pose.point).isEqualTo(Vector2D(5.0, 3.0)) } - @Test - fun `assignment of negative point`() { + test("assignment of negative point") { val pose = Pose2D(Vector2D(-3.0, 1.0), Rotation2D.ZERO) assertThat(pose.point).isEqualTo(Vector2D(-3.0, 1.0)) } } - @Nested - inner class TestRotationAssignment { - @Test - fun `assignment of two pi rotation`() { + context("TestRotationAssignment") { + + test("assignment of two pi rotation") { val pose = Pose2D(Vector2D(5.0, 3.0), Rotation2D(TWO_PI)) assertThat(pose.rotation.toAngleRadians()).isEqualTo(0.0) } - @Test - fun `assignment of pi rotation`() { + test("assignment of pi rotation") { val pose = Pose2D(Vector2D(-3.0, 1.0), Rotation2D(PI)) assertThat(pose.rotation.toAngleRadians()).isEqualTo(PI) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/Rotation2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/Rotation2DTest.kt index 4e14a8ed..33e64c54 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/Rotation2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/Rotation2DTest.kt @@ -16,88 +16,78 @@ package io.rtron.math.geometry.euclidean.twod +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.booleans.shouldBeFalse +import io.kotest.matchers.booleans.shouldBeTrue import io.rtron.math.std.DBL_EPSILON_1 import io.rtron.math.std.DBL_EPSILON_2 import io.rtron.math.std.DBL_EPSILON_4 import io.rtron.math.std.TWO_PI -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Rotation2DTest { +class Rotation2DTest : FunSpec({ + context("TestFuzzyEquals") { - @Nested - inner class TestFuzzyEquals { - - @Test - fun `two rotations with same angle are fuzzily equal`() { + test("two rotations with same angle are fuzzily equal") { val rotationA = Rotation2D(1.3) val rotationB = Rotation2D(1.3) val actualEquality = rotationA.fuzzyEquals(rotationB, DBL_EPSILON_1) - assertTrue(actualEquality) + actualEquality.shouldBeTrue() } - @Test - fun `two rotations with different angle are not fuzzily equal`() { + test("two rotations with different angle are not fuzzily equal") { val rotationA = Rotation2D(1.3) val rotationB = Rotation2D(1.4) val actualEquality = rotationA.fuzzyEquals(rotationB, DBL_EPSILON_1) - assertFalse(actualEquality) + actualEquality.shouldBeFalse() } - @Test - fun `two rotations at zero radians and two pi minus epsilon radians are fuzzily equal`() { + test("two rotations at zero radians and two pi minus epsilon radians are fuzzily equal") { val rotationA = Rotation2D.ZERO val rotationB = Rotation2D(TWO_PI - DBL_EPSILON_2) val actualEquality = rotationA.fuzzyEquals(rotationB, DBL_EPSILON_2) - assertTrue(actualEquality) + actualEquality.shouldBeTrue() } - @Test - fun `two rotations at zero radians and two pi plus epsilon radians are fuzzily equal`() { + test("two rotations at zero radians and two pi plus epsilon radians are fuzzily equal") { val rotationA = Rotation2D.ZERO val rotationB = Rotation2D(TWO_PI + DBL_EPSILON_2) val actualEquality = rotationA.fuzzyEquals(rotationB, DBL_EPSILON_2) - assertTrue(actualEquality) + actualEquality.shouldBeTrue() } - @Test - fun `two rotations at two pi minus epsilon radians and zero radians are fuzzily equal`() { + test("two rotations at two pi minus epsilon radians and zero radians are fuzzily equal") { val rotationA = Rotation2D(TWO_PI - DBL_EPSILON_2) val rotationB = Rotation2D.ZERO val actualEquality = rotationA.fuzzyEquals(rotationB, DBL_EPSILON_2) - assertTrue(actualEquality) + actualEquality.shouldBeTrue() } - @Test - fun `two rotations at two pi plus epsilon radians and zero radians are fuzzily equal`() { + test("two rotations at two pi plus epsilon radians and zero radians are fuzzily equal") { val rotationA = Rotation2D(TWO_PI + DBL_EPSILON_2) val rotationB = Rotation2D.ZERO val actualEquality = rotationA.fuzzyEquals(rotationB, DBL_EPSILON_2) - assertTrue(actualEquality) + actualEquality.shouldBeTrue() } - @Test - fun `two rotations at two pi plus larger epsilon radians and zero radians are not fuzzily equal`() { + test("two rotations at two pi plus larger epsilon radians and zero radians are not fuzzily equal") { val rotationA = Rotation2D(TWO_PI + DBL_EPSILON_4) val rotationB = Rotation2D.ZERO val actualEquality = rotationA.fuzzyEquals(rotationB, DBL_EPSILON_2) - assertFalse(actualEquality) + actualEquality.shouldBeFalse() } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/Arc2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/Arc2DTest.kt index d0c4e82a..ca9ddabb 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/Arc2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/Arc2DTest.kt @@ -17,6 +17,7 @@ package io.rtron.math.geometry.euclidean.twod.curve import arrow.core.Either +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.curved.oned.point.CurveRelativeVector1D import io.rtron.math.geometry.euclidean.twod.Rotation2D import io.rtron.math.geometry.euclidean.twod.point.Vector2D @@ -28,16 +29,11 @@ import io.rtron.math.transform.Affine2D import io.rtron.math.transform.AffineSequence2D import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Arc2DTest { +class Arc2DTest : FunSpec({ + context("TestCenterCalculation") { - @Nested - inner class TestCenterCalculation { - - @Test - fun `unit curvature with center above origin`() { + test("unit curvature with center above origin") { val arc = Arc2D(1.0, 2.0, 0.0) val actualCenter = arc.center @@ -45,8 +41,7 @@ internal class Arc2DTest { assertThat(actualCenter).isEqualTo(Vector2D(0.0, 1.0)) } - @Test - fun `unit curvature with center below origin`() { + test("unit curvature with center below origin") { val arc = Arc2D(-1.0, 2.0, 0.0) val actualCenter = arc.center @@ -55,11 +50,9 @@ internal class Arc2DTest { } } - @Nested - inner class TestStartAngleCalculation { + context("TestStartAngleCalculation") { - @Test - fun `starting angle with center above origin`() { + test("starting angle with center above origin") { val arc = Arc2D(1.0, HALF_PI, 0.0) val actualStartAngle = arc.startAngle.toAngleRadians() @@ -67,8 +60,7 @@ internal class Arc2DTest { assertThat(actualStartAngle).isEqualTo(PI + HALF_PI) } - @Test - fun `starting angle with center below origin`() { + test("starting angle with center below origin") { val arc = Arc2D(-1.0, HALF_PI, 0.0) val actualStartAngle = arc.startAngle.toAngleRadians() @@ -77,11 +69,9 @@ internal class Arc2DTest { } } - @Nested - inner class TestEndAngleCalculation { + context("TestEndAngleCalculation") { - @Test - fun `ending angle at 0`() { + test("ending angle at 0") { val arc = Arc2D(1.0, HALF_PI, 0.0) val actualEndAngle = arc.endAngle.toAngleRadians() @@ -90,11 +80,9 @@ internal class Arc2DTest { } } - @Nested - inner class TestLocalPoseCalculation { + context("TestLocalPoseCalculation") { - @Test - fun `calculate pose point on the start`() { + test("calculate pose point on the start") { val arc = Arc2D(1.0, TWO_PI, 0.0, AffineSequence2D.EMPTY) val actualReturn = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO) @@ -104,8 +92,7 @@ internal class Arc2DTest { assertThat(actualReturn.value.point).isEqualTo(Vector2D.ZERO) } - @Test - fun `calculate pose point on the curve`() { + test("calculate pose point on the curve") { val arc = Arc2D(1.0, TWO_PI, 0.0, AffineSequence2D.EMPTY) val curveRelativePoint = CurveRelativeVector1D(HALF_PI) @@ -116,8 +103,7 @@ internal class Arc2DTest { assertThat(actualReturn.value.point).isEqualTo(Vector2D(1.0, 1.0)) } - @Test - fun `calculate pose angle on the start`() { + test("calculate pose angle on the start") { val arc = Arc2D(1.0, TWO_PI, 0.0, AffineSequence2D.EMPTY) val actualReturn = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO) @@ -127,8 +113,7 @@ internal class Arc2DTest { assertThat(actualReturn.value.rotation.toAngleRadians()).isEqualTo(0.0) } - @Test - fun `calculate pose angle on the curve`() { + test("calculate pose angle on the curve") { val arc = Arc2D(1.0, TWO_PI, 0.0, AffineSequence2D.EMPTY) val curveRelativePoint = CurveRelativeVector1D(HALF_PI) @@ -140,11 +125,9 @@ internal class Arc2DTest { } } - @Nested - inner class TestGlobalPoseCalculation { + context("TestGlobalPoseCalculation") { - @Test - fun `calculate pose point on the start`() { + test("calculate pose point on the start") { val point = Vector2D(3.0, 5.0) val rotation = Rotation2D(HALF_PI) val affine = Affine2D.of(point, rotation) @@ -158,8 +141,7 @@ internal class Arc2DTest { assertThat(actualReturn.value.point).isEqualTo(Vector2D(3.0, 5.0)) } - @Test - fun `calculate pose point on the curve`() { + test("calculate pose point on the curve") { val point = Vector2D(3.0, 5.0) val rotation = Rotation2D(HALF_PI) val affine = Affine2D.of(point, rotation) @@ -174,8 +156,7 @@ internal class Arc2DTest { assertThat(actualReturn.value.point).isEqualTo(Vector2D(2.0, 6.0)) } - @Test - fun `calculate pose in fourth quadrant`() { + test("calculate pose in fourth quadrant") { val point = Vector2D(60.0, -50.0) val rotation = Rotation2D(5.5) val affine = Affine2D.of(point, rotation) @@ -190,8 +171,7 @@ internal class Arc2DTest { assertThat(actualReturn.value.point.y).isCloseTo(point.y, Offset.offset(DBL_EPSILON_4)) } - @Test - fun `calculate pose angle on the start`() { + test("calculate pose angle on the start") { val point = Vector2D(3.0, 5.0) val rotation = Rotation2D(HALF_PI) val affine = Affine2D.of(point, rotation) @@ -205,8 +185,7 @@ internal class Arc2DTest { assertThat(actualReturn.value.rotation.toAngleRadians()).isEqualTo(HALF_PI) } - @Test - fun `calculate pose angle on the curve`() { + test("calculate pose angle on the curve") { val point = Vector2D(3.0, 5.0) val rotation = Rotation2D(HALF_PI) val affine = Affine2D.of(point, rotation) @@ -221,8 +200,7 @@ internal class Arc2DTest { assertThat(actualReturn.value.rotation.toAngleRadians()).isEqualTo(PI) } - @Test - fun `calculate pose angle in fourth quadrant`() { + test("calculate pose angle in fourth quadrant") { val point = Vector2D(3.0, 5.0) val rotation = Rotation2D(HALF_PI) val affine = Affine2D.of(point, rotation) @@ -237,4 +215,4 @@ internal class Arc2DTest { assertThat(actualReturn.value.rotation.toAngleRadians()).isEqualTo(PI + HALF_PI) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/CompositeCurve2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/CompositeCurve2DTest.kt index 90a8bb67..dfdba318 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/CompositeCurve2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/CompositeCurve2DTest.kt @@ -17,6 +17,7 @@ package io.rtron.math.geometry.euclidean.twod.curve import arrow.core.Either +import io.kotest.core.spec.style.FunSpec import io.rtron.math.analysis.function.univariate.pure.LinearFunction import io.rtron.math.geometry.curved.oned.point.CurveRelativeVector1D import io.rtron.math.geometry.euclidean.twod.Rotation2D @@ -27,16 +28,11 @@ import io.rtron.math.transform.Affine2D import io.rtron.math.transform.AffineSequence2D import io.rtron.std.cumulativeSum import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class CompositeCurve2DTest { +class CompositeCurve2DTest : FunSpec({ + context("TestPoseCalculation") { - @Nested - inner class TestPoseCalculation { - - @Test - fun `calculating last point on curve is not NaN`() { + test("calculating last point on curve is not NaN") { val tolerance = DBL_EPSILON_7 // example from Crossing8Course road with id=515 @@ -104,4 +100,4 @@ internal class CompositeCurve2DTest { assertThat(actualPoint.value.point).isNotEqualTo(Vector2D.ZERO) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/CubicCurve2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/CubicCurve2DTest.kt index 58a95abb..7a35ae5b 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/CubicCurve2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/CubicCurve2DTest.kt @@ -17,6 +17,7 @@ package io.rtron.math.geometry.euclidean.twod.curve import arrow.core.Either +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.curved.oned.point.CurveRelativeVector1D import io.rtron.math.geometry.euclidean.twod.Pose2D import io.rtron.math.geometry.euclidean.twod.Rotation2D @@ -27,16 +28,11 @@ import io.rtron.math.transform.Affine2D import io.rtron.math.transform.AffineSequence2D import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class CubicCurve2DTest { +class CubicCurve2DTest : FunSpec({ + context("TestPoseCalculation") { - @Nested - inner class TestPoseCalculation { - - @Test - fun `pose calculation of straight line`() { + test("pose calculation of straight line") { val coefficients = doubleArrayOf(0.0, 1.0, 0.0, 0.0) val pose = Pose2D(Vector2D(0.0, 0.0), Rotation2D(0.0)) val affine = Affine2D.of(pose) @@ -53,8 +49,7 @@ internal class CubicCurve2DTest { assertThat(actualReturn.value.rotation.angle).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) } - @Test - fun `pose calculation of straight line with start pose offset`() { + test("pose calculation of straight line with start pose offset") { val coefficients = doubleArrayOf(0.0, 1.0, 0.0, 0.0) val pose = Pose2D(Vector2D(0.0, 0.0), Rotation2D(HALF_PI)) val affine = Affine2D.of(pose) @@ -74,8 +69,8 @@ internal class CubicCurve2DTest { * Cubic curve geometry from the poly3 example dataset of [ASAM](https://www.asam.net/standards/detail/opendrive/). * The sample dataset contains gaps between the geometry elements of the reference line. */ - @Test - fun `cubic curve geometry from OpenDRIVE poly3 example dataset with gap to the next curve element`() { + + test("cubic curve geometry from OpenDRIVE poly3 example dataset with gap to the next curve element") { val coefficients = doubleArrayOf(0.0, 0.0, 1.1010160043712483e-02, -4.0376563467901658e-04) val pose = Pose2D(Vector2D(-2.6331198952545350e+01, -7.4309373646250769e+00), Rotation2D(6.7579136200528211e-01)) val affine = Affine2D.of(pose) @@ -93,4 +88,4 @@ internal class CubicCurve2DTest { assertThat(actualReturn.value.rotation.angle).isNotCloseTo(3.8412114603351055e-01, Offset.offset(DBL_EPSILON)) // not coincident with next curve element } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/LineSegment2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/LineSegment2DTest.kt index 90dd48c5..55b8f539 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/LineSegment2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/LineSegment2DTest.kt @@ -17,6 +17,7 @@ package io.rtron.math.geometry.euclidean.twod.curve import arrow.core.Either +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.curved.oned.point.CurveRelativeVector1D import io.rtron.math.geometry.euclidean.twod.point.Vector2D import io.rtron.math.std.DBL_EPSILON @@ -24,16 +25,12 @@ import io.rtron.math.std.HALF_PI import io.rtron.math.std.QUARTER_PI import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test import kotlin.math.sqrt -internal class LineSegment2DTest { +class LineSegment2DTest : FunSpec({ + context("TestLengthCalculation") { - @Nested - inner class TestLengthCalculation { - @Test - fun `length of line segment on axis`() { + test("length of line segment on axis") { val pointA = Vector2D(0.0, 0.0) val pointB = Vector2D(7.0, 0.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) @@ -41,8 +38,7 @@ internal class LineSegment2DTest { assertThat(lineSegment.length).isCloseTo(7.0, Offset.offset(DBL_EPSILON)) } - @Test - fun `length of diagonal line segment`() { + test("length of diagonal line segment") { val pointA = Vector2D(3.0, 0.0) val pointB = Vector2D(0.0, 4.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) @@ -51,10 +47,9 @@ internal class LineSegment2DTest { } } - @Nested - inner class TestPoseAngleCalculation { - @Test - fun `angle of line segment on axis`() { + context("TestPoseAngleCalculation") { + + test("angle of line segment on axis") { val pointA = Vector2D(0.0, 0.0) val pointB = Vector2D(0.0, 1.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) @@ -66,8 +61,7 @@ internal class LineSegment2DTest { assertThat(actualReturn.value.rotation.angle).isEqualTo(HALF_PI) } - @Test - fun `angle of diagonal line segment`() { + test("angle of diagonal line segment") { val pointA = Vector2D(0.0, 0.0) val pointB = Vector2D(1.0, 1.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) @@ -80,10 +74,9 @@ internal class LineSegment2DTest { } } - @Nested - inner class TestPosePointCalculation { - @Test - fun `point on line segment on axis`() { + context("TestPosePointCalculation") { + + test("point on line segment on axis") { val pointA = Vector2D(0.0, 0.0) val pointB = Vector2D(10.0, 0.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) @@ -96,8 +89,7 @@ internal class LineSegment2DTest { assertThat(actualReturn.value.point).isEqualTo(Vector2D(5.0, 0.0)) } - @Test - fun `point on diagonal line segment on axis`() { + test("point on diagonal line segment on axis") { val pointA = Vector2D(0.0, 0.0) val pointB = Vector2D(1.0, 1.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) @@ -111,8 +103,7 @@ internal class LineSegment2DTest { assertThat(actualReturn.value.point.y).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) } - @Test - fun `point on diagonal line segment on axis 2`() { + test("point on diagonal line segment on axis 2") { val pointA = Vector2D(-1.0, 0.0) val pointB = Vector2D(0.0, 0.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) @@ -125,4 +116,4 @@ internal class LineSegment2DTest { assertThat(actualReturn.value.point).isEqualTo(Vector2D(0.0, 0.0)) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/ParametricCubicCurve2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/ParametricCubicCurve2DTest.kt index dd205af6..6f660258 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/ParametricCubicCurve2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/ParametricCubicCurve2DTest.kt @@ -17,6 +17,7 @@ package io.rtron.math.geometry.euclidean.twod.curve import arrow.core.Either +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.curved.oned.point.CurveRelativeVector1D import io.rtron.math.geometry.euclidean.twod.Rotation2D import io.rtron.math.geometry.euclidean.twod.point.Vector2D @@ -28,16 +29,12 @@ import io.rtron.math.transform.Affine2D import io.rtron.math.transform.AffineSequence2D import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test import kotlin.math.sqrt -internal class ParametricCubicCurve2DTest { +class ParametricCubicCurve2DTest : FunSpec({ + context("TestPoseCalculation") { - @Nested - inner class TestPoseCalculation { - @Test - fun `simple quadratic curve`() { + test("simple quadratic curve") { val coefficientX = doubleArrayOf(0.0, 1.0, 0.0, 0.0) val coefficientY = doubleArrayOf(0.0, 0.0, 1.0, 0.0) val curve = ParametricCubicCurve2D(coefficientX, coefficientY, 10.0, 0.0) @@ -50,8 +47,7 @@ internal class ParametricCubicCurve2DTest { assertThat(actualReturn.value.point).isEqualTo(Vector2D(2.0, 4.0)) } - @Test - fun `simple linear curve`() { + test("simple linear curve") { val coefficientX = doubleArrayOf(0.0, 1.0, 0.0, 0.0) val coefficientY = doubleArrayOf(0.0, 0.0, 0.0, 0.0) val affine = Affine2D.of(Vector2D.ZERO, Rotation2D(QUARTER_PI)) @@ -67,8 +63,7 @@ internal class ParametricCubicCurve2DTest { assertThat(actualReturn.value.point.y).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) } - @Test - fun `simple quadratic negative curve`() { + test("simple quadratic negative curve") { val coefficientX = doubleArrayOf(0.0, 1.0, 0.0, 0.0) val coefficientY = doubleArrayOf(0.0, 0.0, 1.0, 0.0) val affine = Affine2D.of(Vector2D.ZERO, Rotation2D(PI)) @@ -84,8 +79,7 @@ internal class ParametricCubicCurve2DTest { assertThat(actualReturn.value.point.y).isCloseTo(-4.0, Offset.offset(DBL_EPSILON_2)) } - @Test - fun `quadratic curve`() { + test("quadratic curve") { val coefficientX = doubleArrayOf(0.0, 1.0, 0.0, 0.0) val coefficientY = doubleArrayOf(0.0, 0.0, 1.0, 0.0) val length = 1.479 @@ -100,4 +94,4 @@ internal class ParametricCubicCurve2DTest { assertThat(actualReturn.value.point.y).isCloseTo(length * length, Offset.offset(DBL_EPSILON)) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/Spiral2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/Spiral2DTest.kt index e8544c86..e26a5af4 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/Spiral2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/Spiral2DTest.kt @@ -16,6 +16,7 @@ package io.rtron.math.geometry.euclidean.twod.curve +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.twod.Rotation2D import io.rtron.math.geometry.euclidean.twod.point.Vector2D import io.rtron.math.std.DBL_EPSILON @@ -28,21 +29,16 @@ import org.apache.commons.csv.CSVFormat import org.apache.commons.csv.CSVRecord import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test import java.io.FileReader import java.lang.Math.abs import kotlin.io.path.Path import kotlin.io.path.absolute import kotlin.io.path.exists -internal class Spiral2DTest { +class Spiral2DTest : FunSpec({ + context("TestPointCalculation") { - @Nested - inner class TestPointCalculation { - - @Test - fun `return (0,0) at l=0`() { + test("return (0,0) at l=0") { val spiral = Spiral2D(1.0) val actualPoint = spiral.calculatePoint(0.0) @@ -50,8 +46,7 @@ internal class Spiral2DTest { assertThat(actualPoint).isEqualTo(Vector2D.ZERO) } - @Test - fun `return asymptotic point at l=+infinity`() { + test("return asymptotic point at l=+infinity") { val asymptoticPoint = Vector2D(0.5, 0.5) val spiral = Spiral2D(PI) @@ -61,8 +56,7 @@ internal class Spiral2DTest { assertThat(actualPoint.y).isCloseTo(asymptoticPoint.y, Offset.offset(DBL_EPSILON_1)) } - @Test - fun `return asymptotic point at l=-infinity`() { + test("return asymptotic point at l=-infinity") { val asymptoticPoint = Vector2D(-0.5, -0.5) val spiral = Spiral2D(PI) @@ -73,11 +67,9 @@ internal class Spiral2DTest { } } - @Nested - inner class TestRotationCalculation { + context("TestRotationCalculation") { - @Test - fun `return 0 at l=0`() { + test("return 0 at l=0") { val spiral = Spiral2D(1.0) val actualRotation = spiral.calculateRotation(0.0) @@ -86,17 +78,15 @@ internal class Spiral2DTest { } } - @Nested - inner class TestDatasetCalculation { + context("TestDatasetCalculation") { - private val logger = KotlinLogging.logger {} + val logger = KotlinLogging.logger {} - @Test - fun `test point and rotation calculation against csv sample dataset`() { + test("test point and rotation calculation against csv sample dataset") { val filePath = Path("src/test/cpp/spiral/build/sampled_spiral.csv").absolute() if (!filePath.exists()) { logger.warn { "Dataset does not exist at $filePath, skipping test" } - return + return@test } val fileReader = FileReader(filePath.toFile()) @@ -122,8 +112,7 @@ internal class Spiral2DTest { } } - @Test - fun `test point calculation against sample value 1`() { + test("test point calculation against sample value 1") { val spiral = Spiral2D(-0.067773987108739761) val actualPoint = spiral.calculatePoint(-5330.827396000006) @@ -132,8 +121,7 @@ internal class Spiral2DTest { assertThat(actualPoint.y).isCloseTo(3.403385667520832, Offset.offset(DBL_EPSILON)) } - @Test - fun `test rotation calculation against sample value 1`() { + test("test rotation calculation against sample value 1") { val spiral = Spiral2D(-0.067773987108739761) val actualPoint = spiral.calculateRotation(-5330.827396000006) @@ -141,8 +129,7 @@ internal class Spiral2DTest { assertThat(actualPoint.angle).isCloseTo(Rotation2D(-962991.11906995473).angle, Offset.offset(DBL_EPSILON)) } - @Test - fun `test point calculation against sample value 2`() { + test("test point calculation against sample value 2") { val spiral = Spiral2D(0.011823698552189441) val actualPoint = spiral.calculatePoint(38679.185313200163) @@ -151,8 +138,7 @@ internal class Spiral2DTest { assertThat(actualPoint.y).isCloseTo(8.1487837011384663, Offset.offset(DBL_EPSILON)) } - @Test - fun `test rotation calculation against sample value 2`() { + test("test rotation calculation against sample value 2") { val spiral = Spiral2D(0.011823698552189441) val actualPoint = spiral.calculateRotation(38679.185313200163) @@ -160,8 +146,7 @@ internal class Spiral2DTest { assertThat(actualPoint.angle).isCloseTo(Rotation2D(8844595.7788996678).angle, Offset.offset(DBL_EPSILON)) } - @Test - fun `test point calculation against sample value 3`() { + test("test point calculation against sample value 3") { val spiral = Spiral2D(-0.051693646571178295) val actualPoint = spiral.calculatePoint(6884.6109795996472) @@ -171,8 +156,7 @@ internal class Spiral2DTest { assertThat(actualPoint.y).isCloseTo(-3.8974453107566154, Offset.offset(DBL_EPSILON_2)) } - @Test - fun `test rotation calculation against sample value 3`() { + test("test rotation calculation against sample value 3") { val spiral = Spiral2D(-0.051693646571178295) val actualPoint = spiral.calculateRotation(6884.6109795996472) @@ -180,4 +164,4 @@ internal class Spiral2DTest { assertThat(actualPoint.angle).isCloseTo(Rotation2D(-1225084.3271085601).angle, Offset.offset(DBL_EPSILON)) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/SpiralSegment2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/SpiralSegment2DTest.kt index 7a8e5f27..78eda8f5 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/SpiralSegment2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/curve/SpiralSegment2DTest.kt @@ -17,6 +17,7 @@ package io.rtron.math.geometry.euclidean.twod.curve import arrow.core.Either +import io.kotest.core.spec.style.FunSpec import io.rtron.math.analysis.function.univariate.pure.LinearFunction import io.rtron.math.geometry.curved.oned.point.CurveRelativeVector1D import io.rtron.math.geometry.euclidean.twod.Pose2D @@ -35,20 +36,15 @@ import org.apache.commons.csv.CSVFormat import org.apache.commons.csv.CSVRecord import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test import java.io.FileReader import kotlin.io.path.Path import kotlin.io.path.absolute import kotlin.io.path.exists -internal class SpiralSegment2DTest { +class SpiralSegment2DTest : FunSpec({ + context("TestPointCalculation") { - @Nested - inner class TestPointCalculation { - - @Test - fun `first spiral of the ASAM example dataset Ex_Line-Spiral-Arc`() { + test("first spiral of the ASAM example dataset Ex_Line-Spiral-Arc") { val pose = Pose2D(Vector2D(3.8003686923043311e+01, -1.8133261823256248e+00), Rotation2D(3.3186980419884304e-01)) val affine = Affine2D.of(pose) val curvatureFunction = LinearFunction.ofSpiralCurvature(0.0, 1.3333327910466574e-02, 2.9999999999999996e+01) @@ -67,8 +63,7 @@ internal class SpiralSegment2DTest { ) } - @Test - fun `second spiral of the ASAM example dataset Ex_Line-Spiral-Arc`() { + test("second spiral of the ASAM example dataset Ex_Line-Spiral-Arc") { val pose = Pose2D(Vector2D(8.7773023553010319e+01, 2.9721920045249909e+01), Rotation2D(9.3186944634590163e-01)) val affine = Affine2D.of(pose) val curvatureFunction = LinearFunction.ofSpiralCurvature(1.3333327910466574e-02, 6.6666666666666671e-03, 2.0000000000000000e+01) @@ -84,8 +79,7 @@ internal class SpiralSegment2DTest { assertThat(actualReturn.value.rotation.angle).isCloseTo(1.1318693921172343e+00, Offset.offset(DBL_EPSILON_4)) } - @Test - fun `first spiral of the example dataset CrossingComplex8Course`() { + test("first spiral of the example dataset CrossingComplex8Course") { val pose = Pose2D(Vector2D(4.5002666984590900e+02, 5.2071081556728734e+02), Rotation2D(4.7173401120976974e+00)) val affine = Affine2D.of(pose) val curvatureFunction = LinearFunction.ofSpiralCurvature(-0.0000000000000000e+00, -1.0126582278481013e-01, 4.9620253164556960e+00) @@ -101,8 +95,7 @@ internal class SpiralSegment2DTest { assertThat(actualReturn.value.rotation.angle).isCloseTo(4.4660983239227257e+00, Offset.offset(DBL_EPSILON_2)) } - @Test - fun `second spiral of the example dataset CrossingComplex8Course`() { + test("second spiral of the example dataset CrossingComplex8Course") { val pose = Pose2D(Vector2D(4.4256271579386976e+02, 5.0863294215453800e+02), Rotation2D(3.3977855734777722e+00)) val affine = Affine2D.of(pose) val curvatureFunction = LinearFunction.ofSpiralCurvature(-1.0126582278481013e-01, -0.0000000000000000e+00, 4.9620253164556960e+00) @@ -119,17 +112,15 @@ internal class SpiralSegment2DTest { } } - @Nested - inner class TestDatasetCalculation { + context("TestDatasetCalculation") { - private val logger = KotlinLogging.logger {} + val logger = KotlinLogging.logger {} - @Test - fun `test point and rotation calculation against csv sample dataset`() { + test("test point and rotation calculation against csv sample dataset") { val filePath = Path("src/test/datasets/spiral_test_dataset/spiral_segments.csv").absolute() if (!filePath.exists()) { logger.warn { "Dataset does not exist at $filePath, skipping test" } - return + return@test } val fileReader = FileReader(filePath.toFile()) @@ -151,4 +142,4 @@ internal class SpiralSegment2DTest { } } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/point/Vector2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/point/Vector2DTest.kt index 16547a6c..050f6b6c 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/point/Vector2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/point/Vector2DTest.kt @@ -16,26 +16,23 @@ package io.rtron.math.geometry.euclidean.twod.point +import io.kotest.core.spec.style.FunSpec import io.rtron.math.std.HALF_PI import io.rtron.math.std.PI import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test import kotlin.math.sqrt -internal class Vector2DTest { +class Vector2DTest : FunSpec({ - @Test fun scalarMultiply() { val actualValue = Vector2D(1.0, 1.0).scalarMultiply(4.0) assertThat(actualValue).isEqualTo(Vector2D(4.0, 4.0)) } - @Nested - inner class TestDistanceCalculation { - @Test - fun `even value distance between two point`() { + context("TestDistanceCalculation") { + + test("even value distance between two point") { val pointA = Vector2D(0.0, 0.0) val pointB = Vector2D(3.0, 0.0) @@ -44,8 +41,7 @@ internal class Vector2DTest { assertThat(actualDistance).isEqualTo(3.0) } - @Test - fun `uneven value distance between two point`() { + test("uneven value distance between two point") { val pointA = Vector2D(0.0, 0.0) val pointB = Vector2D(1.0, 1.0) @@ -55,10 +51,9 @@ internal class Vector2DTest { } } - @Nested - inner class TestAngleCalculation { - @Test - fun `half pi angle between to axes`() { + context("TestAngleCalculation") { + + test("half pi angle between to axes") { val pointA = Vector2D.X_AXIS val pointB = Vector2D.Y_AXIS @@ -67,8 +62,7 @@ internal class Vector2DTest { assertThat(actualAngle).isEqualTo(HALF_PI) } - @Test - fun `uneven radians angle`() { + test("uneven radians angle") { val pointA = Vector2D.X_AXIS val pointB = Vector2D(1.0, -1.0) @@ -77,8 +71,7 @@ internal class Vector2DTest { assertThat(actualAngle).isEqualTo(1.75 * PI) } - @Test - fun `-half pi degree angle axes`() { + test("-half pi degree angle axes") { val pointA = Vector2D.X_AXIS val pointB = Vector2D(0.0, -1.0) @@ -87,4 +80,4 @@ internal class Vector2DTest { assertThat(actualAngle).isEqualTo(1.5 * PI) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/surface/Polygon2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/surface/Polygon2DTest.kt index a64afa37..33e35b38 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/surface/Polygon2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/geometry/euclidean/twod/surface/Polygon2DTest.kt @@ -18,18 +18,14 @@ package io.rtron.math.geometry.euclidean.twod.surface import arrow.core.NonEmptyList import arrow.core.toNonEmptyListOrNull +import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.twod.point.Vector2D import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Polygon2DTest { +class Polygon2DTest : FunSpec({ + context("TestContainsCalculation") { - @Nested - inner class TestContainsCalculation { - - @Test - fun `basic triangle contains point`() { + test("basic triangle contains point") { val vertices: NonEmptyList = listOf(Vector2D.ZERO, Vector2D.X_AXIS, Vector2D.Y_AXIS).toNonEmptyListOrNull()!! val polygon = Polygon2D(vertices, 0.0) @@ -38,8 +34,7 @@ internal class Polygon2DTest { assertThat(actualReturn).isTrue } - @Test - fun `basic triangle does not contain point`() { + test("basic triangle does not contain point") { val vertices: NonEmptyList = listOf( Vector2D.ZERO, Vector2D.X_AXIS, @@ -52,8 +47,7 @@ internal class Polygon2DTest { assertThat(actualReturn).isFalse } - @Test - fun `concave polygon does contain point`() { + test("concave polygon does contain point") { val vertices: NonEmptyList = listOf( Vector2D.ZERO, Vector2D(1.0, 1.0), @@ -68,4 +62,4 @@ internal class Polygon2DTest { assertThat(actualReturn).isTrue } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/linear/MatrixUtilsTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/linear/MatrixUtilsTest.kt index e81c2475..a5590c40 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/linear/MatrixUtilsTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/linear/MatrixUtilsTest.kt @@ -16,17 +16,13 @@ package io.rtron.math.linear +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class MatrixUtilsTest { +class MatrixUtilsTest : FunSpec({ + context("TestAppendColumn") { - @Nested - inner class TestAppendColumn { - - @Test - fun `append column with two elements`() { + test("append column with two elements") { val matrixValues = arrayOf(doubleArrayOf(1.0, 0.0), doubleArrayOf(0.0, 4.0)) val matrix = RealMatrix(matrixValues) val column = doubleArrayOf(2.0, 1.0) @@ -37,4 +33,4 @@ internal class MatrixUtilsTest { assertThat(actualAppendedMatrix.getRow(1)).isEqualTo(doubleArrayOf(0.0, 4.0, 1.0)) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/linear/RealMatrixTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/linear/RealMatrixTest.kt index 027e5703..c1440bf2 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/linear/RealMatrixTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/linear/RealMatrixTest.kt @@ -19,11 +19,9 @@ package io.rtron.math.linear import io.rtron.math.std.DBL_EPSILON import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Test -internal class RealMatrixTest { +class RealMatrixTest { - @Test fun normalize() { val matrixValues = arrayOf(doubleArrayOf(1.0, 0.0), doubleArrayOf(0.0, 4.0)) val matrix = RealMatrix(matrixValues) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/linear/RealVectorUtilsTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/linear/RealVectorUtilsTest.kt index 7ec4c73e..9ea048c5 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/linear/RealVectorUtilsTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/linear/RealVectorUtilsTest.kt @@ -16,16 +16,13 @@ package io.rtron.math.linear +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class RealVectorUtilsTest { +class RealVectorUtilsTest : FunSpec({ + context("TestDimensionOfSpan") { - @Nested - inner class TestDimensionOfSpan { - @Test - fun `two linearly independent and one dependent vector should have a span's dimension of 2`() { + test("two linearly independent and one dependent vector should have a span's dimension of 2") { val vectorA = RealVector(doubleArrayOf(1.0, -2.0, 1.0)) val vectorB = RealVector(doubleArrayOf(2.0, 3.0, 0.0)) // 2*B = A + C val vectorC = RealVector(doubleArrayOf(3.0, 8.0, -1.0)) @@ -36,8 +33,7 @@ internal class RealVectorUtilsTest { assertThat(actualSpan).isEqualTo(2) } - @Test - fun `four linearly independent vectors should have a span's dimension of 4`() { + test("four linearly independent vectors should have a span's dimension of 4") { val vectorA = RealVector(doubleArrayOf(1.0, 0.0, 0.0, 0.0)) val vectorB = RealVector(doubleArrayOf(0.0, 1.0, 0.0, 0.0)) val vectorC = RealVector(doubleArrayOf(0.0, 0.0, 1.0, 0.0)) @@ -49,8 +45,7 @@ internal class RealVectorUtilsTest { assertThat(actualSpan).isEqualTo(4) } - @Test - fun `no vector should have a span's dimension of 0`() { + test("no vector should have a span's dimension of 0") { val rowVectors = emptyList() val actualSpan = rowVectors.dimensionOfSpan() @@ -58,4 +53,4 @@ internal class RealVectorUtilsTest { assertThat(actualSpan).isEqualTo(0) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/linear/SingularValueDecompositionTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/linear/SingularValueDecompositionTest.kt index 5bc30ca3..75252b57 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/linear/SingularValueDecompositionTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/linear/SingularValueDecompositionTest.kt @@ -16,18 +16,14 @@ package io.rtron.math.linear +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class SingularValueDecompositionTest { +class SingularValueDecompositionTest : FunSpec({ + context("TestRank") { - @Nested - inner class TestRank { - - @Test - fun `matrix of two orthogonal vectors should have rank 2`() { + test("matrix of two orthogonal vectors should have rank 2") { val matrixValues = arrayOf(doubleArrayOf(1.0, 0.0), doubleArrayOf(0.0, 4.0)) val matrix = RealMatrix(matrixValues) val singularValueDecomposition = SingularValueDecomposition(matrix) @@ -37,8 +33,7 @@ internal class SingularValueDecompositionTest { assertThat(actualRank).isEqualTo(2) } - @Test - fun `matrix with two colinear vectors should have rank 1`() { + test("matrix with two colinear vectors should have rank 1") { val matrixValues = arrayOf(doubleArrayOf(1.0, 0.0), doubleArrayOf(3.0, 0.0)) val matrix = RealMatrix(matrixValues) val singularValueDecomposition = SingularValueDecomposition(matrix) @@ -48,8 +43,7 @@ internal class SingularValueDecompositionTest { assertThat(actualRank).isEqualTo(1) } - @Test - fun `matrix of two zero vectors should have rank 0`() { + test("matrix of two zero vectors should have rank 0") { val matrixValues = arrayOf(doubleArrayOf(0.0, 0.0), doubleArrayOf(0.0, 0.0)) val matrix = RealMatrix(matrixValues) val singularValueDecomposition = SingularValueDecomposition(matrix) @@ -60,11 +54,9 @@ internal class SingularValueDecompositionTest { } } - @Nested - inner class TestMatrixUCalculation { + context("TestMatrixUCalculation") { - @Test - fun `decomposition of 2x2 matrix`() { + test("decomposition of 2x2 matrix") { val matrixValues = arrayOf(doubleArrayOf(4.0, 12.0), doubleArrayOf(12.0, 11.0)) val matrix = RealMatrix(matrixValues) val singularValueDecomposition = SingularValueDecomposition(matrix) @@ -78,11 +70,9 @@ internal class SingularValueDecompositionTest { } } - @Nested - inner class TestMatrixSCalculation { + context("TestMatrixSCalculation") { - @Test - fun `decomposition of 2x2 matrix`() { + test("decomposition of 2x2 matrix") { val matrixValues = arrayOf(doubleArrayOf(4.0, 12.0), doubleArrayOf(12.0, 11.0)) val matrix = RealMatrix(matrixValues) val singularValueDecomposition = SingularValueDecomposition(matrix) @@ -96,11 +86,9 @@ internal class SingularValueDecompositionTest { } } - @Nested - inner class TestMatrixVCalculation { + context("TestMatrixVCalculation") { - @Test - fun `decomposition of 2x2 matrix`() { + test("decomposition of 2x2 matrix") { val matrixValues = arrayOf(doubleArrayOf(4.0, 12.0), doubleArrayOf(12.0, 11.0)) val matrix = RealMatrix(matrixValues) val singularValueDecomposition = SingularValueDecomposition(matrix) @@ -113,4 +101,4 @@ internal class SingularValueDecompositionTest { .containsExactly(expectedMatrixV.entriesFlattened, Offset.offset(0.01)) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/processing/Plane3DUtilTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/processing/Plane3DUtilTest.kt index f536a47f..2c022174 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/processing/Plane3DUtilTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/processing/Plane3DUtilTest.kt @@ -16,23 +16,19 @@ package io.rtron.math.processing +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.booleans.shouldBeTrue import io.rtron.math.geometry.euclidean.threed.point.Vector3D import io.rtron.math.geometry.euclidean.threed.surface.Plane3D import io.rtron.math.std.DBL_EPSILON_1 import io.rtron.math.std.DBL_EPSILON_2 import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Plane3DUtilTest { +class Plane3DUtilTest : FunSpec({ + context("TestBestFittingPlaneCalculation") { - @Nested - inner class TestBestFittingPlaneCalculation { - - @Test - fun `normal for clockwise point in XY-plane`() { + test("normal for clockwise point in XY-plane") { val pointA = -Vector3D.X_AXIS val pointB = Vector3D.Y_AXIS val pointC = Vector3D.X_AXIS @@ -43,8 +39,7 @@ internal class Plane3DUtilTest { assertThat(actualBestFittingPlane.normal).isEqualTo(expectedNormal) } - @Test - fun `normal for counter clockwise point in XY-plane`() { + test("normal for counter clockwise point in XY-plane") { val pointA = Vector3D.X_AXIS val pointB = Vector3D.Y_AXIS val pointC = -Vector3D.X_AXIS @@ -55,8 +50,7 @@ internal class Plane3DUtilTest { assertThat(actualBestFittingPlane.normal).isEqualTo(expectedNormal) } - @Test - fun `plane fitting with three points`() { + test("plane fitting with three points") { val pointA = Vector3D(1.0, 0.0, 0.0) val pointB = Vector3D(1.0, 3.0, 0.0) val pointC = Vector3D(1.0, 0.0, 3.0) @@ -69,8 +63,7 @@ internal class Plane3DUtilTest { assertThat(actualBestFittingPlane).isEqualTo(expectedPlane) } - @Test - fun `plane fitting with multiple points`() { + test("plane fitting with multiple points") { val pointA = Vector3D(4.0, 1.0, -3.0) val pointB = Vector3D(2.0, 2.0, -2.0) val pointC = Vector3D(1.0, 1.0, 3.0) @@ -84,11 +77,10 @@ internal class Plane3DUtilTest { assertThat(actualBestFittingPlane.normal.toDoubleArray()) .containsExactly(expectedPlane.normal.toDoubleArray(), Offset.offset(DBL_EPSILON_2)) - assertTrue(actualBestFittingPlane.isSimilarTo(expectedPlane)) + actualBestFittingPlane.isSimilarTo(expectedPlane).shouldBeTrue() } - @Test - fun `plane fitting with five points not in the same plane`() { + test("plane fitting with five points not in the same plane") { val pointA = Vector3D(1.0, 0.0, 0.0) val pointB = Vector3D(1.0, 3.0, 0.0) val pointC = Vector3D(1.0, 0.0, 3.0) @@ -103,4 +95,4 @@ internal class Plane3DUtilTest { assertThat(actualBestFittingPlane).isEqualTo(expectedPlane) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/processing/Vector2DListExtensionsTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/processing/Vector2DListExtensionsTest.kt index 894fdb4e..acacbdc0 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/processing/Vector2DListExtensionsTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/processing/Vector2DListExtensionsTest.kt @@ -1,19 +1,15 @@ package io.rtron.math.processing +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.booleans.shouldBeFalse +import io.kotest.matchers.booleans.shouldBeTrue import io.rtron.math.geometry.euclidean.twod.point.Vector2D import org.assertj.core.api.Assertions -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Vector2DListExtensionsTest { +class Vector2DListExtensionsTest : FunSpec({ + context("TestVectorsAreClockwiseOrdered") { - @Nested - inner class TestVectorsAreClockwiseOrdered { - - @Test - fun `basic three-vertices-triangle should have a clockwise order`() { + test("basic three-vertices-triangle should have a clockwise order") { val pointA = Vector2D.ZERO val pointB = Vector2D.Y_AXIS val pointC = Vector2D.X_AXIS @@ -21,11 +17,10 @@ internal class Vector2DListExtensionsTest { val hasClockwiseOrder = vertices.isClockwiseOrdered() - assertTrue(hasClockwiseOrder) + hasClockwiseOrder.shouldBeTrue() } - @Test - fun `basic three-vertices-triangle should not have a clockwise order`() { + test("basic three-vertices-triangle should not have a clockwise order") { val pointA = Vector2D.X_AXIS val pointB = Vector2D.Y_AXIS val pointC = Vector2D.ZERO @@ -33,11 +28,10 @@ internal class Vector2DListExtensionsTest { val hasClockwiseOrder = vertices.isClockwiseOrdered() - assertFalse(hasClockwiseOrder) + hasClockwiseOrder.shouldBeFalse() } - @Test - fun `five-vertices-triangle should not have a clockwise order`() { + test("five-vertices-triangle should not have a clockwise order") { val pointA = Vector2D(5.0, 0.0) val pointB = Vector2D(6.0, 4.0) val pointC = Vector2D(4.0, 5.0) @@ -47,11 +41,10 @@ internal class Vector2DListExtensionsTest { val hasClockwiseOrder = vertices.isClockwiseOrdered() - assertFalse(hasClockwiseOrder) + hasClockwiseOrder.shouldBeFalse() } - @Test - fun `providing two vertices should fail`() { + test("providing two vertices should fail") { val pointA = Vector2D.X_AXIS val pointB = Vector2D.Y_AXIS val vertices = listOf(pointA, pointB) @@ -61,4 +54,4 @@ internal class Vector2DListExtensionsTest { } } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/processing/Vector3DListExtensionsTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/processing/Vector3DListExtensionsTest.kt index c7843c8a..880d449c 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/processing/Vector3DListExtensionsTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/processing/Vector3DListExtensionsTest.kt @@ -16,21 +16,17 @@ package io.rtron.math.processing +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.booleans.shouldBeFalse +import io.kotest.matchers.booleans.shouldBeTrue import io.rtron.math.geometry.euclidean.threed.point.Vector3D import io.rtron.math.std.DBL_EPSILON_1 import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Vector3DListExtensionsTest { +class Vector3DListExtensionsTest : FunSpec({ + context("TestTripleIsColinear") { - @Nested - inner class TestTripleIsColinear { - - @Test - fun `if first and third vector are equal, vector triple should be colinear`() { + test("if first and third vector are equal, vector triple should be colinear") { val pointA = Vector3D.X_AXIS val pointB = Vector3D(3.0, 4.0, 0.0) val pointC = Vector3D.X_AXIS @@ -38,20 +34,18 @@ internal class Vector3DListExtensionsTest { val isColinear = vertices.isColinear(DBL_EPSILON_1) - assertTrue(isColinear) + isColinear.shouldBeTrue() } - @Test - fun `three linearly independent vectors should be not colinear`() { + test("three linearly independent vectors should be not colinear") { val vertices = Triple(Vector3D.X_AXIS, Vector3D.Y_AXIS, Vector3D.Z_AXIS) val isColinear = vertices.isColinear(DBL_EPSILON_1) - assertFalse(isColinear) + isColinear.shouldBeFalse() } - @Test - fun `three colinear vectors with a mixed ordering should still result true`() { + test("three colinear vectors with a mixed ordering should still result true") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS.scalarMultiply(5.0) val pointC = Vector3D.X_AXIS @@ -59,15 +53,13 @@ internal class Vector3DListExtensionsTest { val isColinear = vertices.isColinear(DBL_EPSILON_1) - assertTrue(isColinear) + isColinear.shouldBeTrue() } } - @Nested - inner class TestRemoveLinearlyRedundantVertices { + context("TestRemoveLinearlyRedundantVertices") { - @Test - fun `empty list should yield an empty list`() { + test("empty list should yield an empty list") { val vertices = listOf() val expectedVertices = listOf() @@ -76,8 +68,7 @@ internal class Vector3DListExtensionsTest { assertThat(actualResultingVertices).isEqualTo(expectedVertices) } - @Test - fun `two different point should yield the exact points`() { + test("two different point should yield the exact points") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS val vertices = listOf(pointA, pointB) @@ -88,8 +79,7 @@ internal class Vector3DListExtensionsTest { assertThat(actualResultingVertices).isEqualTo(expectedVertices) } - @Test - fun `two equal points should yield only one point`() { + test("two equal points should yield only one point") { val pointA = Vector3D.X_AXIS val pointB = Vector3D.X_AXIS val vertices = listOf(pointA, pointB) @@ -100,8 +90,7 @@ internal class Vector3DListExtensionsTest { assertThat(actualResultingVertices).isEqualTo(expectedVertices) } - @Test - fun `three points of pattern ABB`() { + test("three points of pattern ABB") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS val pointC = Vector3D.X_AXIS @@ -113,8 +102,7 @@ internal class Vector3DListExtensionsTest { assertThat(actualResultingVertices).isEqualTo(expectedVertices) } - @Test - fun `basic four points`() { + test("basic four points") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS val pointC = Vector3D.X_AXIS.scalarMultiply(2.0) @@ -127,8 +115,7 @@ internal class Vector3DListExtensionsTest { assertThat(actualResultingVertices).isEqualTo(expectedVertices) } - @Test - fun `four points of pattern ABBA`() { + test("four points of pattern ABBA") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS val pointC = Vector3D.X_AXIS @@ -141,8 +128,7 @@ internal class Vector3DListExtensionsTest { assertThat(actualResultingVertices).isEqualTo(expectedVertices) } - @Test - fun `five points of pattern ABBBA`() { + test("five points of pattern ABBBA") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS val pointC = Vector3D.X_AXIS @@ -157,11 +143,9 @@ internal class Vector3DListExtensionsTest { } } - @Nested - inner class TestListIsColinear { + context("TestListIsColinear") { - @Test - fun `three points located on x axis should be colinear`() { + test("three points located on x axis should be colinear") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS val pointC = Vector3D.X_AXIS.scalarMultiply(2.0) @@ -169,24 +153,21 @@ internal class Vector3DListExtensionsTest { val isColinear = vertices.isColinear(DBL_EPSILON_1) - assertTrue(isColinear) + isColinear.shouldBeTrue() } } - @Nested - inner class TestIsPlanar { + context("TestIsPlanar") { - @Test - fun `test triangle polygon`() { + test("test triangle polygon") { val points = listOf(Vector3D.ZERO, Vector3D.X_AXIS, Vector3D.Y_AXIS) val actual = points.isPlanar(DBL_EPSILON_1) - assertTrue(actual) + actual.shouldBeTrue() } - @Test - fun `test planar quadrilateral polygon`() { + test("test planar quadrilateral polygon") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS val pointC = Vector3D(1.0, 0.0, 1.0) @@ -195,11 +176,10 @@ internal class Vector3DListExtensionsTest { val actual = points.isPlanar(DBL_EPSILON_1) - assertTrue(actual) + actual.shouldBeTrue() } - @Test - fun `test non-planar quadrilateral polygon`() { + test("test non-planar quadrilateral polygon") { val pointA = Vector3D.ZERO val pointB = Vector3D.X_AXIS val pointC = Vector3D.Y_AXIS @@ -208,15 +188,13 @@ internal class Vector3DListExtensionsTest { val actual = points.isPlanar(DBL_EPSILON_1) - assertFalse(actual) + actual.shouldBeFalse() } } - @Nested - inner class TestCentroidCalculation { + context("TestCentroidCalculation") { - @Test - fun `centroid of triangle`() { + test("centroid of triangle") { val pointA = Vector3D.ZERO val pointB = Vector3D(6.0, 0.0, 0.0) val pointC = Vector3D(0.0, 6.0, 0.0) @@ -227,8 +205,7 @@ internal class Vector3DListExtensionsTest { assertThat(actualCentroid).isEqualTo(expectedCentroid) } - @Test - fun `centroid of multiple points`() { + test("centroid of multiple points") { val points = mutableListOf() points += Vector3D(1.0, 2.0, 1.0) points += Vector3D(3.0, 2.0, 1.0) @@ -241,4 +218,4 @@ internal class Vector3DListExtensionsTest { assertThat(actualCentroid).isEqualTo(expectedCentroid) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/projection/CoordinateReferenceSystemTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/projection/CoordinateReferenceSystemTest.kt index 568ea28c..8edc3d4c 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/projection/CoordinateReferenceSystemTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/projection/CoordinateReferenceSystemTest.kt @@ -17,17 +17,14 @@ package io.rtron.math.projection import arrow.core.Either +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class CoordinateReferenceSystemTest { +class CoordinateReferenceSystemTest : FunSpec({ - @Nested - inner class TestProperties { + context("TestProperties") { - @Test - fun `build crs 4326 from epsg name`() { + test("build crs 4326 from epsg name") { val crsName = "EPSG:4326" val actualCrsResult = CoordinateReferenceSystem.of(crsName) @@ -36,8 +33,7 @@ internal class CoordinateReferenceSystemTest { assertThat(actualCrsResult.value.name).isEqualTo(crsName) } - @Test - fun `build crs 32632 from epsg name`() { + test("build crs 32632 from epsg name") { val crsName = "EPSG:32632" val actualCrsResult = CoordinateReferenceSystem.of(crsName) @@ -46,8 +42,7 @@ internal class CoordinateReferenceSystemTest { assertThat(actualCrsResult.value.name).isEqualTo(crsName) } - @Test - fun `extract epsg code 4326`() { + test("extract epsg code 4326") { val crsName = "EPSG:4326" val actualCrsResult = CoordinateReferenceSystem.of(crsName) @@ -56,8 +51,7 @@ internal class CoordinateReferenceSystemTest { assertThat(actualCrsResult.value.epsgCode).isEqualTo(4326) } - @Test - fun `extract epsg code 32632`() { + test("extract epsg code 32632") { val crsName = "EPSG:32632" val actualCrsResult = CoordinateReferenceSystem.of(crsName) @@ -66,8 +60,7 @@ internal class CoordinateReferenceSystemTest { assertThat(actualCrsResult.value.epsgCode).isEqualTo(32632) } - @Test - fun `build crs 32632 from parameters`() { + test("build crs 32632 from parameters") { val parameters = "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs" val actualCrsResult = CoordinateReferenceSystem.ofParameters(parameters) @@ -76,8 +69,7 @@ internal class CoordinateReferenceSystemTest { assertThat(actualCrsResult.value.epsgCode).isEqualTo(32632) } - @Test - fun `build crs 4326 from parameters`() { + test("build crs 4326 from parameters") { val parameters = "+proj=longlat +datum=WGS84 +no_defs" val actualCrsResult = CoordinateReferenceSystem.ofParameters(parameters) @@ -86,4 +78,4 @@ internal class CoordinateReferenceSystemTest { assertThat(actualCrsResult.value.epsgCode).isEqualTo(4326) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/range/DoubleRangeExtensionsTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/range/DoubleRangeExtensionsTest.kt index c15fc5dd..d985f9fa 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/range/DoubleRangeExtensionsTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/range/DoubleRangeExtensionsTest.kt @@ -16,92 +16,79 @@ package io.rtron.math.range -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe -internal class DoubleRangeExtensionsTest { - - @Nested - inner class ArrangeDoubleRange { - @Test - fun `correct value spacing`() { +class DoubleRangeExtensionsTest : FunSpec({ + context("ArrangeDoubleRange") { + test("correct value spacing") { val actualValues = Range.closed(0.0, 1.25) .arrange(0.25, false, 0.0) - assertThat(doubleArrayOf(0.0, 0.25, 0.5, 0.75, 1.0, 1.25)).isEqualTo(actualValues) + doubleArrayOf(0.0, 0.25, 0.5, 0.75, 1.0, 1.25) shouldBe actualValues } - @Test - fun `non zero start`() { + test("non zero start") { val actualValues = Range.closed(1.0, 1.25) .arrange(0.25, false, 0.0) - assertThat(doubleArrayOf(1.0, 1.25)).isEqualTo(actualValues) + doubleArrayOf(1.0, 1.25) shouldBe actualValues } - @Test - fun `offset start`() { + test("offset start") { val actualValues = Range.closed(0.51, 1.25) .arrange(0.25, false, 0.0) - assertThat(doubleArrayOf(0.51, 0.76, 1.01)).isEqualTo(actualValues) + doubleArrayOf(0.51, 0.76, 1.01) shouldBe actualValues } - @Test - fun `with epsilon offset and endpoint`() { + test("with epsilon offset and endpoint") { val actualValues = Range.closed(0.51, 1.25) .arrange(0.25, true, 0.0) - assertThat(doubleArrayOf(0.51, 0.76, 1.01, 1.25)).isEqualTo(actualValues) + doubleArrayOf(0.51, 0.76, 1.01, 1.25) shouldBe actualValues } - @Test - fun `with endpoint`() { + test("with endpoint") { val actualValues = Range.closed(1.0, 1.25) .arrange(0.25, true, 0.0) - assertThat(doubleArrayOf(1.0, 1.25)).isEqualTo(actualValues) + doubleArrayOf(1.0, 1.25) shouldBe actualValues } - @Test - fun `list with length zero`() { + test("list with length zero") { val actualValues = Range.closed(1.0, 1.0) .arrange(0.25, false, 0.0) - assertThat(doubleArrayOf(1.0)).isEqualTo(actualValues) + doubleArrayOf(1.0) shouldBe actualValues } - @Test - fun `list with length zero and endPoint`() { + test("list with length zero and endPoint") { val actualValues = Range.closed(1.0, 1.0) .arrange(0.25, true, 0.0) - assertThat(doubleArrayOf(1.0)).isEqualTo(actualValues) + doubleArrayOf(1.0) shouldBe actualValues } - @Test - fun `smaller range than step size should nevertheless contain the start`() { + test("smaller range than step size should nevertheless contain the start") { val actualValues = Range.closed(1.0, 2.0) .arrange(5.0, false, 0.0) - assertThat(doubleArrayOf(1.0)).isEqualTo(actualValues) + doubleArrayOf(1.0) shouldBe actualValues } - @Test - fun `smaller range than step size should nevertheless contain the start and end`() { + test("smaller range than step size should nevertheless contain the start and end") { val actualValues = Range.closed(1.0, 2.0) .arrange(5.0, true, 0.0) - assertThat(doubleArrayOf(1.0, 2.0)).isEqualTo(actualValues) + doubleArrayOf(1.0, 2.0) shouldBe actualValues } - @Test - fun `range with length under epsilon should nevertheless contain the start and end`() { + test("range with length under epsilon should nevertheless contain the start and end") { val actualValues = Range.closed(0.0, 1.0E-8) .arrange(0.5, true, 0.0) - assertThat(doubleArrayOf(0.0, 1.0E-8)).isEqualTo(actualValues) + doubleArrayOf(0.0, 1.0E-8) shouldBe actualValues } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/range/DoubleRangeSetExtensionsTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/range/DoubleRangeSetExtensionsTest.kt index 7a8b8ab3..29c7bf8f 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/range/DoubleRangeSetExtensionsTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/range/DoubleRangeSetExtensionsTest.kt @@ -16,18 +16,14 @@ package io.rtron.math.range +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatIllegalArgumentException -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class DoubleRangeSetExtensionsTest { +class DoubleRangeSetExtensionsTest : FunSpec({ + context("TestCreation") { - @Nested - inner class TestCreation { - - @Test - fun `intersecting ranges should throw an IllegalArgumentException`() { + test("intersecting ranges should throw an IllegalArgumentException") { val rangeA = Range.closed(0.0, 2.0) val rangeB = Range.closed(1.0, 4.0) @@ -36,8 +32,7 @@ internal class DoubleRangeSetExtensionsTest { } } - @Test - fun `connected ranges are combined to one range`() { + test("connected ranges are combined to one range") { val rangeA = Range.closedOpen(0.0, 2.0) val rangeB = Range.closed(2.0, 4.0) @@ -46,4 +41,4 @@ internal class DoubleRangeSetExtensionsTest { assertThat(actualRangeSet.asRanges()).hasSize(1) } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/range/RangeSetTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/range/RangeSetTest.kt index d34b7ebf..b5d2ac2b 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/range/RangeSetTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/range/RangeSetTest.kt @@ -16,33 +16,28 @@ package io.rtron.math.range +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.booleans.shouldBeFalse +import io.kotest.matchers.booleans.shouldBeTrue import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class RangeSetTest { +class RangeSetTest : FunSpec({ - @Nested - inner class TestContains { + context("TestContains") { - @Test - fun `contains primitive value`() { + test("contains primitive value") { val rangeA = Range.closedOpen(1.0, 1.3) val rangeB = Range.closedOpen(10.0, 12.0) val rangeC = Range.closed(1.3, 2.0) val rangeSet = RangeSet.of(rangeA, rangeB, rangeC) - assertTrue(rangeSet.contains(1.3)) + rangeSet.contains(1.3).shouldBeTrue() } } - @Nested - inner class TestUnion { + context("TestUnion") { - @Test - fun `simple union of two disconnected range sets`() { + test("simple union of two disconnected range sets") { val rangeA = Range.closedOpen(1.0, 1.3) val rangeB = Range.closed(1.4, 2.0) val rangeSetA = RangeSet.of(rangeA) @@ -54,8 +49,7 @@ internal class RangeSetTest { .containsExactlyInAnyOrder(rangeA, rangeB) } - @Test - fun `simple union of two connected range sets`() { + test("simple union of two connected range sets") { val rangeA = Range.closedOpen(1.0, 1.3) val rangeB = Range.closed(1.3, 2.0) val rangeSetA = RangeSet.of(rangeA) @@ -68,37 +62,33 @@ internal class RangeSetTest { } } - @Nested - inner class TestIntersection { + context("TestIntersection") { - @Test - fun `two disconnected range sets do not intersect`() { + test("two disconnected range sets do not intersect") { val rangeA = Range.closedOpen(1.0, 1.3) val rangeB = Range.closed(1.4, 2.0) val rangeSetA = RangeSet.of(rangeA) val rangeSetB = RangeSet.of(rangeB) - assertFalse(rangeSetA.intersects(rangeSetB)) + rangeSetA.intersects(rangeSetB).shouldBeFalse() } - @Test - fun `two connected range sets do not intersect`() { + test("two connected range sets do not intersect") { val rangeA = Range.closedOpen(1.0, 1.3) val rangeB = Range.closed(1.3, 2.0) val rangeSetA = RangeSet.of(rangeA) val rangeSetB = RangeSet.of(rangeB) - assertFalse(rangeSetA.intersects(rangeSetB)) + rangeSetA.intersects(rangeSetB).shouldBeFalse() } - @Test - fun `two connected and closed range sets do intersect`() { + test("two connected and closed range sets do intersect") { val rangeA = Range.closed(1.0, 1.3) val rangeB = Range.closed(1.3, 2.0) val rangeSetA = RangeSet.of(rangeA) val rangeSetB = RangeSet.of(rangeB) - assertTrue(rangeSetA.intersects(rangeSetB)) + rangeSetA.intersects(rangeSetB).shouldBeTrue() } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/range/RangeTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/range/RangeTest.kt index 3108638d..6f60a028 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/range/RangeTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/range/RangeTest.kt @@ -16,173 +16,150 @@ package io.rtron.math.range +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.booleans.shouldBeFalse +import io.kotest.matchers.booleans.shouldBeTrue +import io.kotest.matchers.nulls.shouldBeNull import io.rtron.math.std.DBL_EPSILON import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatIllegalArgumentException -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertNull -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class RangeTest { +class RangeTest : FunSpec({ + context("UpperLowerEndpoint") { - @Nested - inner class UpperLowerEndpoint { - - @Test - fun `lowerEndpoint should yield null, if no lower endpoint exists`() { + test("lowerEndpoint should yield null, if no lower endpoint exists") { val range: Range = Range.all() - assertNull(range.lowerEndpointOrNull()) + range.lowerEndpointOrNull().shouldBeNull() } - @Test - fun `upperEndpoint should yield null, if no upper endpoint exists`() { + test("upperEndpoint should yield null, if no upper endpoint exists") { val range: Range = Range.all() - assertNull(range.upperEndpointOrNull()) + range.upperEndpointOrNull().shouldBeNull() } } - @Nested - inner class ContainsValue { + context("ContainsValue") { - @Test - fun `closed range should contain basic value`() { + test("closed range should contain basic value") { val range = Range.closed(-5.0, -2.0) val actualContains = range.contains(-2.0) - assertTrue(actualContains) + actualContains.shouldBeTrue() } - @Test - fun `closed range should contain lower value`() { + test("closed range should contain lower value") { val range = Range.closed(-5.0, -2.0) val actualContains = range.contains(-5.0) - assertTrue(actualContains) + actualContains.shouldBeTrue() } - @Test - fun `closed range should contain upper value`() { + test("closed range should contain upper value") { val range = Range.closed(-5.0, -2.0) val actualContains = range.contains(-2.0) - assertTrue(actualContains) + actualContains.shouldBeTrue() } - @Test - fun `greaterThan range contains infinity`() { + test("greaterThan range contains infinity") { val range = Range.greaterThan(1.0) val actualContains = range.contains(Double.POSITIVE_INFINITY) - assertTrue(actualContains) + + actualContains.shouldBeTrue() } - @Test - fun `lessThan range contains negative infinity`() { + test("lessThan range contains negative infinity") { val range = Range.lessThan(-12.0) val actualContains = range.contains(Double.NEGATIVE_INFINITY) - assertTrue(actualContains) + actualContains.shouldBeTrue() } - @Test - fun `closed range does not contain positive infinity`() { + test("closed range does not contain positive infinity") { val range = Range.open(1.0, 555.3) val actualContains = range.contains(Double.POSITIVE_INFINITY) - assertFalse(actualContains) + actualContains.shouldBeFalse() } - @Test - fun `closed start range does not contain negative infinity`() { + test("closed start range does not contain negative infinity") { val range = Range.closed(-20.0, 0.0) val actualContains = range.contains(Double.NEGATIVE_INFINITY) - assertFalse(actualContains) + actualContains.shouldBeFalse() } - @Test - fun `closed range contains negative start limit`() { + test("closed range contains negative start limit") { val actualContains = Range.closed(-3.1, 2.0).contains(-3.1) - assertTrue(actualContains) + actualContains.shouldBeTrue() } - @Test - fun `closed range contains positive end limit`() { + test("closed range contains positive end limit") { val actualContains = Range.closed(0.0, 2.0).contains(2.0) - assertTrue(actualContains) + actualContains.shouldBeTrue() } - @Test - fun `closed range does not contain negative start limit`() { + test("closed range does not contain negative start limit") { val actualContains = Range.closed(-3.1, 2.0).contains(-3.10000001) - assertFalse(actualContains) + actualContains.shouldBeFalse() } - @Test - fun `closed range does not contain positive start limit`() { + test("closed range does not contain positive start limit") { val actualContains = Range.closed(0.0, 2.0).contains(2.0001) - assertFalse(actualContains) + actualContains.shouldBeFalse() } } - @Nested - inner class TestConstruction { + context("TestConstruction") { - @Test - fun `negative orientation of the range throws an illegal argument exception`() { + test("negative orientation of the range throws an illegal argument exception") { assertThatIllegalArgumentException().isThrownBy { Range.closed(-1.0, -1.25) } } } - @Nested - inner class TestIsConnected { + context("TestIsConnected") { - @Test - fun `is not connected`() { + test("is not connected") { val rangeA = Range.closed(1.0, 1.0) val rangeB = Range.closed(2.0, 2.0) val actualIsConnected = rangeA.isConnected(rangeB) - assertFalse(actualIsConnected) + actualIsConnected.shouldBeFalse() } - @Test - fun `is not connected with epsilon`() { + test("is not connected with epsilon") { val rangeA = Range.closed(0.0, 1.0) val rangeB = Range.closed((1.0 + DBL_EPSILON), 2.0) val actualIsConnected = rangeA.isConnected(rangeB) - assertFalse(actualIsConnected) + actualIsConnected.shouldBeFalse() } - @Test - fun `is connected`() { + test("is connected") { val rangeA = Range.closed(0.0, 1.0) val rangeB = Range.closed((1.0 - DBL_EPSILON), 2.0) val actualIsConnected = rangeA.isConnected(rangeB) - assertTrue(actualIsConnected) + actualIsConnected.shouldBeTrue() } - @Test - fun `connected range joins with positive values`() { + test("connected range joins with positive values") { val rangeA = Range.closed(0.0, 1.0) val rangeB = Range.closed(1.0, 2.0) @@ -191,8 +168,7 @@ internal class RangeTest { assertThat(actualJoin).isEqualTo(Range.closed(0.0, 2.0)) } - @Test - fun `Connected joins with negative values`() { + test("Connected joins with negative values") { val rangeA = Range.closed(-1.0, -0.5) val rangeB = Range.closed(-0.5, -0.2) @@ -201,12 +177,11 @@ internal class RangeTest { assertThat(actualJoin).isEqualTo(Range.closed(-1.0, -0.2)) } - @Test - fun `join throws exception if the ranges are not connected`() { + test("join throws exception if the ranges are not connected") { val rangeA = Range.closed(-1.0, -0.51) val rangeB = Range.closed(-0.5, -0.2) assertThatIllegalArgumentException().isThrownBy { rangeA.join(rangeB) } } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/std/DoubleArrayExtensionTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/std/DoubleArrayExtensionTest.kt index b82c6350..1e1891be 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/std/DoubleArrayExtensionTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/std/DoubleArrayExtensionTest.kt @@ -16,18 +16,15 @@ package io.rtron.math.std -import org.assertj.core.api.Assertions.assertThat +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe import org.assertj.core.api.Assertions.assertThatIllegalArgumentException -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class DoubleArrayExtensionTest { +class DoubleArrayExtensionTest : FunSpec({ - @Nested - inner class TestReshapeByColumnDimension { + context("TestReshapeByColumnDimension") { - @Test - fun `test reshape of square matrix`() { + test("test reshape of square matrix") { val expectedMatrix = arrayOf( doubleArrayOf(1.0, 0.0, 0.0, 1.0), doubleArrayOf(0.0, 1.0, 0.0, 2.0), @@ -43,22 +40,19 @@ internal class DoubleArrayExtensionTest { val actualReshapedMatrix = matrix.reshapeByColumnDimension(4) - assertThat(actualReshapedMatrix).isEqualTo(expectedMatrix) + actualReshapedMatrix shouldBe expectedMatrix } } - @Nested - inner class TestReshapeByRowDimension { + context("TestReshapeByRowDimension") { - @Test - fun `test fail for wrong dimension`() { + test("test fail for wrong dimension") { val values = doubleArrayOf(2.0, 1.0, 2.0, 1.0) assertThatIllegalArgumentException().isThrownBy { values.reshapeByRowDimension(5) } } - @Test - fun `test reshape of square matrix`() { + test("test reshape of square matrix") { val expectedMatrix = arrayOf( doubleArrayOf(0.0, 0.0, 1.0), doubleArrayOf(1.0, 0.0, 2.0), @@ -74,7 +68,7 @@ internal class DoubleArrayExtensionTest { val actualReshapedMatrix = matrix.reshapeByRowDimension(4) - assertThat(actualReshapedMatrix).isEqualTo(expectedMatrix) + actualReshapedMatrix shouldBe expectedMatrix } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/transform/Affine2DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/transform/Affine2DTest.kt index 78c03e96..19e9b772 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/transform/Affine2DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/transform/Affine2DTest.kt @@ -16,6 +16,8 @@ package io.rtron.math.transform +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe import io.rtron.math.geometry.euclidean.twod.Pose2D import io.rtron.math.geometry.euclidean.twod.Rotation2D import io.rtron.math.geometry.euclidean.twod.point.Vector2D @@ -23,47 +25,35 @@ import io.rtron.math.linear.RealMatrix import io.rtron.math.linear.RealVector import io.rtron.math.std.HALF_PI import io.rtron.math.std.QUARTER_PI -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Assertions.assertArrayEquals -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class Affine2DTest { +class Affine2DTest : FunSpec({ - @Nested - inner class TestTransform { - @Test - fun `test rotation`() { + context("TestTransform") { + test("test rotation") { val point = Vector2D.X_AXIS val rotationAngle = Rotation2D(HALF_PI) val affine = Affine2D.of(rotationAngle) val actualTransformed = affine.transform(point) - assertThat(actualTransformed).isEqualTo(Vector2D(0.0, 1.0)) + actualTransformed shouldBe Vector2D(0.0, 1.0) } } - @Nested - inner class TestInverseTransform { - - @Test - fun `inverse translation transform`() { + context("TestInverseTransform") { + test("inverse translation transform") { val point = Vector2D(10.0, 12.0) val translation = Vector2D(5.0, 2.0) val affine = Affine2D.of(translation) val actualTransformed = affine.inverseTransform(point) - assertThat(actualTransformed).isEqualTo(Vector2D(5.0, 10.0)) + actualTransformed shouldBe Vector2D(5.0, 10.0) } } - @Nested - inner class TestAffineMultiplication { - - @Test - fun `test appending`() { + context("TestAffineMultiplication") { + test("test appending") { val translation = Vector2D(1.0, 2.0) val affineA = Affine2D.of(translation) val scaling = RealVector.of(2.0, 3.0) @@ -78,16 +68,13 @@ internal class Affine2DTest { val actualAppended = affineA.append(affineB) val actualMatrix = actualAppended.toMatrix() - assertThat(actualMatrix.dimension).isEqualTo(expectedMatrix.dimension) - assertArrayEquals(expectedMatrix.toDoubleArray(), actualMatrix.toDoubleArray()) + actualMatrix.dimension shouldBe expectedMatrix.dimension + expectedMatrix.toDoubleArray() shouldBe actualMatrix.toDoubleArray() } } - @Nested - inner class TestPoseTransforms { - - @Test - fun `test translation`() { + context("TestPoseTransforms") { + test("test translation") { val point = Vector2D(5.0, 3.0) val pose = Pose2D(Vector2D(-10.0, -5.0), Rotation2D(0.0)) val affineTranslation = Affine2D.of(pose.point) @@ -96,78 +83,69 @@ internal class Affine2DTest { val actualTransformed = affine.transform(point) - assertThat(actualTransformed).isEqualTo(Vector2D(-5.0, -2.0)) + actualTransformed shouldBe Vector2D(-5.0, -2.0) } - @Test - fun `inverse transform with pose in origin`() { + test("inverse transform with pose in origin") { val point = Vector2D(5.0, 3.0) val pose = Pose2D(Vector2D(0.0, 0.0), Rotation2D(0.0)) val affine = Affine2D.of(Affine2D.of(pose.point), Affine2D.of(pose.rotation)) val actualTransformed = affine.inverseTransform(point) - assertThat(actualTransformed).isEqualTo(Vector2D(5.0, 3.0)) + actualTransformed shouldBe Vector2D(5.0, 3.0) } - @Test - fun `transform with rotated pose in origin`() { + test("transform with rotated pose in origin") { val point = Vector2D(5.0, 0.0) val pose = Pose2D(Vector2D(0.0, 0.0), Rotation2D(HALF_PI)) val affine = Affine2D.of(Affine2D.of(pose.point), Affine2D.of(pose.rotation)) val actualTransformed = affine.transform(point) - assertThat(actualTransformed).isEqualTo(Vector2D(0.0, 5.0)) + actualTransformed shouldBe Vector2D(0.0, 5.0) } - @Test - fun `transform with rotated pose and offset point`() { + test("transform with rotated pose and offset point") { val point = Vector2D(2.0, 3.0) val pose = Pose2D(Vector2D(0.0, 0.0), Rotation2D(HALF_PI)) val affine = Affine2D.of(Affine2D.of(pose.point), Affine2D.of(pose.rotation)) val actualTransformed = affine.transform(point) - assertThat(actualTransformed).isEqualTo(Vector2D(-3.0, 2.0)) + actualTransformed shouldBe Vector2D(-3.0, 2.0) } } - @Nested - inner class TestDecomposition { - - @Test - fun `extract translation point from basic affine`() { + context("TestDecomposition") { + test("extract translation point from basic affine") { val translation = Vector2D(1.0, 2.0) val affine = Affine2D.of(translation) val actual = affine.extractTranslation() - assertThat(actual).isEqualTo(translation) + actual shouldBe translation } - @Test - fun `extract rotation from basic affine`() { + test("extract rotation from basic affine") { val rotation = Rotation2D(QUARTER_PI) val affine = Affine2D.of(rotation) val actual = affine.extractRotation() - assertThat(actual).isEqualTo(rotation) + actual shouldBe rotation } - @Test - fun `extract scale vector from basic affine`() { + test("extract scale vector from basic affine") { val scaling = RealVector(doubleArrayOf(3.0, 2.0)) val affine = Affine2D.of(scaling) val actual = affine.extractScaling() - assertThat(actual).isEqualTo(scaling) + actual shouldBe scaling } - @Test - fun `extract rotation from affine with scaling, translation and rotation`() { + test("extract rotation from affine with scaling, translation and rotation") { val scaling = RealVector(doubleArrayOf(3.0, 2.0)) val translation = Vector2D(3.0, 2.0) val rotation = Rotation2D(HALF_PI) @@ -175,7 +153,7 @@ internal class Affine2DTest { val actual = affine.extractRotation() - assertThat(actual.toAngleRadians()).isEqualTo(rotation.toAngleRadians()) + actual.toAngleRadians() shouldBe rotation.toAngleRadians() } } -} +}) diff --git a/rtron-math/src/test/kotlin/io/rtron/math/transform/Affine3DTest.kt b/rtron-math/src/test/kotlin/io/rtron/math/transform/Affine3DTest.kt index aeefae24..2f8fd574 100644 --- a/rtron-math/src/test/kotlin/io/rtron/math/transform/Affine3DTest.kt +++ b/rtron-math/src/test/kotlin/io/rtron/math/transform/Affine3DTest.kt @@ -16,6 +16,9 @@ package io.rtron.math.transform +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe import io.rtron.math.geometry.euclidean.threed.Rotation3D import io.rtron.math.geometry.euclidean.threed.point.Vector3D import io.rtron.math.linear.RealMatrix @@ -24,43 +27,35 @@ import io.rtron.math.std.DBL_EPSILON import io.rtron.math.std.HALF_PI import org.assertj.core.api.Assertions.assertThat import org.assertj.core.data.Offset -import org.junit.jupiter.api.Assertions.assertArrayEquals -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test import kotlin.math.cos import kotlin.math.sin import org.joml.Matrix4d as JOMLMatrix4d -internal class Affine3DTest { +class Affine3DTest : FunSpec({ - @Nested - inner class TestCreation { + context("TestCreation") { - @Test - fun `last entry must be 1 when creating a translation`() { + test("last entry must be 1 when creating a translation") { val translation = Vector3D(1.0, 2.0, 3.0) val affine = Affine3D.of(translation) val actual = affine.toRealMatrix()[3][3] - assertThat(actual).isEqualTo(1.0) + actual shouldBe 1.0 } } - @Nested - inner class TestDecomposition { + context("TestDecomposition") { - @Test - fun `test translation from 3x3 matrix`() { + test("test translation from 3x3 matrix") { val affine = Affine3D(JOMLMatrix4d()) val actual = affine.extractTranslation() - assertThat(actual).isEqualTo(Vector3D(0.0, 0.0, 0.0)) + actual shouldBe Vector3D(0.0, 0.0, 0.0) } - @Test - fun `test translation from 3x4 matrix`() { + test("test translation from 3x4 matrix") { val values = doubleArrayOf( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 3.0, @@ -72,31 +67,28 @@ internal class Affine3DTest { val actual = affine.extractTranslation() - assertThat(actual).isEqualTo(Vector3D(0.0, 3.0, 2.0)) + actual shouldBe Vector3D(0.0, 3.0, 2.0) } - @Test - fun `test translation`() { + test("test translation") { val translation = Vector3D(1.0, 2.0, 3.0) val affine = Affine3D.of(translation) val actual = affine.extractTranslation() - assertThat(actual).isEqualTo(translation) + actual shouldBe translation } - @Test - fun `test scale`() { + test("test scale") { val scaling = RealVector(doubleArrayOf(3.0, 2.0, 1.0)) val affine = Affine3D.of(scaling) val actual = affine.extractScaling() - assertThat(actual).isEqualTo(scaling) + actual shouldBe scaling } - @Test - fun `test rotation`() { + test("test rotation") { val scaling = RealVector(doubleArrayOf(3.0, 2.0, 1.0)) val translation = Vector3D(3.0, 2.0, 1.0) val heading = HALF_PI @@ -114,16 +106,16 @@ internal class Affine3DTest { val actual = affine.extractRotationAffine().toRealMatrix() - assertThat(actual.dimension).isEqualTo(expectedRotationMatrix.dimension) - assertArrayEquals(expectedRotationMatrix.toDoubleArray(), actual.toDoubleArray(), DBL_EPSILON) + actual.dimension shouldBe expectedRotationMatrix.dimension + expectedRotationMatrix.toDoubleArray().zip(actual.toDoubleArray()).forEach { + it.first.shouldBe(it.second plusOrMinus DBL_EPSILON) + } } } - @Nested - inner class TestAffineMultiplication { + context("TestAffineMultiplication") { - @Test - fun `test appending`() { + test("test appending") { val translation = Vector3D(1.0, 2.0, 3.0) val affineA = Affine3D.of(translation) val scaling = RealVector.of(2.0, 3.0, 4.0) @@ -139,40 +131,35 @@ internal class Affine3DTest { val actualAppended = affineA.append(affineB) val actualMatrix = actualAppended.toRealMatrix() - assertThat(actualMatrix.dimension).isEqualTo(expectedMatrix.dimension) - assertArrayEquals(expectedMatrix.toDoubleArray(), actualMatrix.toDoubleArray()) + actualMatrix.dimension shouldBe expectedMatrix.dimension + expectedMatrix.toDoubleArray() shouldBe actualMatrix.toDoubleArray() } } - @Nested - inner class TestTransforms { + context("TestTransforms") { - @Test - fun `test translation`() { + test("test translation") { val translation = Vector3D(1.0, 2.0, 3.0) val affine = Affine3D.of(translation) val actualTranslated = affine.transform(Vector3D.ZERO) - assertThat(actualTranslated).isEqualTo(translation) + actualTranslated shouldBe translation } - @Test - fun `test inverse translation`() { + test("test inverse translation") { val translation = Vector3D(1.0, 2.0, 3.0) val affine = Affine3D.of(translation) val actualTranslated = affine.inverseTransform(Vector3D.ZERO) - assertThat(actualTranslated).isEqualTo(-translation) + actualTranslated shouldBe -translation } } - @Nested - inner class TestRotations { + context("TestRotations") { - @Test - fun `test heading rotation`() { + test("test heading rotation") { val rotation = Rotation3D(HALF_PI, 0.0, 0.0) val affine = Affine3D.of(rotation) @@ -183,8 +170,7 @@ internal class Affine3DTest { assertThat(actualRotated.z).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) } - @Test - fun `test pitch rotation`() { + test("test pitch rotation") { val rotation = Rotation3D(0.0, HALF_PI, 0.0) val affine = Affine3D.of(rotation) @@ -195,8 +181,7 @@ internal class Affine3DTest { assertThat(actualRotated.z).isCloseTo(-1.0, Offset.offset(DBL_EPSILON)) } - @Test - fun `test rotation based on new standard basis`() { + test("test rotation based on new standard basis") { val basisX = Vector3D(-1.0, 1.0, 0.0) val basisY = Vector3D(-1.0, 0.0, 1.0) val basisZ = Vector3D(1.0, 1.0, 1.0) @@ -211,11 +196,9 @@ internal class Affine3DTest { } } - @Nested - inner class TestConversions { + context("TestConversions") { - @Test - fun `test to double array`() { + test("test to double array") { val translation = Vector3D(1.0, 2.0, 3.0) val affine = Affine3D.of(translation) val expectedDoubleArray = doubleArrayOf( @@ -227,7 +210,7 @@ internal class Affine3DTest { val actualDoubleArray = affine.toDoubleArray() - assertArrayEquals(expectedDoubleArray, actualDoubleArray) + expectedDoubleArray shouldBe actualDoubleArray } } -} +}) diff --git a/rtron-std/src/test/kotlin/io/rtron/std/CollectionsKtTest.kt b/rtron-std/src/test/kotlin/io/rtron/std/CollectionsKtTest.kt index ce1a68da..49a4a593 100644 --- a/rtron-std/src/test/kotlin/io/rtron/std/CollectionsKtTest.kt +++ b/rtron-std/src/test/kotlin/io/rtron/std/CollectionsKtTest.kt @@ -16,17 +16,13 @@ package io.rtron.std +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class CollectionsKtTest { +class CollectionsKtTest : FunSpec({ + context("TestDistinctConsecutive") { - @Nested - inner class TestDistinctConsecutive { - - @Test - fun `test basic list with consecutive duplicate at the beginning`() { + test("test basic list with consecutive duplicate at the beginning") { val expectedValues = listOf("a", "b", "c") val actualValues = listOf("a", "a", "b", "c").distinctConsecutiveBy { it } @@ -34,8 +30,7 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test basic list with same enclosing pair`() { + test("test basic list with same enclosing pair") { val expectedValues = listOf("a", "b", "c", "a") val actualValues = listOf("a", "a", "b", "c", "a").distinctConsecutiveBy { it } @@ -43,26 +38,22 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test empty list`() { + test("test empty list") { val actualValues = emptyList().distinctConsecutiveBy { it } assertThat(actualValues).isEqualTo(emptyList()) } - @Test - fun `test list with a single element`() { + test("test list with a single element") { val actualValues = listOf("a").distinctConsecutiveBy { it } assertThat(actualValues).isEqualTo(listOf("a")) } } - @Nested - inner class TestDistinctConsecutiveEnclosing { + context("TestDistinctConsecutiveEnclosing") { - @Test - fun `test basic list with consecutive duplicate at the beginning`() { + test("test basic list with consecutive duplicate at the beginning") { val expectedValues = listOf("a", "b", "c") val actualValues = listOf("a", "a", "b", "c").distinctConsecutiveEnclosingBy { it } @@ -70,8 +61,7 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test basic list with same enclosing pair`() { + test("test basic list with same enclosing pair") { val expectedValues = listOf("a", "b", "c") val actualValues = listOf("a", "a", "b", "c", "a").distinctConsecutiveEnclosingBy { it } @@ -79,8 +69,7 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test removal of multiple consecutive objects`() { + test("test removal of multiple consecutive objects") { val expectedValues = listOf("a", "b", "c") val actualValues = listOf("a", "b", "b", "b", "c").distinctConsecutiveEnclosingBy { it } @@ -88,25 +77,22 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test empty list`() { + test("test empty list") { val actualValues = emptyList().distinctConsecutiveEnclosingBy { it } assertThat(actualValues).isEqualTo(emptyList()) } - @Test - fun `test list with a single element`() { + test("test list with a single element") { val actualValues = listOf("a").distinctConsecutiveEnclosingBy { it } assertThat(actualValues).isEqualTo(listOf("a")) } } - @Nested - inner class TestFilterToSorting { - @Test - fun `test basic list with consecutive duplicate at the beginning`() { + context("TestFilterToSorting") { + + test("test basic list with consecutive duplicate at the beginning") { val expectedValues = listOf(1, 2, 3) val actualValues = listOf(1, 1, 2, 3).filterToSorting { first, second -> first < second } @@ -114,8 +100,7 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test unsorted list`() { + test("test unsorted list") { val expectedValues = listOf(3, 4, 12) val actualValues = listOf(3, 1, 2, 4, 12, 5, 3).filterToSorting { first, second -> first < second } @@ -123,26 +108,22 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test empty list`() { + test("test empty list") { val actualValues = emptyList().filterToSorting { first, second -> first < second } assertThat(actualValues).isEqualTo(emptyList()) } - @Test - fun `test list with a single element`() { + test("test list with a single element") { val actualValues = listOf("a").filterToSorting { first, second -> first < second } assertThat(actualValues).isEqualTo(listOf("a")) } } - @Nested - inner class TestWindowedEnclosing { + context("TestWindowedEnclosing") { - @Test - fun `test basic enclosed windowing of character sequence`() { + test("test basic enclosed windowing of character sequence") { val baseSequence = sequenceOf("a", "b", "c", "d") val expectedSequence = sequenceOf( listOf("a", "b", "c"), @@ -156,8 +137,7 @@ internal class CollectionsKtTest { assertThat(actualSequence.toList()).isEqualTo(expectedSequence.toList()) } - @Test - fun `test basic enclosed windowing of integer sequence`() { + test("test basic enclosed windowing of integer sequence") { val baseSequence = sequenceOf(1, 2, 3, 4, 5, 6) val expectedSequence = sequenceOf( listOf(1, 2, 3), @@ -174,11 +154,9 @@ internal class CollectionsKtTest { } } - @Nested - inner class TestFilterWithNext { + context("TestFilterWithNext") { - @Test - fun `test basic enclosed windowing of character sequence`() { + test("test basic enclosed windowing of character sequence") { val expectedValues = listOf("a", "b", "c") val actualValues = listOf("a", "a", "b", "c").filterWithNext { a, b -> a != b } @@ -186,8 +164,7 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test basic list with same enclosing pair`() { + test("test basic list with same enclosing pair") { val expectedValues = listOf("a", "b", "c", "a") val actualValues = listOf("a", "a", "b", "c", "a").filterWithNext { a, b -> a != b } @@ -195,8 +172,7 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test list with three consecutively following duplicates`() { + test("test list with three consecutively following duplicates") { val expectedValues = listOf("a", "b", "c", "a") val actualValues = listOf("a", "a", "a", "b", "b", "c", "a").filterWithNext { a, b -> a != b } @@ -204,26 +180,22 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test empty list`() { + test("test empty list") { val actualValues = emptyList().filterWithNext { a, b -> a != b } assertThat(actualValues).isEqualTo(emptyList()) } - @Test - fun `test list with a single element`() { + test("test list with a single element") { val actualValues = listOf("a").filterWithNext { a, b -> a != b } assertThat(actualValues).isEqualTo(listOf("a")) } } - @Nested - inner class TestFilterWithNextEnclosing { + context("TestFilterWithNextEnclosing") { - @Test - fun `test basic list with consecutive duplicate at the beginning`() { + test("test basic list with consecutive duplicate at the beginning") { val expectedValues = listOf("a", "b", "c") val actualValues = listOf("a", "a", "b", "c").filterWithNextEnclosing { a, b -> a != b } @@ -231,8 +203,7 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test basic list with same enclosing pair`() { + test("test basic list with same enclosing pair") { val expectedValues = listOf("a", "b", "c") val actualValues = listOf("a", "a", "b", "c", "a").filterWithNextEnclosing { a, b -> a != b } @@ -240,8 +211,7 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test removal of multiple consecutive objects`() { + test("test removal of multiple consecutive objects") { val expectedValues = listOf("a", "b", "c") val actualValues = listOf("a", "b", "b", "b", "c").filterWithNextEnclosing { a, b -> a != b } @@ -249,18 +219,16 @@ internal class CollectionsKtTest { assertThat(actualValues).isEqualTo(expectedValues) } - @Test - fun `test empty list`() { + test("test empty list") { val actualValues = emptyList().filterWithNextEnclosing { a, b -> a != b } assertThat(actualValues).isEqualTo(emptyList()) } - @Test - fun `test list with a single element`() { + test("test list with a single element") { val actualValues = listOf("a").filterWithNextEnclosing { a, b -> a != b } assertThat(actualValues).isEqualTo(listOf("a")) } } -} +}) diff --git a/rtron-std/src/test/kotlin/io/rtron/std/IterableKtTest.kt b/rtron-std/src/test/kotlin/io/rtron/std/IterableKtTest.kt index a6553090..6d0bf932 100644 --- a/rtron-std/src/test/kotlin/io/rtron/std/IterableKtTest.kt +++ b/rtron-std/src/test/kotlin/io/rtron/std/IterableKtTest.kt @@ -16,42 +16,35 @@ package io.rtron.std -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.booleans.shouldBeFalse +import io.kotest.matchers.booleans.shouldBeTrue -internal class IterableKtTest { +class IterableKtTest : FunSpec({ + context("TestIsSorted") { - @Nested - inner class TestIsSorted { - - @Test - fun `isSorted() returns true if integer list is sorted ascending`() { + test("isSorted() returns true if integer list is sorted ascending") { val sortedList = listOf(1, 7, 7, 12, 13) - assertTrue(sortedList.isSorted()) + sortedList.isSorted().shouldBeTrue() } - @Test - fun `isSorted() returns false if integer list is not sorted ascending`() { + test("isSorted() returns false if integer list is not sorted ascending") { val sortedList = listOf(1, 7, 3, 12, 13) - assertFalse(sortedList.isSorted()) + sortedList.isSorted().shouldBeFalse() } - @Test - fun `isSortedDescending() returns true if integer list is sorted descending`() { + test("isSortedDescending() returns true if integer list is sorted descending") { val sortedList = listOf(13, 7, 7, 1, -1) - assertTrue(sortedList.isSortedDescending()) + sortedList.isSortedDescending().shouldBeTrue() } - @Test - fun `isSortedDescending() returns false if integer list is not sorted descending`() { + test("isSortedDescending() returns false if integer list is not sorted descending") { val sortedList = listOf(13, 7, 7, 1, -1, 0) - assertFalse(sortedList.isSortedDescending()) + sortedList.isSortedDescending().shouldBeFalse() } } -} +}) diff --git a/rtron-std/src/test/kotlin/io/rtron/std/ListsKtTest.kt b/rtron-std/src/test/kotlin/io/rtron/std/ListsKtTest.kt index 7aea74cc..8c31de71 100644 --- a/rtron-std/src/test/kotlin/io/rtron/std/ListsKtTest.kt +++ b/rtron-std/src/test/kotlin/io/rtron/std/ListsKtTest.kt @@ -16,18 +16,14 @@ package io.rtron.std +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatIllegalArgumentException -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class ListsKtTest { +class ListsKtTest : FunSpec({ + context("TestMoveWindow") { - @Nested - inner class TestMoveWindow { - - @Test - fun `basic moving window test with differently sized lists`() { + test("basic moving window test with differently sized lists") { val listA = listOf(false, false, true, false, false) val listB = listOf(true, true, false) val expectedList = listOf(false, false, true, true, false, false, false) @@ -41,8 +37,7 @@ internal class ListsKtTest { assertThat(actualList).isEqualTo(expectedList) } - @Test - fun `fail if base list is empty`() { + test("fail if base list is empty") { val listA = listOf() val listB = listOf(true, false) @@ -55,8 +50,7 @@ internal class ListsKtTest { } } - @Test - fun `fail if other list is empty`() { + test("fail if other list is empty") { val listA = listOf(true, false) val listB = listOf() @@ -69,8 +63,7 @@ internal class ListsKtTest { } } - @Test - fun `moving window with same type shape`() { + test("moving window with same type shape") { val listA = listOf(false, false, true, false, false) val listB = listOf(true, true, false) val expectedList = listOf(false, false, true, true, false) @@ -85,8 +78,7 @@ internal class ListsKtTest { assertThat(actualList).isEqualTo(expectedList) } - @Test - fun `moving window with doubles`() { + test("moving window with doubles") { val listA = listOf(0.0, 2.0, 1.0, 0.0, 0.0) val listB = listOf(1.0, 1.0, 0.0) val expectedList = listOf(0.0, 2.0, 3.0, 1.0, 0.0, 0.0, 0.0) @@ -101,10 +93,9 @@ internal class ListsKtTest { } } - @Nested - inner class TestSlidedWindowBoolean { - @Test - fun `moving window with booleans and type same`() { + context("TestSlidedWindowBoolean") { + + test("moving window with booleans and type same") { val listA = listOf(false, true, false, false, false, true, false) val listB = listOf(true, false, true) val expectedList = listOf(false, true, false, true, false, true, false) @@ -115,11 +106,9 @@ internal class ListsKtTest { } } - @Nested - inner class TestFilterWindowedEnclosing { + context("TestFilterWindowedEnclosing") { - @Test - fun `fail if requested sublist size is greater than list size`() { + test("fail if requested sublist size is greater than list size") { val mainList = listOf("a", "a", "a", "b", "c", "c") assertThatIllegalArgumentException().isThrownBy { @@ -127,8 +116,7 @@ internal class ListsKtTest { } } - @Test - fun `test basic sublist pattern filter`() { + test("test basic sublist pattern filter") { val mainList = listOf(1, 2, 3, 4, 4, 3, 3, 4, 4, 5, 6, 7, 8) val expectedList = listOf(1, 2, 3, 5, 6, 7, 8) @@ -137,8 +125,7 @@ internal class ListsKtTest { assertThat(actualList).isEqualTo(expectedList) } - @Test - fun `sublist pattern filter with drop indices on characters`() { + test("sublist pattern filter with drop indices on characters") { val mainList = listOf("P1", "P2", "P3", "P4", "P3", "P5", "P6", "P7", "P8") val dropIndices = listOf(false, true, true) val expectedList = listOf("P1", "P2", "P3", "P5", "P6", "P7", "P8") @@ -148,8 +135,7 @@ internal class ListsKtTest { assertThat(actualList).isEqualTo(expectedList) } - @Test - fun `test removal of consecutive duplicates`() { + test("test removal of consecutive duplicates") { val mainList = listOf("A", "A", "B", "C", "D") val dropIndices = listOf(false, true) val expectedList = listOf("A", "B", "C", "D") @@ -159,8 +145,7 @@ internal class ListsKtTest { assertThat(actualList).isEqualTo(expectedList) } - @Test - fun `test removal of consecutive and enclosing duplicates by dropping the first window indices`() { + test("test removal of consecutive and enclosing duplicates by dropping the first window indices") { val mainList = listOf("A", "A", "B", "C", "A") val dropIndices = listOf(true, false) val expectedList = listOf("A", "B", "C") @@ -170,8 +155,7 @@ internal class ListsKtTest { assertThat(actualList).isEqualTo(expectedList) } - @Test - fun `test removal of consecutive and enclosing duplicates by dropping the second window indices`() { + test("test removal of consecutive and enclosing duplicates by dropping the second window indices") { val mainList = listOf("A", "A", "B", "C", "A") val dropIndices = listOf(false, true) val expectedList = listOf("A", "B", "C", "A") @@ -181,4 +165,4 @@ internal class ListsKtTest { assertThat(actualList).isEqualTo(expectedList) } } -} +}) diff --git a/rtron-std/src/test/kotlin/io/rtron/std/SequencesKtTest.kt b/rtron-std/src/test/kotlin/io/rtron/std/SequencesKtTest.kt index 59dcf64a..5ef72adc 100644 --- a/rtron-std/src/test/kotlin/io/rtron/std/SequencesKtTest.kt +++ b/rtron-std/src/test/kotlin/io/rtron/std/SequencesKtTest.kt @@ -16,17 +16,13 @@ package io.rtron.std +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class SequencesKtTest { +class SequencesKtTest : FunSpec({ + context("TestZipWithNextEnclosing") { - @Nested - inner class TestZipWithNextEnclosing { - - @Test - fun `test basic sequence`() { + test("test basic sequence") { val expectedZips = listOf(Pair("a", "b"), Pair("b", "c"), Pair("c", "a")) val actualZips = listOf("a", "b", "c").zipWithNextEnclosing() @@ -34,26 +30,22 @@ internal class SequencesKtTest { assertThat(actualZips).isEqualTo(expectedZips) } - @Test - fun `empty list should return an empty list`() { + test("empty list should return an empty list") { val actualZips = emptyList().zipWithNextEnclosing() assertThat(actualZips).isEqualTo(emptyList()) } - @Test - fun `list with a single element should return an empty list`() { + test("list with a single element should return an empty list") { val actualZips = listOf("a").zipWithNextEnclosing() assertThat(actualZips).isEqualTo(emptyList()) } } - @Nested - inner class TestZipWithConsecutives { + context("TestZipWithConsecutives") { - @Test - fun `test basic sequence`() { + test("test basic sequence") { val expected = listOf(listOf("a", "a", "a"), listOf("b"), listOf("c", "c")) val actual = listOf("a", "a", "a", "b", "c", "c").zipWithConsecutives { it } @@ -61,8 +53,7 @@ internal class SequencesKtTest { assertThat(actual).isEqualTo(expected) } - @Test - fun `test basic sequence with same enclosing pair`() { + test("test basic sequence with same enclosing pair") { val expected = listOf(listOf("a", "a", "a"), listOf("b"), listOf("c", "c"), listOf("a")) val actual = listOf("a", "a", "a", "b", "c", "c", "a").zipWithConsecutives { it } @@ -70,26 +61,22 @@ internal class SequencesKtTest { assertThat(actual).isEqualTo(expected) } - @Test - fun `empty list should return an empty list`() { + test("empty list should return an empty list") { val actualZips = emptyList().zipWithConsecutives { it } assertThat(actualZips).isEqualTo(emptyList()) } - @Test - fun `test single element`() { + test("test single element") { val actualZips = listOf("a").zipWithConsecutives { it } assertThat(actualZips).isEqualTo(listOf(listOf("a"))) } } - @Nested - inner class TestZipWithConsecutivesEnclosing { + context("TestZipWithConsecutivesEnclosing") { - @Test - fun `test without enclosing pair`() { + test("test without enclosing pair") { val expected = listOf(listOf("a", "a", "a"), listOf("b"), listOf("c", "c")) val actual = listOf("a", "a", "a", "b", "c", "c").zipWithConsecutivesEnclosing { it } @@ -97,8 +84,7 @@ internal class SequencesKtTest { assertThat(actual).isEqualTo(expected) } - @Test - fun `test basic sequence with same enclosing pair`() { + test("test basic sequence with same enclosing pair") { val elements = listOf("a", "a", "a", "b", "c", "c", "a") val expectedZips = listOf(listOf("a", "a", "a", "a"), listOf("b"), listOf("c", "c")) @@ -107,22 +93,19 @@ internal class SequencesKtTest { assertThat(actualZips).isEqualTo(expectedZips) } - @Test - fun `empty list should return an empty list`() { + test("empty list should return an empty list") { val actualZips = emptyList().zipWithConsecutivesEnclosing { it } assertThat(actualZips).isEqualTo(emptyList()) } - @Test - fun `test single element`() { + test("test single element") { val actualZips = listOf("a").zipWithConsecutivesEnclosing { it } assertThat(actualZips).isEqualTo(listOf(listOf("a"))) } - @Test - fun `test ordering`() { + test("test ordering") { val pair1 = Pair(1, "a") val pair2 = Pair(1, "b") val pair3 = Pair(2, "a") @@ -141,4 +124,4 @@ internal class SequencesKtTest { assertThat(actualZips).isEqualTo(expectedZips) } } -} +}) diff --git a/rtron-std/src/test/kotlin/io/rtron/std/SetsKtTest.kt b/rtron-std/src/test/kotlin/io/rtron/std/SetsKtTest.kt index 14ad68fc..0210eb97 100644 --- a/rtron-std/src/test/kotlin/io/rtron/std/SetsKtTest.kt +++ b/rtron-std/src/test/kotlin/io/rtron/std/SetsKtTest.kt @@ -16,17 +16,13 @@ package io.rtron.std +import io.kotest.core.spec.style.FunSpec import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -internal class SetsKtTest { +class SetsKtTest : FunSpec({ + context("TestCombinations") { - @Nested - inner class TestCombinations { - - @Test - fun `test basic combination generation`() { + test("test basic combination generation") { val startSet = setOf("a", "b", "c") val expectedCombinations = setOf( setOf("a", "b"), @@ -39,4 +35,4 @@ internal class SetsKtTest { assertThat(actualCombinations).isEqualTo(expectedCombinations) } } -} +})