From 8bee5c03b6afa36b8f2d3bc932731e766e86fa6f Mon Sep 17 00:00:00 2001 From: Benedikt Schwab Date: Wed, 13 Sep 2023 06:57:06 +0200 Subject: [PATCH] replaced assertions with kotest --- build.gradle.kts | 2 +- buildSrc/src/main/kotlin/Dependencies.kt | 4 +- .../io/rtron/math/analysis/FresnelTest.kt | 20 ++--- .../analysis/function/LinearFunctionTest.kt | 19 +++-- .../SectionedBivariateFunctionTest.kt | 4 +- .../combination/ConcatenatedFunctionTest.kt | 44 +++++------ .../euclidean/threed/Rotation3DTest.kt | 22 +++--- .../geometry/euclidean/threed/Vector3DTest.kt | 22 +++--- .../euclidean/threed/curve/Curve3DTest.kt | 12 +-- .../euclidean/threed/curve/Line3DTest.kt | 6 +- .../threed/curve/LineSegment3DTest.kt | 12 +-- .../threed/curve/LineString3DTest.kt | 30 ++++--- .../euclidean/threed/point/Pose3DTest.kt | 4 +- .../euclidean/threed/solid/Cuboid3DTest.kt | 11 +-- .../threed/surface/LinearRing3DUtilTest.kt | 4 +- .../euclidean/threed/surface/Polygon3DTest.kt | 33 ++++---- .../geometry/euclidean/twod/Pose2DTest.kt | 10 +-- .../euclidean/twod/curve/Arc2DTest.kt | 78 +++++++------------ .../twod/curve/CompositeCurve2DTest.kt | 10 +-- .../euclidean/twod/curve/CubicCurve2DTest.kt | 35 ++++----- .../euclidean/twod/curve/LineSegment2DTest.kt | 42 ++++------ .../twod/curve/ParametricCubicCurve2DTest.kt | 36 ++++----- .../euclidean/twod/curve/Spiral2DTest.kt | 40 +++++----- .../twod/curve/SpiralSegment2DTest.kt | 60 ++++++-------- .../euclidean/twod/point/Vector2DTest.kt | 14 ++-- .../euclidean/twod/surface/Polygon2DTest.kt | 9 ++- .../io/rtron/math/linear/MatrixUtilsTest.kt | 6 +- .../io/rtron/math/linear/RealMatrixTest.kt | 14 ++-- .../rtron/math/linear/RealVectorUtilsTest.kt | 8 +- .../linear/SingularValueDecompositionTest.kt | 28 +++---- .../rtron/math/processing/Plane3DUtilTest.kt | 17 ++-- .../processing/Vector2DListExtensionsTest.kt | 4 +- .../processing/Vector3DListExtensionsTest.kt | 20 ++--- .../CoordinateReferenceSystemTest.kt | 14 ++-- .../range/DoubleRangeSetExtensionsTest.kt | 8 +- .../io/rtron/math/range/RangeSetTest.kt | 8 +- .../kotlin/io/rtron/math/range/RangeTest.kt | 12 +-- .../math/std/DoubleArrayExtensionTest.kt | 4 +- .../io/rtron/math/transform/Affine3DTest.kt | 20 +++-- .../kotlin/io/rtron/std/CollectionsKtTest.kt | 52 ++++++------- .../test/kotlin/io/rtron/std/ListsKtTest.kt | 28 +++---- .../kotlin/io/rtron/std/SequencesKtTest.kt | 26 +++---- .../test/kotlin/io/rtron/std/SetsKtTest.kt | 4 +- 43 files changed, 398 insertions(+), 458 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a9604fe5..2b0b5366 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -71,7 +71,7 @@ allprojects { implementation(Dependencies.arrowOptics) testImplementation(Dependencies.kotest) - testImplementation(Dependencies.assertj) + testImplementation(Dependencies.kotestExtensionArrow) testImplementation(Dependencies.mockk) } diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 730021fe..3d0c14bf 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -23,7 +23,7 @@ object DependencyVersions { // testing libraries const val kotest = "5.7.1" - const val assertj = "3.24.2" + const val kotestExtensionArrow = "1.3.3" const val mockk = "1.13.7" // logging libraries @@ -71,7 +71,7 @@ object Dependencies { // testing libraries const val kotest = "io.kotest:kotest-runner-junit5:${DependencyVersions.kotest}" - const val assertj = "org.assertj:assertj-core:${DependencyVersions.assertj}" + const val kotestExtensionArrow = "io.kotest.extensions:kotest-assertions-arrow:${DependencyVersions.kotestExtensionArrow}" const val mockk = "io.mockk:mockk:${DependencyVersions.mockk}" // logging libraries 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 f2c70459..350174af 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 @@ -17,12 +17,12 @@ package io.rtron.math.analysis import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe 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 java.io.FileReader import kotlin.io.path.Path import kotlin.io.path.absolute @@ -51,30 +51,30 @@ class FresnelTest : FunSpec({ val (actualX, actualY) = Fresnel.calculatePoint(l) - assertThat(actualX).isCloseTo(x, Offset.offset(DBL_EPSILON)) - assertThat(actualY).isCloseTo(y, Offset.offset(DBL_EPSILON)) + actualX.shouldBe(x plusOrMinus DBL_EPSILON) + actualY.shouldBe(y plusOrMinus DBL_EPSILON) } } 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)) + actualX.shouldBe(-0.51547336206019945 plusOrMinus DBL_EPSILON) + actualY.shouldBe(-0.5736113070569262 plusOrMinus DBL_EPSILON) } 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)) + actualX.shouldBe(0.50035646758310326 plusOrMinus DBL_EPSILON) + actualY.shouldBe(0.49994666781760994 plusOrMinus DBL_EPSILON) } 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)) + actualX.shouldBe(-0.33992314562581244 plusOrMinus DBL_EPSILON) + actualY.shouldBe(-0.43687889962705617 plusOrMinus 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 cea82850..edc7eb68 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,11 +17,12 @@ package io.rtron.math.analysis.function import arrow.core.Either +import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe +import io.kotest.matchers.types.shouldBeInstanceOf 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 class LinearFunctionTest : FunSpec({ context("TestValueCalculation") { @@ -32,7 +33,7 @@ class LinearFunctionTest : FunSpec({ val actualResult = linearFunction.value(3.0) require(actualResult is Either.Right) - assertThat(actualResult.value).isEqualTo(40.0) + actualResult.value shouldBe 40.0 } test("out of range value evaluation throws an IllegalArgumentException") { @@ -41,7 +42,7 @@ class LinearFunctionTest : FunSpec({ val actualResult = linearFunction.value(3.0) require(actualResult is Either.Left) - assertThat(actualResult.value).isInstanceOf(IllegalArgumentException::class.java) + actualResult.value.shouldBeInstanceOf() } } @@ -56,14 +57,16 @@ class LinearFunctionTest : FunSpec({ val actualLinearFunction = LinearFunction.ofInclusivePoints(3.0, 2.0, 7.0, -4.0) - assertThat(actualLinearFunction).isEqualTo(expectedLinearFunction) + actualLinearFunction shouldBe expectedLinearFunction } test("creation of linear function with two equal points throws an IllegalArgumentException") { val x = 2.1 val y = 3.4 - assertThatIllegalArgumentException().isThrownBy { LinearFunction.ofInclusivePoints(x, y, x, y) } + shouldThrow { + LinearFunction.ofInclusivePoints(x, y, x, y) + } } } @@ -78,7 +81,7 @@ class LinearFunctionTest : FunSpec({ val actualLinearFunction = LinearFunction.ofInclusiveYValuesAndUnitSlope(2.0, 4.0) - assertThat(actualLinearFunction).isEqualTo(expectedLinearFunction) + actualLinearFunction shouldBe expectedLinearFunction } test("with negative unit slope") { @@ -90,7 +93,7 @@ class LinearFunctionTest : FunSpec({ val actualLinearFunction = LinearFunction.ofInclusiveYValuesAndUnitSlope(17.0, 14.0) - assertThat(actualLinearFunction).isEqualTo(expectedLinearFunction) + actualLinearFunction shouldBe 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 1a838bde..c1ef4fcd 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 @@ -18,10 +18,10 @@ package io.rtron.math.analysis.function.bivariate import arrow.core.Either import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe 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 class SectionedBivariateFunctionTest : FunSpec({ context("TestCreation") { @@ -33,7 +33,7 @@ class SectionedBivariateFunctionTest : FunSpec({ val actualResult = sectionedPlane.value(0.0, 0.0) require(actualResult is Either.Right) - assertThat(actualResult.value).isEqualTo(1.0) + actualResult.value shouldBe 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 ff6ee5cc..13aac811 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 @@ -19,7 +19,7 @@ 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 io.kotest.matchers.shouldBe class ConcatenatedFunctionTest : FunSpec({ @@ -37,11 +37,11 @@ class ConcatenatedFunctionTest : FunSpec({ require(actualResult1 is Either.Left) require(actualResult2 is Either.Right) - assertThat(actualResult2.value).isEqualTo(0.0) + actualResult2.value shouldBe 0.0 require(actualResult3 is Either.Right) - assertThat(actualResult3.value).isEqualTo(-5.0) + actualResult3.value shouldBe -5.0 require(actualResult4 is Either.Right) - assertThat(actualResult4.value).isEqualTo(-5.0) + actualResult4.value shouldBe -5.0 } test("concatenated function with absolute start at -2") { @@ -56,11 +56,11 @@ class ConcatenatedFunctionTest : FunSpec({ require(actualResult1 is Either.Left) require(actualResult2 is Either.Right) - assertThat(actualResult2.value).isEqualTo(0.0) + actualResult2.value shouldBe 0.0 require(actualResult3 is Either.Right) - assertThat(actualResult3.value).isEqualTo(-5.0) + actualResult3.value shouldBe -5.0 require(actualResult4 is Either.Right) - assertThat(actualResult4.value).isEqualTo(-5.0) + actualResult4.value shouldBe -5.0 } test("concatenated function with absolute start at 2") { @@ -75,11 +75,11 @@ class ConcatenatedFunctionTest : FunSpec({ require(actualResult1 is Either.Left) require(actualResult2 is Either.Right) - assertThat(actualResult2.value).isEqualTo(0.0) + actualResult2.value shouldBe 0.0 require(actualResult3 is Either.Right) - assertThat(actualResult3.value).isEqualTo(-5.0) + actualResult3.value shouldBe -5.0 require(actualResult4 is Either.Right) - assertThat(actualResult4.value).isEqualTo(-5.0) + actualResult4.value shouldBe -5.0 } } @@ -100,13 +100,13 @@ class ConcatenatedFunctionTest : FunSpec({ val actualResult4 = concatenatedFunction.valueInFuzzy(7.0, 1E-7) require(actualResult1 is Either.Right) - assertThat(actualResult1.value).isEqualTo(2.0) + actualResult1.value shouldBe 2.0 require(actualResult2 is Either.Right) - assertThat(actualResult2.value).isEqualTo(32.0) + actualResult2.value shouldBe 32.0 require(actualResult3 is Either.Right) - assertThat(actualResult3.value).isEqualTo(1.0) + actualResult3.value shouldBe 1.0 require(actualResult4 is Either.Right) - assertThat(actualResult4.value).isEqualTo(49.0) + actualResult4.value shouldBe 49.0 } test("concatenated function with absolute start at -2") { @@ -124,13 +124,13 @@ class ConcatenatedFunctionTest : FunSpec({ val actualResult4 = concatenatedFunction.valueInFuzzy(5.0, 1E-7) require(actualResult1 is Either.Right) - assertThat(actualResult1.value).isEqualTo(2.0) + actualResult1.value shouldBe 2.0 require(actualResult2 is Either.Right) - assertThat(actualResult2.value).isEqualTo(32.0) + actualResult2.value shouldBe 32.0 require(actualResult3 is Either.Right) - assertThat(actualResult3.value).isEqualTo(1.0) + actualResult3.value shouldBe 1.0 require(actualResult4 is Either.Right) - assertThat(actualResult4.value).isEqualTo(49.0) + actualResult4.value shouldBe 49.0 } test("concatenated function with absolute start at 2") { @@ -148,13 +148,13 @@ class ConcatenatedFunctionTest : FunSpec({ val actualResult4 = concatenatedFunction.valueInFuzzy(9.0, 1E-7) require(actualResult1 is Either.Right) - assertThat(actualResult1.value).isEqualTo(2.0) + actualResult1.value shouldBe 2.0 require(actualResult2 is Either.Right) - assertThat(actualResult2.value).isEqualTo(32.0) + actualResult2.value shouldBe 32.0 require(actualResult3 is Either.Right) - assertThat(actualResult3.value).isEqualTo(1.0) + actualResult3.value shouldBe 1.0 require(actualResult4 is Either.Right) - assertThat(actualResult4.value).isEqualTo(49.0) + actualResult4.value shouldBe 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 2d283613..8ab2f1db 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 @@ -17,13 +17,13 @@ package io.rtron.math.geometry.euclidean.threed import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe import io.rtron.math.std.DBL_EPSILON import io.rtron.math.std.DBL_EPSILON_3 import io.rtron.math.std.HALF_PI 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 class Rotation3DTest : FunSpec({ context("TestAngleAssignments") { @@ -31,55 +31,55 @@ class Rotation3DTest : FunSpec({ 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)) + actualHeading.shouldBe(HALF_PI plusOrMinus DBL_EPSILON) } 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)) + actualHeading.shouldBe(0.0 plusOrMinus DBL_EPSILON_3) } 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)) + actualHeading.shouldBe(HALF_PI plusOrMinus DBL_EPSILON_3) } 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)) + actualPitch.shouldBe(QUARTER_PI plusOrMinus DBL_EPSILON) } 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)) + actualPitch.shouldBe(0.0 plusOrMinus DBL_EPSILON_3) } 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)) + actualPitch.shouldBe(QUARTER_PI plusOrMinus DBL_EPSILON_3) } 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)) + actualRoll.shouldBe(HALF_PI plusOrMinus DBL_EPSILON) } 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)) + actualRoll.shouldBe(0.0 plusOrMinus DBL_EPSILON_3) } 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)) + actualRoll.shouldBe(HALF_PI plusOrMinus 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 59c7138a..60fa786a 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,14 +16,14 @@ package io.rtron.math.geometry.euclidean.threed +import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.booleans.shouldBeFalse import io.kotest.matchers.booleans.shouldBeTrue +import io.kotest.matchers.shouldBe 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 class Vector3DTest : FunSpec({ context("Addition") { @@ -34,7 +34,7 @@ class Vector3DTest : FunSpec({ val actualSum = pointA + pointB - assertThat(actualSum).isEqualTo(Vector3D(2.0, 2.0, 2.0)) + actualSum shouldBe Vector3D(2.0, 2.0, 2.0) } test("adding points with negative coordinates") { @@ -43,7 +43,7 @@ class Vector3DTest : FunSpec({ val actualSum = pointA + pointB - assertThat(actualSum).isEqualTo(Vector3D(0.0, 0.0, 0.0)) + actualSum shouldBe Vector3D(0.0, 0.0, 0.0) } } @@ -55,7 +55,7 @@ class Vector3DTest : FunSpec({ val actualDifference = pointA - pointB - assertThat(actualDifference).isEqualTo(Vector3D(2.0, 2.0, 2.0)) + actualDifference shouldBe Vector3D(2.0, 2.0, 2.0) } } @@ -64,7 +64,7 @@ class Vector3DTest : FunSpec({ 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)) + actualResult shouldBe Vector3D(4.0, 4.0, 4.0) } } @@ -73,11 +73,11 @@ class Vector3DTest : FunSpec({ 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)) + actualResult shouldBe Vector3D(0.5, 1.0, 0.25) } test("scalar division by zero throws error") { - Assertions.assertThatIllegalArgumentException().isThrownBy { + shouldThrow { Vector3D(2.0, 4.0, 1.0).scalarDivide(0.0) } } @@ -90,7 +90,7 @@ class Vector3DTest : FunSpec({ point.normalized() - assertThat(point).isEqualTo(Vector3D(2.0, 4.0, 1.0)) + point shouldBe Vector3D(2.0, 4.0, 1.0) } } @@ -102,7 +102,7 @@ class Vector3DTest : FunSpec({ val actualSum = pointA.angle(pointB) - assertThat(actualSum).isEqualTo(HALF_PI) + actualSum shouldBe HALF_PI } test("adding points with positive coordinates") { @@ -111,7 +111,7 @@ class Vector3DTest : FunSpec({ val actualSum = pointA.angle(pointB) - assertThat(actualSum).isEqualTo(PI) + actualSum shouldBe PI } } 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 18f16f20..26222adc 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 @@ -17,6 +17,8 @@ package io.rtron.math.geometry.euclidean.threed.curve import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe 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 @@ -25,8 +27,6 @@ import io.rtron.math.geometry.euclidean.twod.point.Vector2D import io.rtron.math.std.DBL_EPSILON 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 kotlin.math.sqrt class Curve3DTest : FunSpec({ @@ -41,7 +41,7 @@ class Curve3DTest : FunSpec({ val actualPointGlobal = affine.transform(pointLocal) - assertThat(actualPointGlobal).isEqualTo(Vector3D(0.5, 1.0, 0.0)) + actualPointGlobal shouldBe Vector3D(0.5, 1.0, 0.0) } test("curve with constant torsion of quarter pi") { @@ -54,8 +54,8 @@ class Curve3DTest : FunSpec({ val actualPointGlobal = affine.transform(pointLocal) - assertThat(actualPointGlobal.y).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) - assertThat(actualPointGlobal.z).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) + actualPointGlobal.y.shouldBe(1.0 plusOrMinus DBL_EPSILON) + actualPointGlobal.z.shouldBe(1.0 plusOrMinus DBL_EPSILON) } test("curve with constant torsion of half pi") { @@ -68,7 +68,7 @@ class Curve3DTest : FunSpec({ val actualPointGlobal = affine.transform(pointLocal) - assertThat(actualPointGlobal).isEqualTo(Vector3D(0.5, 0.0, 1.0)) + actualPointGlobal shouldBe 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 ac683ec9..9f51a4f5 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,9 +16,9 @@ package io.rtron.math.geometry.euclidean.threed.curve +import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec import io.rtron.math.geometry.euclidean.threed.point.Vector3D -import org.assertj.core.api.Assertions.assertThatIllegalArgumentException class Line3DTest : FunSpec({ context("Addition") { @@ -26,7 +26,9 @@ class Line3DTest : FunSpec({ test("throws error if ") { val point = Vector3D(1.0, 1.0, 1.0) - assertThatIllegalArgumentException().isThrownBy { Line3D(point, point, 0.0) } + shouldThrow { + 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 4b527ba4..e3ca2a24 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 @@ -17,8 +17,8 @@ package io.rtron.math.geometry.euclidean.threed.curve import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe import io.rtron.math.geometry.euclidean.threed.point.Vector3D -import org.assertj.core.api.Assertions.assertThat class LineSegment3DTest : FunSpec({ context("TestDistance") { @@ -30,7 +30,7 @@ class LineSegment3DTest : FunSpec({ val actualResultingVertices = lineSegment.distance(point) - assertThat(actualResultingVertices).isEqualTo(expectedDistance) + actualResultingVertices shouldBe expectedDistance } test("point located outside of line segment returns the distance to closest boundary point") { @@ -40,7 +40,7 @@ class LineSegment3DTest : FunSpec({ val actualResultingVertices = lineSegment.distance(point) - assertThat(actualResultingVertices).isEqualTo(expectedDistance) + actualResultingVertices shouldBe expectedDistance } test("point located not on line segment returns the correct distance") { @@ -50,7 +50,7 @@ class LineSegment3DTest : FunSpec({ val actualResultingVertices = lineSegment.distance(point) - assertThat(actualResultingVertices).isEqualTo(expectedDistance) + actualResultingVertices shouldBe expectedDistance } test("boundary point of line segment returns the zero distance") { @@ -60,7 +60,7 @@ class LineSegment3DTest : FunSpec({ val actualResultingVertices = lineSegment.distance(point) - assertThat(actualResultingVertices).isEqualTo(expectedDistance) + actualResultingVertices shouldBe expectedDistance } test("point on line but outside of line segment return distances to the shortest boundary point") { @@ -70,7 +70,7 @@ class LineSegment3DTest : FunSpec({ val actualResultingVertices = lineSegment.distance(point) - assertThat(actualResultingVertices).isEqualTo(expectedDistance) + actualResultingVertices shouldBe 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 b0eafb3b..62cd81d2 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 @@ -16,14 +16,14 @@ package io.rtron.math.geometry.euclidean.threed.curve -import arrow.core.Either import arrow.core.nonEmptyListOf +import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe 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 class LineString3DTest : FunSpec({ context("TestLengthCalculation") { @@ -33,7 +33,7 @@ class LineString3DTest : FunSpec({ val actualLength = lineString.length - assertThat(actualLength).isEqualTo(1.0) + actualLength shouldBe 1.0 } test("line string with multiple points should have a length of 1") { @@ -45,7 +45,7 @@ class LineString3DTest : FunSpec({ val actualLength = lineString.length - assertThat(actualLength).isEqualTo(3.0) + actualLength shouldBe 3.0 } } @@ -56,13 +56,11 @@ class LineString3DTest : FunSpec({ val pointB = Vector3D(0.0, 10.0, 0.0) val lineString = LineString3D(nonEmptyListOf(pointA, pointB), 0.0) - val actualReturn = lineString.calculatePointGlobalCS(CurveRelativeVector1D(5.0)) + val actualPoint = lineString.calculatePointGlobalCS(CurveRelativeVector1D(5.0)).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.x).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.y).isCloseTo(5.0, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.z).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) + actualPoint.x.shouldBe(0.0 plusOrMinus DBL_EPSILON) + actualPoint.y.shouldBe(5.0 plusOrMinus DBL_EPSILON) + actualPoint.z.shouldBe(0.0 plusOrMinus DBL_EPSILON) } test("line string with multiple points yields point on the top") { @@ -72,13 +70,11 @@ class LineString3DTest : FunSpec({ val pointD = Vector3D(0.0, 1.0, 0.0) val lineString = LineString3D(nonEmptyListOf(pointA, pointB, pointC, pointD), 0.0) - val actualReturn = lineString.calculatePointGlobalCS(CurveRelativeVector1D(2.5)) + val actualPoint = lineString.calculatePointGlobalCS(CurveRelativeVector1D(2.5)).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.x).isCloseTo(0.5, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.y).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.z).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) + actualPoint.x.shouldBe(0.5 plusOrMinus DBL_EPSILON) + actualPoint.y.shouldBe(1.0 plusOrMinus DBL_EPSILON) + actualPoint.z.shouldBe(0.0 plusOrMinus 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 b616a8c8..4fa6d35f 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 @@ -17,12 +17,12 @@ package io.rtron.math.geometry.euclidean.threed.point import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe 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 class Pose3DTest : FunSpec({ context("TestConversionToPose2D") { @@ -35,7 +35,7 @@ class Pose3DTest : FunSpec({ val actualPose2D = pose3D.toPose2D(Vector3D.Y_AXIS) - assertThat(actualPose2D).isEqualTo(expectedPose2D) + actualPose2D shouldBe 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 91461a76..03f6b7b9 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 @@ -17,9 +17,10 @@ package io.rtron.math.geometry.euclidean.threed.solid import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.collections.shouldContain +import io.kotest.matchers.collections.shouldHaveSize 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 class Cuboid3DTest : FunSpec({ context("PolygonsGeneration") { @@ -29,7 +30,7 @@ class Cuboid3DTest : FunSpec({ val actualPolygons = cuboid.calculatePolygonsGlobalCS() - assertThat(actualPolygons).hasSize(6) + actualPolygons shouldHaveSize 6 } test("generated polygons list contain base polygon") { @@ -44,7 +45,7 @@ class Cuboid3DTest : FunSpec({ val actualPolygons = cuboid.calculatePolygonsGlobalCS() - assertThat(actualPolygons).contains(expectedBasePolygon) + actualPolygons.shouldContain(expectedBasePolygon) } test("generated polygons list contain elevated polygon") { @@ -60,7 +61,7 @@ class Cuboid3DTest : FunSpec({ val actualPolygons = cuboid.calculatePolygonsGlobalCS() - assertThat(actualPolygons).contains(expectedBasePolygon) + actualPolygons.shouldContain(expectedBasePolygon) } test("generated polygons list contain front polygon") { @@ -76,7 +77,7 @@ class Cuboid3DTest : FunSpec({ val actualPolygons = cuboid.calculatePolygonsGlobalCS() - assertThat(actualPolygons).contains(expectedBasePolygon) + actualPolygons.shouldContain(expectedBasePolygon) } } }) 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 f9c12f2d..398fba9e 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 @@ -17,9 +17,9 @@ package io.rtron.math.geometry.euclidean.threed.surface import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe import io.rtron.math.geometry.euclidean.threed.point.Vector3D import io.rtron.math.processing.removeConsecutiveSideDuplicates -import org.assertj.core.api.Assertions.assertThat class LinearRing3DUtilTest : FunSpec({ context("TestRemoveCuts") { @@ -34,7 +34,7 @@ class LinearRing3DUtilTest : FunSpec({ val actualRemovedVerticesList = vertices.removeConsecutiveSideDuplicates() - assertThat(actualRemovedVerticesList).isEqualTo(expected) + actualRemovedVerticesList shouldBe 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 3dd6d2ef..ef57d5db 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 @@ -16,12 +16,12 @@ package io.rtron.math.geometry.euclidean.threed.surface -import arrow.core.Either import arrow.core.nonEmptyListOf +import io.kotest.assertions.arrow.core.shouldBeRight +import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe import io.rtron.math.geometry.euclidean.threed.point.Vector3D -import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatIllegalArgumentException class Polygon3DTest : FunSpec({ context("TestCreation") { @@ -30,27 +30,26 @@ class Polygon3DTest : FunSpec({ 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) } + shouldThrow { Polygon3D(nonEmptyListOf(pointA, pointB), 0.0) } } 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) } + shouldThrow { Polygon3D(nonEmptyListOf(pointA), 0.0) } } 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) } + shouldThrow { Polygon3D(nonEmptyListOf(pointA), 0.0) } } 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) - assertThatIllegalArgumentException() - .isThrownBy { Polygon3D(nonEmptyListOf(pointA, pointB, pointA), 0.0) } + shouldThrow { Polygon3D(nonEmptyListOf(pointA, pointB, pointA), 0.0) } } test("creation of polygon with three colinear points should fail") { @@ -58,8 +57,7 @@ class Polygon3DTest : FunSpec({ val pointB = Vector3D(2.0, 3.0, 0.0) val pointC = Vector3D(3.0, 4.0, 0.0) - assertThatIllegalArgumentException() - .isThrownBy { Polygon3D(nonEmptyListOf(pointA, pointB, pointC), 0.0) } + shouldThrow { Polygon3D(nonEmptyListOf(pointA, pointB, pointC), 0.0) } } test("creation of polygon with non-planar points should fail") { @@ -68,8 +66,7 @@ class Polygon3DTest : FunSpec({ val pointC = Vector3D.Y_AXIS val pointD = Vector3D(1.0, 1.0, 1.0) - assertThatIllegalArgumentException() - .isThrownBy { Polygon3D(nonEmptyListOf(pointA, pointB, pointC, pointD), 0.0) } + shouldThrow { Polygon3D(nonEmptyListOf(pointA, pointB, pointC, pointD), 0.0) } } } @@ -81,11 +78,9 @@ class Polygon3DTest : FunSpec({ val pointC = Vector3D(2.0, 2.0, 1.0) val triangle = Polygon3D(nonEmptyListOf(pointA, pointB, pointC), 0.0) - val actualReturn = triangle.getNormal() + val actualNormal = triangle.getNormal().shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value).isEqualTo(Vector3D.Z_AXIS) + actualNormal shouldBe Vector3D.Z_AXIS } test("test planar quadrilateral polygon") { @@ -100,11 +95,9 @@ class Polygon3DTest : FunSpec({ ) val expectedResult = Vector3D(0.0, -1.0, 0.0) - val actualReturn = planarQuadrilateral.getNormal() + val actualNormal = planarQuadrilateral.getNormal().shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value).isEqualTo(expectedResult) + actualNormal shouldBe 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 23a131c2..560dc972 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 @@ -17,10 +17,10 @@ package io.rtron.math.geometry.euclidean.twod import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe 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 class Pose2DTest : FunSpec({ context("TestPointAssignment") { @@ -28,13 +28,13 @@ class Pose2DTest : FunSpec({ test("assignment of positive point") { val pose = Pose2D(Vector2D(5.0, 3.0), Rotation2D.ZERO) - assertThat(pose.point).isEqualTo(Vector2D(5.0, 3.0)) + pose.point shouldBe Vector2D(5.0, 3.0) } test("assignment of negative point") { val pose = Pose2D(Vector2D(-3.0, 1.0), Rotation2D.ZERO) - assertThat(pose.point).isEqualTo(Vector2D(-3.0, 1.0)) + pose.point shouldBe Vector2D(-3.0, 1.0) } } @@ -43,13 +43,13 @@ class Pose2DTest : FunSpec({ test("assignment of two pi rotation") { val pose = Pose2D(Vector2D(5.0, 3.0), Rotation2D(TWO_PI)) - assertThat(pose.rotation.toAngleRadians()).isEqualTo(0.0) + pose.rotation.toAngleRadians() shouldBe 0.0 } test("assignment of pi rotation") { val pose = Pose2D(Vector2D(-3.0, 1.0), Rotation2D(PI)) - assertThat(pose.rotation.toAngleRadians()).isEqualTo(PI) + pose.rotation.toAngleRadians() shouldBe PI } } }) 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 ca9ddabb..d0af8060 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 @@ -16,8 +16,10 @@ package io.rtron.math.geometry.euclidean.twod.curve -import arrow.core.Either +import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe 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 @@ -27,8 +29,6 @@ import io.rtron.math.std.PI import io.rtron.math.std.TWO_PI 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 class Arc2DTest : FunSpec({ context("TestCenterCalculation") { @@ -38,7 +38,7 @@ class Arc2DTest : FunSpec({ val actualCenter = arc.center - assertThat(actualCenter).isEqualTo(Vector2D(0.0, 1.0)) + actualCenter shouldBe Vector2D(0.0, 1.0) } test("unit curvature with center below origin") { @@ -46,7 +46,7 @@ class Arc2DTest : FunSpec({ val actualCenter = arc.center - assertThat(actualCenter).isEqualTo(Vector2D(0.0, -1.0)) + actualCenter shouldBe Vector2D(0.0, -1.0) } } @@ -57,7 +57,7 @@ class Arc2DTest : FunSpec({ val actualStartAngle = arc.startAngle.toAngleRadians() - assertThat(actualStartAngle).isEqualTo(PI + HALF_PI) + actualStartAngle shouldBe PI + HALF_PI } test("starting angle with center below origin") { @@ -65,7 +65,7 @@ class Arc2DTest : FunSpec({ val actualStartAngle = arc.startAngle.toAngleRadians() - assertThat(actualStartAngle).isEqualTo(HALF_PI) + actualStartAngle shouldBe HALF_PI } } @@ -76,7 +76,7 @@ class Arc2DTest : FunSpec({ val actualEndAngle = arc.endAngle.toAngleRadians() - assertThat(actualEndAngle).isEqualTo(0.0) + actualEndAngle shouldBe 0.0 } } @@ -85,43 +85,35 @@ class Arc2DTest : FunSpec({ test("calculate pose point on the start") { val arc = Arc2D(1.0, TWO_PI, 0.0, AffineSequence2D.EMPTY) - val actualReturn = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO) + val actualPose = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point).isEqualTo(Vector2D.ZERO) + actualPose.point shouldBe Vector2D.ZERO } test("calculate pose point on the curve") { val arc = Arc2D(1.0, TWO_PI, 0.0, AffineSequence2D.EMPTY) val curveRelativePoint = CurveRelativeVector1D(HALF_PI) - val actualReturn = arc.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = arc.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point).isEqualTo(Vector2D(1.0, 1.0)) + actualPose.point shouldBe Vector2D(1.0, 1.0) } test("calculate pose angle on the start") { val arc = Arc2D(1.0, TWO_PI, 0.0, AffineSequence2D.EMPTY) - val actualReturn = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO) + val actualPose = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.rotation.toAngleRadians()).isEqualTo(0.0) + actualPose.rotation.toAngleRadians() shouldBe 0.0 } test("calculate pose angle on the curve") { val arc = Arc2D(1.0, TWO_PI, 0.0, AffineSequence2D.EMPTY) val curveRelativePoint = CurveRelativeVector1D(HALF_PI) - val actualReturn = arc.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = arc.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.rotation.toAngleRadians()).isEqualTo(HALF_PI) + actualPose.rotation.toAngleRadians() shouldBe HALF_PI } } @@ -134,11 +126,9 @@ class Arc2DTest : FunSpec({ val affineSequence = AffineSequence2D.of(affine) val arc = Arc2D(1.0, TWO_PI, 0.0, affineSequence) - val actualReturn = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO) + val actualPose = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point).isEqualTo(Vector2D(3.0, 5.0)) + actualPose.point shouldBe Vector2D(3.0, 5.0) } test("calculate pose point on the curve") { @@ -149,11 +139,9 @@ class Arc2DTest : FunSpec({ val arc = Arc2D(1.0, TWO_PI, 0.0, affineSequence) val curveRelativePoint = CurveRelativeVector1D(HALF_PI) - val actualReturn = arc.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = arc.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point).isEqualTo(Vector2D(2.0, 6.0)) + actualPose.point shouldBe Vector2D(2.0, 6.0) } test("calculate pose in fourth quadrant") { @@ -163,12 +151,10 @@ class Arc2DTest : FunSpec({ val affineSequence = AffineSequence2D.of(affine) val arc = Arc2D(0.0125, 170.0, 0.0, affineSequence) - val actualReturn = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO) + val actualPose = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(point.x, Offset.offset(DBL_EPSILON_4)) - assertThat(actualReturn.value.point.y).isCloseTo(point.y, Offset.offset(DBL_EPSILON_4)) + actualPose.point.x.shouldBe(point.x plusOrMinus DBL_EPSILON_4) + actualPose.point.y.shouldBe(point.y plusOrMinus DBL_EPSILON_4) } test("calculate pose angle on the start") { @@ -178,11 +164,9 @@ class Arc2DTest : FunSpec({ val affineSequence = AffineSequence2D.of(affine) val arc = Arc2D(1.0, TWO_PI, 0.0, affineSequence) - val actualReturn = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO) + val actualPose = arc.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.rotation.toAngleRadians()).isEqualTo(HALF_PI) + actualPose.rotation.toAngleRadians() shouldBe HALF_PI } test("calculate pose angle on the curve") { @@ -193,11 +177,9 @@ class Arc2DTest : FunSpec({ val arc = Arc2D(1.0, TWO_PI, 0.0, affineSequence) val curveRelativePoint = CurveRelativeVector1D(HALF_PI) - val actualReturn = arc.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = arc.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.rotation.toAngleRadians()).isEqualTo(PI) + actualPose.rotation.toAngleRadians() shouldBe PI } test("calculate pose angle in fourth quadrant") { @@ -208,11 +190,9 @@ class Arc2DTest : FunSpec({ val arc = Arc2D(1.0, TWO_PI, 0.0, affineSequence) val curveRelativePoint = CurveRelativeVector1D(PI) - val actualReturn = arc.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = arc.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.rotation.toAngleRadians()).isEqualTo(PI + HALF_PI) + actualPose.rotation.toAngleRadians() shouldBe 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 dfdba318..a9d9a862 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 @@ -16,8 +16,9 @@ package io.rtron.math.geometry.euclidean.twod.curve -import arrow.core.Either +import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldNotBe 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,7 +28,6 @@ import io.rtron.math.std.DBL_EPSILON_7 import io.rtron.math.transform.Affine2D import io.rtron.math.transform.AffineSequence2D import io.rtron.std.cumulativeSum -import org.assertj.core.api.Assertions.assertThat class CompositeCurve2DTest : FunSpec({ context("TestPoseCalculation") { @@ -93,11 +93,9 @@ class CompositeCurve2DTest : FunSpec({ val compositeCurve = CompositeCurve2D(curveMembers, absoluteDomains, absoluteStarts.dropLast(1)) val curveRelativePoint = CurveRelativeVector1D(compositeCurve.length) - val actualPoint = compositeCurve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = compositeCurve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualPoint).isInstanceOf(Either.Right::class.java) - require(actualPoint is Either.Right) - assertThat(actualPoint.value.point).isNotEqualTo(Vector2D.ZERO) + actualPose.point shouldNotBe 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 7a35ae5b..f4e4ad2d 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 @@ -16,8 +16,11 @@ package io.rtron.math.geometry.euclidean.twod.curve -import arrow.core.Either +import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe +import io.kotest.matchers.shouldNotBe 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 @@ -26,8 +29,6 @@ import io.rtron.math.std.DBL_EPSILON import io.rtron.math.std.HALF_PI 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 class CubicCurve2DTest : FunSpec({ context("TestPoseCalculation") { @@ -40,13 +41,11 @@ class CubicCurve2DTest : FunSpec({ val curve = CubicCurve2D(coefficients, 1.0, 0.0, affineSequence) val curveRelativePoint = CurveRelativeVector1D(1.0) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.point.y).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.rotation.angle).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) + actualPose.point.x.shouldBe(1.0 plusOrMinus DBL_EPSILON) + actualPose.point.y.shouldBe(1.0 plusOrMinus DBL_EPSILON) + actualPose.rotation.angle.shouldBe(1.0 plusOrMinus DBL_EPSILON) } test("pose calculation of straight line with start pose offset") { @@ -57,12 +56,10 @@ class CubicCurve2DTest : FunSpec({ val curve = CubicCurve2D(coefficients, 1.0, 0.0, affineSequence) val curveRelativePoint = CurveRelativeVector1D(1.0) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(-1.0, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.point.y).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) + actualPose.point.x.shouldBe(-1.0 plusOrMinus DBL_EPSILON) + actualPose.point.y.shouldBe(1.0 plusOrMinus DBL_EPSILON) } /** @@ -79,13 +76,11 @@ class CubicCurve2DTest : FunSpec({ val curve = CubicCurve2D(coefficients, length, 1E-4, affineSequence) val curveRelativePoint = CurveRelativeVector1D(length) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isNotCloseTo(-5.0558344684384622e+00, Offset.offset(DBL_EPSILON)) // not coincident with next curve element - assertThat(actualReturn.value.point.y).isNotCloseTo(9.6260358855640789e+00, Offset.offset(DBL_EPSILON)) // not coincident with next curve element - assertThat(actualReturn.value.rotation.angle).isNotCloseTo(3.8412114603351055e-01, Offset.offset(DBL_EPSILON)) // not coincident with next curve element + actualPose.point.x.shouldNotBe(-5.0558344684384622e+00 plusOrMinus DBL_EPSILON) // not coincident with next curve element + actualPose.point.y.shouldNotBe(9.6260358855640789e+00 plusOrMinus DBL_EPSILON) // not coincident with next curve element + actualPose.rotation.angle.shouldNotBe(3.8412114603351055e-01 plusOrMinus 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 55b8f539..feb89805 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 @@ -16,15 +16,15 @@ package io.rtron.math.geometry.euclidean.twod.curve -import arrow.core.Either +import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe 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 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 kotlin.math.sqrt class LineSegment2DTest : FunSpec({ @@ -35,7 +35,7 @@ class LineSegment2DTest : FunSpec({ val pointB = Vector2D(7.0, 0.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) - assertThat(lineSegment.length).isCloseTo(7.0, Offset.offset(DBL_EPSILON)) + lineSegment.length.shouldBe(7.0 plusOrMinus DBL_EPSILON) } test("length of diagonal line segment") { @@ -43,7 +43,7 @@ class LineSegment2DTest : FunSpec({ val pointB = Vector2D(0.0, 4.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) - assertThat(lineSegment.length).isCloseTo(5.0, Offset.offset(DBL_EPSILON)) + lineSegment.length.shouldBe(5.0 plusOrMinus DBL_EPSILON) } } @@ -54,11 +54,9 @@ class LineSegment2DTest : FunSpec({ val pointB = Vector2D(0.0, 1.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) - val actualReturn = lineSegment.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO) + val actualPose = lineSegment.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.rotation.angle).isEqualTo(HALF_PI) + actualPose.rotation.angle shouldBe HALF_PI } test("angle of diagonal line segment") { @@ -66,11 +64,9 @@ class LineSegment2DTest : FunSpec({ val pointB = Vector2D(1.0, 1.0) val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) - val actualReturn = lineSegment.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO) + val actualPose = lineSegment.calculatePoseGlobalCS(CurveRelativeVector1D.ZERO).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.rotation.angle).isEqualTo(QUARTER_PI) + actualPose.rotation.angle shouldBe QUARTER_PI } } @@ -82,11 +78,9 @@ class LineSegment2DTest : FunSpec({ val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) val curveRelativePoint = CurveRelativeVector1D(5.0) - val actualReturn = lineSegment.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = lineSegment.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point).isEqualTo(Vector2D(5.0, 0.0)) + actualPose.point shouldBe Vector2D(5.0, 0.0) } test("point on diagonal line segment on axis") { @@ -95,12 +89,10 @@ class LineSegment2DTest : FunSpec({ val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) val curveRelativePoint = CurveRelativeVector1D(sqrt(2.0)) - val actualReturn = lineSegment.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = lineSegment.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.point.y).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) + actualPose.point.x.shouldBe(1.0 plusOrMinus DBL_EPSILON) + actualPose.point.y.shouldBe(1.0 plusOrMinus DBL_EPSILON) } test("point on diagonal line segment on axis 2") { @@ -109,11 +101,9 @@ class LineSegment2DTest : FunSpec({ val lineSegment = LineSegment2D.of(pointA, pointB, 0.0) val curveRelativePoint = CurveRelativeVector1D(1.0) - val actualReturn = lineSegment.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = lineSegment.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point).isEqualTo(Vector2D(0.0, 0.0)) + actualPose.point shouldBe 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 6f660258..8d8d7a53 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 @@ -16,8 +16,10 @@ package io.rtron.math.geometry.euclidean.twod.curve -import arrow.core.Either +import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe 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 @@ -27,8 +29,6 @@ import io.rtron.math.std.PI import io.rtron.math.std.QUARTER_PI 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 kotlin.math.sqrt class ParametricCubicCurve2DTest : FunSpec({ @@ -40,11 +40,9 @@ class ParametricCubicCurve2DTest : FunSpec({ val curve = ParametricCubicCurve2D(coefficientX, coefficientY, 10.0, 0.0) val curveRelativePoint = CurveRelativeVector1D(2.0) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point).isEqualTo(Vector2D(2.0, 4.0)) + actualPose.point shouldBe Vector2D(2.0, 4.0) } test("simple linear curve") { @@ -55,12 +53,10 @@ class ParametricCubicCurve2DTest : FunSpec({ val curve = ParametricCubicCurve2D(coefficientX, coefficientY, 10.0, 0.0, affineSequence) val curveRelativePoint = CurveRelativeVector1D(sqrt(2.0)) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.point.y).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) + actualPose.point.x.shouldBe(1.0 plusOrMinus DBL_EPSILON) + actualPose.point.y.shouldBe(1.0 plusOrMinus DBL_EPSILON) } test("simple quadratic negative curve") { @@ -71,12 +67,10 @@ class ParametricCubicCurve2DTest : FunSpec({ val curve = ParametricCubicCurve2D(coefficientX, coefficientY, 10.0, 0.0, affineSequence) val curveRelativePoint = CurveRelativeVector1D(2.0) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(-2.0, Offset.offset(DBL_EPSILON_2)) - assertThat(actualReturn.value.point.y).isCloseTo(-4.0, Offset.offset(DBL_EPSILON_2)) + actualPose.point.x.shouldBe(-2.0 plusOrMinus DBL_EPSILON_2) + actualPose.point.y.shouldBe(-4.0 plusOrMinus DBL_EPSILON_2) } test("quadratic curve") { @@ -86,12 +80,10 @@ class ParametricCubicCurve2DTest : FunSpec({ val curveRelativePoint = CurveRelativeVector1D(length) val curve = ParametricCubicCurve2D(coefficientX, coefficientY, length, 0.0) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(length, Offset.offset(DBL_EPSILON)) - assertThat(actualReturn.value.point.y).isCloseTo(length * length, Offset.offset(DBL_EPSILON)) + actualPose.point.x.shouldBe(length plusOrMinus DBL_EPSILON) + actualPose.point.y.shouldBe(length * length plusOrMinus 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 e26a5af4..ca7de63c 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 @@ -17,6 +17,8 @@ package io.rtron.math.geometry.euclidean.twod.curve import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe import io.rtron.math.geometry.euclidean.twod.Rotation2D import io.rtron.math.geometry.euclidean.twod.point.Vector2D import io.rtron.math.std.DBL_EPSILON @@ -27,8 +29,6 @@ import io.rtron.math.std.PI 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 java.io.FileReader import java.lang.Math.abs import kotlin.io.path.Path @@ -43,7 +43,7 @@ class Spiral2DTest : FunSpec({ val actualPoint = spiral.calculatePoint(0.0) - assertThat(actualPoint).isEqualTo(Vector2D.ZERO) + actualPoint shouldBe Vector2D.ZERO } test("return asymptotic point at l=+infinity") { @@ -52,8 +52,8 @@ class Spiral2DTest : FunSpec({ val actualPoint = spiral.calculatePoint(Double.POSITIVE_INFINITY) - assertThat(actualPoint.x).isCloseTo(asymptoticPoint.x, Offset.offset(DBL_EPSILON_1)) - assertThat(actualPoint.y).isCloseTo(asymptoticPoint.y, Offset.offset(DBL_EPSILON_1)) + actualPoint.x.shouldBe(asymptoticPoint.x plusOrMinus DBL_EPSILON_1) + actualPoint.y.shouldBe(asymptoticPoint.y plusOrMinus DBL_EPSILON_1) } test("return asymptotic point at l=-infinity") { @@ -62,8 +62,8 @@ class Spiral2DTest : FunSpec({ val actualPoint = spiral.calculatePoint(Double.NEGATIVE_INFINITY) - assertThat(actualPoint.x).isCloseTo(asymptoticPoint.x, Offset.offset(DBL_EPSILON_1)) - assertThat(actualPoint.y).isCloseTo(asymptoticPoint.y, Offset.offset(DBL_EPSILON_1)) + actualPoint.x.shouldBe(asymptoticPoint.x plusOrMinus DBL_EPSILON_1) + actualPoint.y.shouldBe(asymptoticPoint.y plusOrMinus DBL_EPSILON_1) } } @@ -74,7 +74,7 @@ class Spiral2DTest : FunSpec({ val actualRotation = spiral.calculateRotation(0.0) - assertThat(actualRotation.toAngleRadians()).isEqualTo(0.0) + actualRotation.toAngleRadians() shouldBe 0.0 } } @@ -106,9 +106,9 @@ class Spiral2DTest : FunSpec({ if (abs(actualPoint.x - x) > DBL_EPSILON_1 || abs(actualPoint.y - y) > DBL_EPSILON_1) { println("test") } - assertThat(actualPoint.x).isCloseTo(x, Offset.offset(DBL_EPSILON_3)) - assertThat(actualPoint.y).isCloseTo(y, Offset.offset(DBL_EPSILON_3)) - assertThat(actualRotation.angle).isCloseTo(Rotation2D(t).angle, Offset.offset(DBL_EPSILON_1)) + actualPoint.x.shouldBe(x plusOrMinus DBL_EPSILON_3) + actualPoint.y.shouldBe(y plusOrMinus DBL_EPSILON_3) + actualRotation.angle.shouldBe(Rotation2D(t).angle plusOrMinus DBL_EPSILON_1) } } @@ -117,8 +117,8 @@ class Spiral2DTest : FunSpec({ val actualPoint = spiral.calculatePoint(-5330.827396000006) - assertThat(actualPoint.x).isCloseTo(-3.401537830619735, Offset.offset(DBL_EPSILON)) - assertThat(actualPoint.y).isCloseTo(3.403385667520832, Offset.offset(DBL_EPSILON)) + actualPoint.x.shouldBe(-3.401537830619735 plusOrMinus DBL_EPSILON) + actualPoint.y.shouldBe(3.403385667520832 plusOrMinus DBL_EPSILON) } test("test rotation calculation against sample value 1") { @@ -126,7 +126,7 @@ class Spiral2DTest : FunSpec({ val actualPoint = spiral.calculateRotation(-5330.827396000006) - assertThat(actualPoint.angle).isCloseTo(Rotation2D(-962991.11906995473).angle, Offset.offset(DBL_EPSILON)) + actualPoint.angle.shouldBe(Rotation2D(-962991.11906995473).angle plusOrMinus DBL_EPSILON) } test("test point calculation against sample value 2") { @@ -134,8 +134,8 @@ class Spiral2DTest : FunSpec({ val actualPoint = spiral.calculatePoint(38679.185313200163) - assertThat(actualPoint.x).isCloseTo(8.1518659286823159, Offset.offset(DBL_EPSILON)) - assertThat(actualPoint.y).isCloseTo(8.1487837011384663, Offset.offset(DBL_EPSILON)) + actualPoint.x.shouldBe(8.1518659286823159 plusOrMinus DBL_EPSILON) + actualPoint.y.shouldBe(8.1487837011384663 plusOrMinus DBL_EPSILON) } test("test rotation calculation against sample value 2") { @@ -143,7 +143,7 @@ class Spiral2DTest : FunSpec({ val actualPoint = spiral.calculateRotation(38679.185313200163) - assertThat(actualPoint.angle).isCloseTo(Rotation2D(8844595.7788996678).angle, Offset.offset(DBL_EPSILON)) + actualPoint.angle.shouldBe(Rotation2D(8844595.7788996678).angle plusOrMinus DBL_EPSILON) } test("test point calculation against sample value 3") { @@ -152,8 +152,8 @@ class Spiral2DTest : FunSpec({ val actualPoint = spiral.calculatePoint(6884.6109795996472) // this higher offset is caused by accumulated floating point errors - assertThat(actualPoint.x).isCloseTo(3.9006399958644153, Offset.offset(DBL_EPSILON_2)) - assertThat(actualPoint.y).isCloseTo(-3.8974453107566154, Offset.offset(DBL_EPSILON_2)) + actualPoint.x.shouldBe(3.9006399958644153 plusOrMinus DBL_EPSILON_2) + actualPoint.y.shouldBe(-3.8974453107566154 plusOrMinus DBL_EPSILON_2) } test("test rotation calculation against sample value 3") { @@ -161,7 +161,7 @@ class Spiral2DTest : FunSpec({ val actualPoint = spiral.calculateRotation(6884.6109795996472) - assertThat(actualPoint.angle).isCloseTo(Rotation2D(-1225084.3271085601).angle, Offset.offset(DBL_EPSILON)) + actualPoint.angle.shouldBe(Rotation2D(-1225084.3271085601).angle plusOrMinus 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 78eda8f5..5d3bb540 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 @@ -16,8 +16,10 @@ package io.rtron.math.geometry.euclidean.twod.curve -import arrow.core.Either +import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe 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 @@ -34,8 +36,6 @@ import io.rtron.math.transform.AffineSequence2D 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 java.io.FileReader import kotlin.io.path.Path import kotlin.io.path.absolute @@ -51,15 +51,13 @@ class SpiralSegment2DTest : FunSpec({ val curve = SpiralSegment2D(curvatureFunction, DBL_EPSILON_2, AffineSequence2D.of(affine)) val curveRelativePoint = CurveRelativeVector1D(1.3000000000000000e+02 - 1.0000000000000000e+02) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(6.5603727689096445e+01, Offset.offset(DBL_EPSILON_11)) - assertThat(actualReturn.value.point.y).isCloseTo(9.8074617455403796e+00, Offset.offset(DBL_EPSILON_11)) - assertThat(actualReturn.value.rotation.angle).isCloseTo( - 5.3186972285460032e-01, - Offset.offset(DBL_EPSILON_4) + actualPose.point.x.shouldBe(6.5603727689096445e+01 plusOrMinus DBL_EPSILON_11) + actualPose.point.y.shouldBe(9.8074617455403796e+00 plusOrMinus DBL_EPSILON_11) + actualPose.rotation.angle.shouldBe( + 5.3186972285460032e-01 + plusOrMinus DBL_EPSILON_4 ) } @@ -70,13 +68,11 @@ class SpiralSegment2DTest : FunSpec({ val curve = SpiralSegment2D(curvatureFunction, DBL_EPSILON_2, AffineSequence2D.of(affine)) val curveRelativePoint = CurveRelativeVector1D(1.7999999146329435e+02 - 1.5999999146329435e+02) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(9.7828942354905308e+01, Offset.offset(DBL_EPSILON_11)) - assertThat(actualReturn.value.point.y).isCloseTo(4.6971187858525226e+01, Offset.offset(DBL_EPSILON_11)) - assertThat(actualReturn.value.rotation.angle).isCloseTo(1.1318693921172343e+00, Offset.offset(DBL_EPSILON_4)) + actualPose.point.x.shouldBe(9.7828942354905308e+01 plusOrMinus DBL_EPSILON_11) + actualPose.point.y.shouldBe(4.6971187858525226e+01 plusOrMinus DBL_EPSILON_11) + actualPose.rotation.angle.shouldBe(1.1318693921172343e+00 plusOrMinus DBL_EPSILON_4) } test("first spiral of the example dataset CrossingComplex8Course") { @@ -86,13 +82,11 @@ class SpiralSegment2DTest : FunSpec({ val curve = SpiralSegment2D(curvatureFunction, DBL_EPSILON_2, AffineSequence2D.of(affine)) val curveRelativePoint = CurveRelativeVector1D(1.0507568316454000e+01 - 5.5455429999983039e+00) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(4.4963740167278593e+02, Offset.offset(DBL_EPSILON_6)) - assertThat(actualReturn.value.point.y).isCloseTo(5.1577803259440122e+02, Offset.offset(DBL_EPSILON_6)) - assertThat(actualReturn.value.rotation.angle).isCloseTo(4.4660983239227257e+00, Offset.offset(DBL_EPSILON_2)) + actualPose.point.x.shouldBe(4.4963740167278593e+02 plusOrMinus DBL_EPSILON_6) + actualPose.point.y.shouldBe(5.1577803259440122e+02 plusOrMinus DBL_EPSILON_6) + actualPose.rotation.angle.shouldBe(4.4660983239227257e+00 plusOrMinus DBL_EPSILON_2) } test("second spiral of the example dataset CrossingComplex8Course") { @@ -102,13 +96,11 @@ class SpiralSegment2DTest : FunSpec({ val curve = SpiralSegment2D(curvatureFunction, DBL_EPSILON_2, AffineSequence2D.of(affine)) val curveRelativePoint = CurveRelativeVector1D(2.6019182043553606e+01 - 2.1057156727097912e+01) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(4.3763402923360974e+02, Offset.offset(DBL_EPSILON_6)) - assertThat(actualReturn.value.point.y).isCloseTo(5.0819484814787387e+02, Offset.offset(DBL_EPSILON_6)) - assertThat(actualReturn.value.rotation.angle).isCloseTo(3.1465437853028004e+00, Offset.offset(DBL_EPSILON_2)) + actualPose.point.x.shouldBe(4.3763402923360974e+02 plusOrMinus DBL_EPSILON_6) + actualPose.point.y.shouldBe(5.0819484814787387e+02 plusOrMinus DBL_EPSILON_6) + actualPose.rotation.angle.shouldBe(3.1465437853028004e+00 plusOrMinus DBL_EPSILON_2) } } @@ -132,13 +124,11 @@ class SpiralSegment2DTest : FunSpec({ val curve = SpiralSegment2D(curvatureFunction, DBL_EPSILON_5, AffineSequence2D.of(affine)) val curveRelativePoint = CurveRelativeVector1D(record.get("s1").toDouble() - record.get("s0").toDouble()) - val actualReturn = curve.calculatePoseGlobalCS(curveRelativePoint) + val actualPose = curve.calculatePoseGlobalCS(curveRelativePoint).shouldBeRight() - assertThat(actualReturn).isInstanceOf(Either.Right::class.java) - require(actualReturn is Either.Right) - assertThat(actualReturn.value.point.x).isCloseTo(record.get("x1").toDouble(), Offset.offset(DBL_EPSILON_8)) - assertThat(actualReturn.value.point.y).isCloseTo(record.get("y1").toDouble(), Offset.offset(DBL_EPSILON_8)) - assertThat(actualReturn.value.rotation.angle).isCloseTo(Rotation2D(record.get("hdg1").toDouble()).angle, Offset.offset(DBL_EPSILON_6)) + actualPose.point.x.shouldBe(record.get("x1").toDouble() plusOrMinus DBL_EPSILON_8) + actualPose.point.y.shouldBe(record.get("y1").toDouble() plusOrMinus DBL_EPSILON_8) + actualPose.rotation.angle.shouldBe(Rotation2D(record.get("hdg1").toDouble()).angle plusOrMinus DBL_EPSILON_6) } } } 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 050f6b6c..13c7ea5f 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 @@ -17,9 +17,9 @@ package io.rtron.math.geometry.euclidean.twod.point import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe import io.rtron.math.std.HALF_PI import io.rtron.math.std.PI -import org.assertj.core.api.Assertions.assertThat import kotlin.math.sqrt class Vector2DTest : FunSpec({ @@ -27,7 +27,7 @@ class Vector2DTest : FunSpec({ fun scalarMultiply() { val actualValue = Vector2D(1.0, 1.0).scalarMultiply(4.0) - assertThat(actualValue).isEqualTo(Vector2D(4.0, 4.0)) + actualValue shouldBe Vector2D(4.0, 4.0) } context("TestDistanceCalculation") { @@ -38,7 +38,7 @@ class Vector2DTest : FunSpec({ val actualDistance = pointA.distance(pointB) - assertThat(actualDistance).isEqualTo(3.0) + actualDistance shouldBe 3.0 } test("uneven value distance between two point") { @@ -47,7 +47,7 @@ class Vector2DTest : FunSpec({ val actualDistance = pointA.distance(pointB) - assertThat(actualDistance).isEqualTo(sqrt(2.0)) + actualDistance shouldBe sqrt(2.0) } } @@ -59,7 +59,7 @@ class Vector2DTest : FunSpec({ val actualAngle = pointA.angle(pointB).toAngleRadians() - assertThat(actualAngle).isEqualTo(HALF_PI) + actualAngle shouldBe HALF_PI } test("uneven radians angle") { @@ -68,7 +68,7 @@ class Vector2DTest : FunSpec({ val actualAngle = pointA.angle(pointB).toAngleRadians() - assertThat(actualAngle).isEqualTo(1.75 * PI) + actualAngle shouldBe 1.75 * PI } test("-half pi degree angle axes") { @@ -77,7 +77,7 @@ class Vector2DTest : FunSpec({ val actualAngle = pointA.angle(pointB).toAngleRadians() - assertThat(actualAngle).isEqualTo(1.5 * PI) + actualAngle shouldBe 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 33e35b38..f63926cb 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 @@ -19,8 +19,9 @@ 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.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.assertThat class Polygon2DTest : FunSpec({ context("TestContainsCalculation") { @@ -31,7 +32,7 @@ class Polygon2DTest : FunSpec({ val actualReturn = polygon.contains(Vector2D(0.25, 0.25)) - assertThat(actualReturn).isTrue + actualReturn.shouldBeTrue() } test("basic triangle does not contain point") { @@ -44,7 +45,7 @@ class Polygon2DTest : FunSpec({ val actualReturn = polygon.contains(Vector2D(1.25, 1.25)) - assertThat(actualReturn).isFalse + actualReturn.shouldBeFalse() } test("concave polygon does contain point") { @@ -59,7 +60,7 @@ class Polygon2DTest : FunSpec({ val actualReturn = polygon.contains(Vector2D(1.0, 1.1)) - assertThat(actualReturn).isTrue + actualReturn.shouldBeTrue() } } }) 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 a5590c40..364389a8 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 @@ -17,7 +17,7 @@ package io.rtron.math.linear import io.kotest.core.spec.style.FunSpec -import org.assertj.core.api.Assertions.assertThat +import io.kotest.matchers.shouldBe class MatrixUtilsTest : FunSpec({ context("TestAppendColumn") { @@ -29,8 +29,8 @@ class MatrixUtilsTest : FunSpec({ val actualAppendedMatrix = matrix.appendColumn(column) - assertThat(actualAppendedMatrix.getRow(0)).isEqualTo(doubleArrayOf(1.0, 0.0, 2.0)) - assertThat(actualAppendedMatrix.getRow(1)).isEqualTo(doubleArrayOf(0.0, 4.0, 1.0)) + actualAppendedMatrix.getRow(0) shouldBe doubleArrayOf(1.0, 0.0, 2.0) + actualAppendedMatrix.getRow(1) shouldBe 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 c1440bf2..20a05378 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 @@ -16,23 +16,23 @@ package io.rtron.math.linear +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe import io.rtron.math.std.DBL_EPSILON -import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.data.Offset class RealMatrixTest { fun normalize() { val matrixValues = arrayOf(doubleArrayOf(1.0, 0.0), doubleArrayOf(0.0, 4.0)) val matrix = RealMatrix(matrixValues) - val toleratedOffset = Offset.offset(DBL_EPSILON) + val toleratedOffset = DBL_EPSILON val actualMatrix = matrix .normalize(matrix.rowDimension - 1, matrix.columnDimension - 1) - assertThat(actualMatrix[0][0]).isCloseTo(0.25, toleratedOffset) - assertThat(actualMatrix[0][1]).isCloseTo(0.0, toleratedOffset) - assertThat(actualMatrix[1][0]).isCloseTo(0.0, toleratedOffset) - assertThat(actualMatrix[1][1]).isCloseTo(1.0, toleratedOffset) + actualMatrix[0][0].shouldBe(0.25 plusOrMinus toleratedOffset) + actualMatrix[0][1].shouldBe(0.0 plusOrMinus toleratedOffset) + actualMatrix[1][0].shouldBe(0.0 plusOrMinus toleratedOffset) + actualMatrix[1][1].shouldBe(1.0 plusOrMinus toleratedOffset) } } 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 9ea048c5..97effc2a 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 @@ -17,7 +17,7 @@ package io.rtron.math.linear import io.kotest.core.spec.style.FunSpec -import org.assertj.core.api.Assertions.assertThat +import io.kotest.matchers.shouldBe class RealVectorUtilsTest : FunSpec({ context("TestDimensionOfSpan") { @@ -30,7 +30,7 @@ class RealVectorUtilsTest : FunSpec({ val actualSpan = rowVectors.dimensionOfSpan() - assertThat(actualSpan).isEqualTo(2) + actualSpan shouldBe 2 } test("four linearly independent vectors should have a span's dimension of 4") { @@ -42,7 +42,7 @@ class RealVectorUtilsTest : FunSpec({ val actualSpan = rowVectors.dimensionOfSpan() - assertThat(actualSpan).isEqualTo(4) + actualSpan shouldBe 4 } test("no vector should have a span's dimension of 0") { @@ -50,7 +50,7 @@ class RealVectorUtilsTest : FunSpec({ val actualSpan = rowVectors.dimensionOfSpan() - assertThat(actualSpan).isEqualTo(0) + actualSpan shouldBe 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 75252b57..0a6042a2 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 @@ -17,8 +17,8 @@ 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 io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe class SingularValueDecompositionTest : FunSpec({ context("TestRank") { @@ -30,7 +30,7 @@ class SingularValueDecompositionTest : FunSpec({ val actualRank = singularValueDecomposition.rank - assertThat(actualRank).isEqualTo(2) + actualRank shouldBe 2 } test("matrix with two colinear vectors should have rank 1") { @@ -40,7 +40,7 @@ class SingularValueDecompositionTest : FunSpec({ val actualRank = singularValueDecomposition.rank - assertThat(actualRank).isEqualTo(1) + actualRank shouldBe 1 } test("matrix of two zero vectors should have rank 0") { @@ -50,7 +50,7 @@ class SingularValueDecompositionTest : FunSpec({ val actualRank = singularValueDecomposition.rank - assertThat(actualRank).isEqualTo(0) + actualRank shouldBe 0 } } @@ -64,9 +64,9 @@ class SingularValueDecompositionTest : FunSpec({ val actualMatrixU = singularValueDecomposition.matrixU - assertThat(actualMatrixU.dimension).isEqualTo(expectedMatrixU.dimension) - assertThat(actualMatrixU.entriesFlattened) - .containsExactly(expectedMatrixU.entriesFlattened, Offset.offset(0.01)) + actualMatrixU.dimension shouldBe expectedMatrixU.dimension + actualMatrixU.entriesFlattened.zip(expectedMatrixU.entriesFlattened) + .forEach { it.first.shouldBe(it.second plusOrMinus 0.01) } } } @@ -80,9 +80,9 @@ class SingularValueDecompositionTest : FunSpec({ val actualMatrixS = singularValueDecomposition.matrixS - assertThat(actualMatrixS.dimension).isEqualTo(expectedMatrixS.dimension) - assertThat(actualMatrixS.entriesFlattened) - .containsExactly(expectedMatrixS.entriesFlattened, Offset.offset(0.01)) + actualMatrixS.dimension shouldBe expectedMatrixS.dimension + actualMatrixS.entriesFlattened.zip(expectedMatrixS.entriesFlattened) + .forEach { it.first.shouldBe(it.second plusOrMinus 0.01) } } } @@ -96,9 +96,9 @@ class SingularValueDecompositionTest : FunSpec({ val actualMatrixVT = singularValueDecomposition.matrixVT - assertThat(actualMatrixVT.dimension).isEqualTo(expectedMatrixV.dimension) - assertThat(actualMatrixVT.entriesFlattened) - .containsExactly(expectedMatrixV.entriesFlattened, Offset.offset(0.01)) + actualMatrixVT.dimension shouldBe expectedMatrixV.dimension + actualMatrixVT.entriesFlattened.zip(expectedMatrixV.entriesFlattened) + .forEach { it.first.shouldBe(it.second plusOrMinus 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 2c022174..13b3c581 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 @@ -18,12 +18,12 @@ package io.rtron.math.processing import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.booleans.shouldBeTrue +import io.kotest.matchers.doubles.plusOrMinus +import io.kotest.matchers.shouldBe 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 class Plane3DUtilTest : FunSpec({ context("TestBestFittingPlaneCalculation") { @@ -36,7 +36,7 @@ class Plane3DUtilTest : FunSpec({ val actualBestFittingPlane = listOf(pointA, pointB, pointC).calculateBestFittingPlane(DBL_EPSILON_1) - assertThat(actualBestFittingPlane.normal).isEqualTo(expectedNormal) + actualBestFittingPlane.normal shouldBe expectedNormal } test("normal for counter clockwise point in XY-plane") { @@ -47,7 +47,7 @@ class Plane3DUtilTest : FunSpec({ val actualBestFittingPlane = listOf(pointA, pointB, pointC).calculateBestFittingPlane(DBL_EPSILON_1) - assertThat(actualBestFittingPlane.normal).isEqualTo(expectedNormal) + actualBestFittingPlane.normal shouldBe expectedNormal } test("plane fitting with three points") { @@ -60,7 +60,7 @@ class Plane3DUtilTest : FunSpec({ val actualBestFittingPlane = listOf(pointA, pointB, pointC).calculateBestFittingPlane(DBL_EPSILON_1) - assertThat(actualBestFittingPlane).isEqualTo(expectedPlane) + actualBestFittingPlane shouldBe expectedPlane } test("plane fitting with multiple points") { @@ -75,8 +75,9 @@ class Plane3DUtilTest : FunSpec({ val actualBestFittingPlane = listOf(pointA, pointB, pointC, pointD) .calculateBestFittingPlane(DBL_EPSILON_2) - assertThat(actualBestFittingPlane.normal.toDoubleArray()) - .containsExactly(expectedPlane.normal.toDoubleArray(), Offset.offset(DBL_EPSILON_2)) + actualBestFittingPlane.normal.toDoubleArray().zip(expectedPlane.normal.toDoubleArray()).forEach { + it.first.shouldBe(it.second plusOrMinus DBL_EPSILON_2) + } actualBestFittingPlane.isSimilarTo(expectedPlane).shouldBeTrue() } @@ -92,7 +93,7 @@ class Plane3DUtilTest : FunSpec({ val actualBestFittingPlane = listOf(pointA, pointB, pointC, pointD, pointE) .calculateBestFittingPlane(DBL_EPSILON_1) - assertThat(actualBestFittingPlane).isEqualTo(expectedPlane) + actualBestFittingPlane shouldBe 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 acacbdc0..ca38d832 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,10 +1,10 @@ package io.rtron.math.processing +import io.kotest.assertions.throwables.shouldThrow 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 class Vector2DListExtensionsTest : FunSpec({ context("TestVectorsAreClockwiseOrdered") { @@ -49,7 +49,7 @@ class Vector2DListExtensionsTest : FunSpec({ val pointB = Vector2D.Y_AXIS val vertices = listOf(pointA, pointB) - Assertions.assertThatIllegalArgumentException().isThrownBy { + shouldThrow { vertices.isClockwiseOrdered() } } 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 880d449c..0157bad8 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 @@ -19,9 +19,9 @@ 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.kotest.matchers.shouldBe import io.rtron.math.geometry.euclidean.threed.point.Vector3D import io.rtron.math.std.DBL_EPSILON_1 -import org.assertj.core.api.Assertions.assertThat class Vector3DListExtensionsTest : FunSpec({ context("TestTripleIsColinear") { @@ -65,7 +65,7 @@ class Vector3DListExtensionsTest : FunSpec({ val actualResultingVertices = vertices.removeRedundantVerticesOnLineSegmentsEnclosing(DBL_EPSILON_1) - assertThat(actualResultingVertices).isEqualTo(expectedVertices) + actualResultingVertices shouldBe expectedVertices } test("two different point should yield the exact points") { @@ -76,7 +76,7 @@ class Vector3DListExtensionsTest : FunSpec({ val actualResultingVertices = vertices.removeRedundantVerticesOnLineSegmentsEnclosing(DBL_EPSILON_1) - assertThat(actualResultingVertices).isEqualTo(expectedVertices) + actualResultingVertices shouldBe expectedVertices } test("two equal points should yield only one point") { @@ -87,7 +87,7 @@ class Vector3DListExtensionsTest : FunSpec({ val actualResultingVertices = vertices.removeRedundantVerticesOnLineSegmentsEnclosing(DBL_EPSILON_1) - assertThat(actualResultingVertices).isEqualTo(expectedVertices) + actualResultingVertices shouldBe expectedVertices } test("three points of pattern ABB") { @@ -99,7 +99,7 @@ class Vector3DListExtensionsTest : FunSpec({ val actualResultingVertices = vertices.removeRedundantVerticesOnLineSegmentsEnclosing(DBL_EPSILON_1) - assertThat(actualResultingVertices).isEqualTo(expectedVertices) + actualResultingVertices shouldBe expectedVertices } test("basic four points") { @@ -112,7 +112,7 @@ class Vector3DListExtensionsTest : FunSpec({ val actualResultingVertices = vertices.removeRedundantVerticesOnLineSegmentsEnclosing(DBL_EPSILON_1) - assertThat(actualResultingVertices).isEqualTo(expectedVertices) + actualResultingVertices shouldBe expectedVertices } test("four points of pattern ABBA") { @@ -125,7 +125,7 @@ class Vector3DListExtensionsTest : FunSpec({ val actualResultingVertices = vertices.removeRedundantVerticesOnLineSegmentsEnclosing(DBL_EPSILON_1) - assertThat(actualResultingVertices).isEqualTo(expectedVertices) + actualResultingVertices shouldBe expectedVertices } test("five points of pattern ABBBA") { @@ -139,7 +139,7 @@ class Vector3DListExtensionsTest : FunSpec({ val actualResultingVertices = vertices.removeRedundantVerticesOnLineSegmentsEnclosing(DBL_EPSILON_1) - assertThat(actualResultingVertices).isEqualTo(expectedVertices) + actualResultingVertices shouldBe expectedVertices } } @@ -202,7 +202,7 @@ class Vector3DListExtensionsTest : FunSpec({ val actualCentroid = listOf(pointA, pointB, pointC).calculateCentroid() - assertThat(actualCentroid).isEqualTo(expectedCentroid) + actualCentroid shouldBe expectedCentroid } test("centroid of multiple points") { @@ -215,7 +215,7 @@ class Vector3DListExtensionsTest : FunSpec({ val actualCentroid = points.calculateCentroid() - assertThat(actualCentroid).isEqualTo(expectedCentroid) + actualCentroid shouldBe 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 8edc3d4c..99cd837d 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 @@ -18,7 +18,7 @@ package io.rtron.math.projection import arrow.core.Either import io.kotest.core.spec.style.FunSpec -import org.assertj.core.api.Assertions.assertThat +import io.kotest.matchers.shouldBe class CoordinateReferenceSystemTest : FunSpec({ @@ -30,7 +30,7 @@ class CoordinateReferenceSystemTest : FunSpec({ val actualCrsResult = CoordinateReferenceSystem.of(crsName) require(actualCrsResult is Either.Right) - assertThat(actualCrsResult.value.name).isEqualTo(crsName) + actualCrsResult.value.name shouldBe crsName } test("build crs 32632 from epsg name") { @@ -39,7 +39,7 @@ class CoordinateReferenceSystemTest : FunSpec({ val actualCrsResult = CoordinateReferenceSystem.of(crsName) require(actualCrsResult is Either.Right) - assertThat(actualCrsResult.value.name).isEqualTo(crsName) + actualCrsResult.value.name shouldBe crsName } test("extract epsg code 4326") { @@ -48,7 +48,7 @@ class CoordinateReferenceSystemTest : FunSpec({ val actualCrsResult = CoordinateReferenceSystem.of(crsName) require(actualCrsResult is Either.Right) - assertThat(actualCrsResult.value.epsgCode).isEqualTo(4326) + actualCrsResult.value.epsgCode shouldBe 4326 } test("extract epsg code 32632") { @@ -57,7 +57,7 @@ class CoordinateReferenceSystemTest : FunSpec({ val actualCrsResult = CoordinateReferenceSystem.of(crsName) require(actualCrsResult is Either.Right) - assertThat(actualCrsResult.value.epsgCode).isEqualTo(32632) + actualCrsResult.value.epsgCode shouldBe 32632 } test("build crs 32632 from parameters") { @@ -66,7 +66,7 @@ class CoordinateReferenceSystemTest : FunSpec({ val actualCrsResult = CoordinateReferenceSystem.ofParameters(parameters) require(actualCrsResult is Either.Right) - assertThat(actualCrsResult.value.epsgCode).isEqualTo(32632) + actualCrsResult.value.epsgCode shouldBe 32632 } test("build crs 4326 from parameters") { @@ -75,7 +75,7 @@ class CoordinateReferenceSystemTest : FunSpec({ val actualCrsResult = CoordinateReferenceSystem.ofParameters(parameters) require(actualCrsResult is Either.Right) - assertThat(actualCrsResult.value.epsgCode).isEqualTo(4326) + actualCrsResult.value.epsgCode shouldBe 4326 } } }) 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 29c7bf8f..c7960921 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,9 +16,9 @@ package io.rtron.math.range +import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec -import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatIllegalArgumentException +import io.kotest.matchers.collections.shouldHaveSize class DoubleRangeSetExtensionsTest : FunSpec({ context("TestCreation") { @@ -27,7 +27,7 @@ class DoubleRangeSetExtensionsTest : FunSpec({ val rangeA = Range.closed(0.0, 2.0) val rangeB = Range.closed(1.0, 4.0) - assertThatIllegalArgumentException().isThrownBy { + shouldThrow { RangeSet.ofNonIntersectingRanges(rangeA, rangeB) } } @@ -38,7 +38,7 @@ class DoubleRangeSetExtensionsTest : FunSpec({ val actualRangeSet = RangeSet.ofNonIntersectingRanges(rangeA, rangeB) - assertThat(actualRangeSet.asRanges()).hasSize(1) + actualRangeSet.asRanges() shouldHaveSize 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 b5d2ac2b..985f554a 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 @@ -19,7 +19,8 @@ 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 io.kotest.matchers.collections.shouldContainExactly +import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder class RangeSetTest : FunSpec({ @@ -45,8 +46,7 @@ class RangeSetTest : FunSpec({ val actualUnion = rangeSetA.union(rangeSetB) - assertThat(actualUnion.asRanges()) - .containsExactlyInAnyOrder(rangeA, rangeB) + actualUnion.asRanges().shouldContainExactlyInAnyOrder(rangeA, rangeB) } test("simple union of two connected range sets") { @@ -58,7 +58,7 @@ class RangeSetTest : FunSpec({ val actualUnion = rangeSetA.union(rangeSetB) - assertThat(actualUnion.asRanges()).containsOnly(expectedRange) + actualUnion.asRanges().shouldContainExactly(expectedRange) } } 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 6f60a028..6983ff2c 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,13 +16,13 @@ package io.rtron.math.range +import io.kotest.assertions.throwables.shouldThrow 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.kotest.matchers.shouldBe import io.rtron.math.std.DBL_EPSILON -import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatIllegalArgumentException class RangeTest : FunSpec({ context("UpperLowerEndpoint") { @@ -126,7 +126,7 @@ class RangeTest : FunSpec({ context("TestConstruction") { test("negative orientation of the range throws an illegal argument exception") { - assertThatIllegalArgumentException().isThrownBy { Range.closed(-1.0, -1.25) } + shouldThrow { Range.closed(-1.0, -1.25) } } } @@ -165,7 +165,7 @@ class RangeTest : FunSpec({ val actualJoin = rangeA.join(rangeB) - assertThat(actualJoin).isEqualTo(Range.closed(0.0, 2.0)) + actualJoin shouldBe Range.closed(0.0, 2.0) } test("Connected joins with negative values") { @@ -174,14 +174,14 @@ class RangeTest : FunSpec({ val actualJoin = rangeA.join(rangeB) - assertThat(actualJoin).isEqualTo(Range.closed(-1.0, -0.2)) + actualJoin shouldBe Range.closed(-1.0, -0.2) } 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) } + shouldThrow { 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 1e1891be..a1771829 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,9 +16,9 @@ package io.rtron.math.std +import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe -import org.assertj.core.api.Assertions.assertThatIllegalArgumentException class DoubleArrayExtensionTest : FunSpec({ @@ -49,7 +49,7 @@ class DoubleArrayExtensionTest : FunSpec({ test("test fail for wrong dimension") { val values = doubleArrayOf(2.0, 1.0, 2.0, 1.0) - assertThatIllegalArgumentException().isThrownBy { values.reshapeByRowDimension(5) } + shouldThrow { values.reshapeByRowDimension(5) } } test("test reshape of square matrix") { 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 2f8fd574..4fb58498 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 @@ -25,8 +25,6 @@ import io.rtron.math.linear.RealMatrix import io.rtron.math.linear.RealVector 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 kotlin.math.cos import kotlin.math.sin import org.joml.Matrix4d as JOMLMatrix4d @@ -165,9 +163,9 @@ class Affine3DTest : FunSpec({ val actualRotated = affine.transform(Vector3D.X_AXIS) - assertThat(actualRotated.x).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) - assertThat(actualRotated.y).isCloseTo(1.0, Offset.offset(DBL_EPSILON)) - assertThat(actualRotated.z).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) + actualRotated.x.shouldBe(0.0 plusOrMinus DBL_EPSILON) + actualRotated.y.shouldBe(1.0 plusOrMinus DBL_EPSILON) + actualRotated.z.shouldBe(0.0 plusOrMinus DBL_EPSILON) } test("test pitch rotation") { @@ -176,9 +174,9 @@ class Affine3DTest : FunSpec({ val actualRotated = affine.transform(Vector3D.X_AXIS) - assertThat(actualRotated.x).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) - assertThat(actualRotated.y).isCloseTo(0.0, Offset.offset(DBL_EPSILON)) - assertThat(actualRotated.z).isCloseTo(-1.0, Offset.offset(DBL_EPSILON)) + actualRotated.x.shouldBe(0.0 plusOrMinus DBL_EPSILON) + actualRotated.y.shouldBe(0.0 plusOrMinus DBL_EPSILON) + actualRotated.z.shouldBe(-1.0 plusOrMinus DBL_EPSILON) } test("test rotation based on new standard basis") { @@ -190,9 +188,9 @@ class Affine3DTest : FunSpec({ val actualRotated = affine.transform(Vector3D.X_AXIS) - assertThat(actualRotated.x).isCloseTo(expected.x, Offset.offset(DBL_EPSILON)) - assertThat(actualRotated.y).isCloseTo(expected.y, Offset.offset(DBL_EPSILON)) - assertThat(actualRotated.z).isCloseTo(expected.z, Offset.offset(DBL_EPSILON)) + actualRotated.x.shouldBe(expected.x plusOrMinus DBL_EPSILON) + actualRotated.y.shouldBe(expected.y plusOrMinus DBL_EPSILON) + actualRotated.z.shouldBe(expected.z plusOrMinus DBL_EPSILON) } } 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 49a4a593..a5f55746 100644 --- a/rtron-std/src/test/kotlin/io/rtron/std/CollectionsKtTest.kt +++ b/rtron-std/src/test/kotlin/io/rtron/std/CollectionsKtTest.kt @@ -17,7 +17,7 @@ package io.rtron.std import io.kotest.core.spec.style.FunSpec -import org.assertj.core.api.Assertions.assertThat +import io.kotest.matchers.shouldBe class CollectionsKtTest : FunSpec({ context("TestDistinctConsecutive") { @@ -27,7 +27,7 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "a", "b", "c").distinctConsecutiveBy { it } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test basic list with same enclosing pair") { @@ -35,19 +35,19 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "a", "b", "c", "a").distinctConsecutiveBy { it } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test empty list") { val actualValues = emptyList().distinctConsecutiveBy { it } - assertThat(actualValues).isEqualTo(emptyList()) + actualValues shouldBe emptyList() } test("test list with a single element") { val actualValues = listOf("a").distinctConsecutiveBy { it } - assertThat(actualValues).isEqualTo(listOf("a")) + actualValues shouldBe listOf("a") } } @@ -58,7 +58,7 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "a", "b", "c").distinctConsecutiveEnclosingBy { it } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test basic list with same enclosing pair") { @@ -66,7 +66,7 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "a", "b", "c", "a").distinctConsecutiveEnclosingBy { it } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test removal of multiple consecutive objects") { @@ -74,19 +74,19 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "b", "b", "b", "c").distinctConsecutiveEnclosingBy { it } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test empty list") { val actualValues = emptyList().distinctConsecutiveEnclosingBy { it } - assertThat(actualValues).isEqualTo(emptyList()) + actualValues shouldBe emptyList() } test("test list with a single element") { val actualValues = listOf("a").distinctConsecutiveEnclosingBy { it } - assertThat(actualValues).isEqualTo(listOf("a")) + actualValues shouldBe listOf("a") } } @@ -97,7 +97,7 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf(1, 1, 2, 3).filterToSorting { first, second -> first < second } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test unsorted list") { @@ -105,19 +105,19 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf(3, 1, 2, 4, 12, 5, 3).filterToSorting { first, second -> first < second } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test empty list") { val actualValues = emptyList().filterToSorting { first, second -> first < second } - assertThat(actualValues).isEqualTo(emptyList()) + actualValues shouldBe emptyList() } test("test list with a single element") { val actualValues = listOf("a").filterToSorting { first, second -> first < second } - assertThat(actualValues).isEqualTo(listOf("a")) + actualValues shouldBe listOf("a") } } @@ -134,7 +134,7 @@ class CollectionsKtTest : FunSpec({ val actualSequence = baseSequence.windowedEnclosing(3) - assertThat(actualSequence.toList()).isEqualTo(expectedSequence.toList()) + actualSequence.toList() shouldBe expectedSequence.toList() } test("test basic enclosed windowing of integer sequence") { @@ -150,7 +150,7 @@ class CollectionsKtTest : FunSpec({ val actualValues = baseSequence.windowedEnclosing(3) - assertThat(actualValues.toList()).isEqualTo(expectedSequence.toList()) + actualValues.toList() shouldBe expectedSequence.toList() } } @@ -161,7 +161,7 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "a", "b", "c").filterWithNext { a, b -> a != b } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test basic list with same enclosing pair") { @@ -169,7 +169,7 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "a", "b", "c", "a").filterWithNext { a, b -> a != b } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test list with three consecutively following duplicates") { @@ -177,19 +177,19 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "a", "a", "b", "b", "c", "a").filterWithNext { a, b -> a != b } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test empty list") { val actualValues = emptyList().filterWithNext { a, b -> a != b } - assertThat(actualValues).isEqualTo(emptyList()) + actualValues shouldBe emptyList() } test("test list with a single element") { val actualValues = listOf("a").filterWithNext { a, b -> a != b } - assertThat(actualValues).isEqualTo(listOf("a")) + actualValues shouldBe listOf("a") } } @@ -200,7 +200,7 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "a", "b", "c").filterWithNextEnclosing { a, b -> a != b } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test basic list with same enclosing pair") { @@ -208,7 +208,7 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "a", "b", "c", "a").filterWithNextEnclosing { a, b -> a != b } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test removal of multiple consecutive objects") { @@ -216,19 +216,19 @@ class CollectionsKtTest : FunSpec({ val actualValues = listOf("a", "b", "b", "b", "c").filterWithNextEnclosing { a, b -> a != b } - assertThat(actualValues).isEqualTo(expectedValues) + actualValues shouldBe expectedValues } test("test empty list") { val actualValues = emptyList().filterWithNextEnclosing { a, b -> a != b } - assertThat(actualValues).isEqualTo(emptyList()) + actualValues shouldBe emptyList() } test("test list with a single element") { val actualValues = listOf("a").filterWithNextEnclosing { a, b -> a != b } - assertThat(actualValues).isEqualTo(listOf("a")) + actualValues shouldBe listOf("a") } } }) 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 8c31de71..da46ebe4 100644 --- a/rtron-std/src/test/kotlin/io/rtron/std/ListsKtTest.kt +++ b/rtron-std/src/test/kotlin/io/rtron/std/ListsKtTest.kt @@ -16,9 +16,9 @@ package io.rtron.std +import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec -import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatIllegalArgumentException +import io.kotest.matchers.shouldBe class ListsKtTest : FunSpec({ context("TestMoveWindow") { @@ -34,14 +34,14 @@ class ListsKtTest : FunSpec({ { a, b -> a || b } ) - assertThat(actualList).isEqualTo(expectedList) + actualList shouldBe expectedList } test("fail if base list is empty") { val listA = listOf() val listB = listOf(true, false) - assertThatIllegalArgumentException().isThrownBy { + shouldThrow { listA.moveWindow( listB, { baseElement, otherElement -> baseElement && otherElement }, @@ -54,7 +54,7 @@ class ListsKtTest : FunSpec({ val listA = listOf(true, false) val listB = listOf() - assertThatIllegalArgumentException().isThrownBy { + shouldThrow { listA.moveWindow( listB, { baseElement, otherElement -> baseElement && otherElement }, @@ -75,7 +75,7 @@ class ListsKtTest : FunSpec({ shape = MovingWindowShape.SAME ) - assertThat(actualList).isEqualTo(expectedList) + actualList shouldBe expectedList } test("moving window with doubles") { @@ -89,7 +89,7 @@ class ListsKtTest : FunSpec({ { a, b -> a + b } ) - assertThat(actualList).isEqualTo(expectedList) + actualList shouldBe expectedList } } @@ -102,7 +102,7 @@ class ListsKtTest : FunSpec({ val actualList = listA.moveWindow(listB, shape = MovingWindowShape.SAME) - assertThat(actualList).isEqualTo(expectedList) + actualList shouldBe expectedList } } @@ -111,7 +111,7 @@ class ListsKtTest : FunSpec({ test("fail if requested sublist size is greater than list size") { val mainList = listOf("a", "a", "a", "b", "c", "c") - assertThatIllegalArgumentException().isThrownBy { + shouldThrow { mainList.filterWindowedEnclosing(7) { it[0] == it[1] } } } @@ -122,7 +122,7 @@ class ListsKtTest : FunSpec({ val actualList = mainList.filterWindowedEnclosing(3) { it[0] == 3 && it[1] == 4 && it[2] == 4 } - assertThat(actualList).isEqualTo(expectedList) + actualList shouldBe expectedList } test("sublist pattern filter with drop indices on characters") { @@ -132,7 +132,7 @@ class ListsKtTest : FunSpec({ val actualList = mainList.filterWindowedEnclosing(dropIndices) { it[0] == it[2] } - assertThat(actualList).isEqualTo(expectedList) + actualList shouldBe expectedList } test("test removal of consecutive duplicates") { @@ -142,7 +142,7 @@ class ListsKtTest : FunSpec({ val actualList = mainList.filterWindowedEnclosing(dropIndices) { it[0] == it[1] } - assertThat(actualList).isEqualTo(expectedList) + actualList shouldBe expectedList } test("test removal of consecutive and enclosing duplicates by dropping the first window indices") { @@ -152,7 +152,7 @@ class ListsKtTest : FunSpec({ val actualList = mainList.filterWindowedEnclosing(dropIndices) { it[0] == it[1] } - assertThat(actualList).isEqualTo(expectedList) + actualList shouldBe expectedList } test("test removal of consecutive and enclosing duplicates by dropping the second window indices") { @@ -162,7 +162,7 @@ class ListsKtTest : FunSpec({ val actualList = mainList.filterWindowedEnclosing(dropIndices) { it[0] == it[1] } - assertThat(actualList).isEqualTo(expectedList) + actualList shouldBe 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 5ef72adc..f504b3c4 100644 --- a/rtron-std/src/test/kotlin/io/rtron/std/SequencesKtTest.kt +++ b/rtron-std/src/test/kotlin/io/rtron/std/SequencesKtTest.kt @@ -17,7 +17,7 @@ package io.rtron.std import io.kotest.core.spec.style.FunSpec -import org.assertj.core.api.Assertions.assertThat +import io.kotest.matchers.shouldBe class SequencesKtTest : FunSpec({ context("TestZipWithNextEnclosing") { @@ -27,19 +27,19 @@ class SequencesKtTest : FunSpec({ val actualZips = listOf("a", "b", "c").zipWithNextEnclosing() - assertThat(actualZips).isEqualTo(expectedZips) + actualZips shouldBe expectedZips } test("empty list should return an empty list") { val actualZips = emptyList().zipWithNextEnclosing() - assertThat(actualZips).isEqualTo(emptyList()) + actualZips shouldBe emptyList() } test("list with a single element should return an empty list") { val actualZips = listOf("a").zipWithNextEnclosing() - assertThat(actualZips).isEqualTo(emptyList()) + actualZips shouldBe emptyList() } } @@ -50,7 +50,7 @@ class SequencesKtTest : FunSpec({ val actual = listOf("a", "a", "a", "b", "c", "c").zipWithConsecutives { it } - assertThat(actual).isEqualTo(expected) + actual shouldBe expected } test("test basic sequence with same enclosing pair") { @@ -58,19 +58,19 @@ class SequencesKtTest : FunSpec({ val actual = listOf("a", "a", "a", "b", "c", "c", "a").zipWithConsecutives { it } - assertThat(actual).isEqualTo(expected) + actual shouldBe expected } test("empty list should return an empty list") { val actualZips = emptyList().zipWithConsecutives { it } - assertThat(actualZips).isEqualTo(emptyList()) + actualZips shouldBe emptyList() } test("test single element") { val actualZips = listOf("a").zipWithConsecutives { it } - assertThat(actualZips).isEqualTo(listOf(listOf("a"))) + actualZips shouldBe listOf(listOf("a")) } } @@ -81,7 +81,7 @@ class SequencesKtTest : FunSpec({ val actual = listOf("a", "a", "a", "b", "c", "c").zipWithConsecutivesEnclosing { it } - assertThat(actual).isEqualTo(expected) + actual shouldBe expected } test("test basic sequence with same enclosing pair") { @@ -90,19 +90,19 @@ class SequencesKtTest : FunSpec({ val actualZips = elements.zipWithConsecutivesEnclosing { it } - assertThat(actualZips).isEqualTo(expectedZips) + actualZips shouldBe expectedZips } test("empty list should return an empty list") { val actualZips = emptyList().zipWithConsecutivesEnclosing { it } - assertThat(actualZips).isEqualTo(emptyList()) + actualZips shouldBe emptyList() } test("test single element") { val actualZips = listOf("a").zipWithConsecutivesEnclosing { it } - assertThat(actualZips).isEqualTo(listOf(listOf("a"))) + actualZips shouldBe listOf(listOf("a")) } test("test ordering") { @@ -121,7 +121,7 @@ class SequencesKtTest : FunSpec({ val actualZips = startList.zipWithConsecutivesEnclosing { it.first } - assertThat(actualZips).isEqualTo(expectedZips) + actualZips shouldBe 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 0210eb97..d7635b2e 100644 --- a/rtron-std/src/test/kotlin/io/rtron/std/SetsKtTest.kt +++ b/rtron-std/src/test/kotlin/io/rtron/std/SetsKtTest.kt @@ -17,7 +17,7 @@ package io.rtron.std import io.kotest.core.spec.style.FunSpec -import org.assertj.core.api.Assertions.assertThat +import io.kotest.matchers.shouldBe class SetsKtTest : FunSpec({ context("TestCombinations") { @@ -32,7 +32,7 @@ class SetsKtTest : FunSpec({ val actualCombinations = startSet.combinations(2) - assertThat(actualCombinations).isEqualTo(expectedCombinations) + actualCombinations shouldBe expectedCombinations } } })