From 5e97726f9605b6af737c5936a13a9616197cb75b Mon Sep 17 00:00:00 2001 From: Geir Sagberg Date: Tue, 18 Oct 2022 13:00:02 +0200 Subject: [PATCH] Add Double.shouldBeCloseTo #minor --- .../saga/modules/testing/KotestAssertionExtensions.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/testing/src/main/kotlin/no/vegvesen/saga/modules/testing/KotestAssertionExtensions.kt b/modules/testing/src/main/kotlin/no/vegvesen/saga/modules/testing/KotestAssertionExtensions.kt index 1259b6f3..90c10266 100644 --- a/modules/testing/src/main/kotlin/no/vegvesen/saga/modules/testing/KotestAssertionExtensions.kt +++ b/modules/testing/src/main/kotlin/no/vegvesen/saga/modules/testing/KotestAssertionExtensions.kt @@ -1,6 +1,7 @@ package no.vegvesen.saga.modules.testing import io.kotest.matchers.collections.shouldHaveSize +import io.kotest.matchers.doubles.shouldBeBetween import io.kotest.matchers.nulls.shouldNotBeNull fun Collection?.shouldContainSingle(match: (t: T) -> Boolean): T { @@ -10,3 +11,7 @@ fun Collection?.shouldContainSingle(match: (t: T) -> Boolean): T { it.single() } } + +fun Double.shouldBeCloseTo(value: Double, tolerance: Double) { + this.shouldBeBetween(value, value, tolerance) +}