kotest-assertions-core / io.kotest.matchers.date / java.time.LocalDate / shouldNotBeWithin

shouldNotBeWithin

fun LocalDate.shouldNotBeWithin(period: Period, date: LocalDate): Unit

Asserts that this is NOT within period of date

Verifies that this is not within period of date. For example, 09/02/1998 is not within 3 days of 25/02/1998, and this assertion should pass for this comparison.

Opposite of LocalDate.shouldBeWithin

    val firstDate = LocalDate.of(1998, 2, 9)
    val secondDate = LocalDate.of(1998, 2, 25)

    firstDate.shouldNotBeWithin(Period.ofDays(3), secondDate) // Assertion passes


    val firstDate = LocalDate.of(1998, 2, 9)
    val secondDate = LocalDate.of(1998, 2, 10)

    firstDate.shouldNotBeWithin(Period.ofDays(3), secondDate)   // Assertion fails, firstDate is within 3 days of secondDate, and we expected not to