Skip to content

Commit

Permalink
Add Double.shouldBeCloseTo #minor
Browse files Browse the repository at this point in the history
  • Loading branch information
geirsagberg committed Oct 18, 2022
1 parent 9da2fcb commit 5e97726
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 <T> Collection<T>?.shouldContainSingle(match: (t: T) -> Boolean): T {
Expand All @@ -10,3 +11,7 @@ fun <T> Collection<T>?.shouldContainSingle(match: (t: T) -> Boolean): T {
it.single()
}
}

fun Double.shouldBeCloseTo(value: Double, tolerance: Double) {
this.shouldBeBetween(value, value, tolerance)
}

0 comments on commit 5e97726

Please sign in to comment.