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

shouldHaveSameDayAs

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

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

Verifies that this day is the same as date's day, ignoring any other fields. For example, 09/02/1998 has the same day as 09/03/2018, and this assertion should pass for this comparison

Opposite of LocalDate.shouldNotHaveSameDayAs

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

    firstDate shouldHaveSameDayAs secondDate   //  Assertion passes


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

    firstDate shouldHaveSameDayAs secondDate   //  Assertion fails, 9 != 10