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

shouldNotHaveSameDayAs

infix fun LocalDate.shouldNotHaveSameDayAs(date: LocalDate): Unit

Asserts that this day is NOT the same as date's day

Verifies that this day isn't the same as date's day, ignoring any other fields. For example, 09/02/1998 doesn't have the same day as 10/02/1998, and this assertion should pass for this comparison

Opposite of LocalDate.shouldHaveSameDayAs

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

    firstDate shouldNotHaveSameDayAs secondDate    //  Assertion passes


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

    firstDate shouldNotHaveSameDayAs  secondDate   //  Assertion fails, 9 == 9, and we expected a difference