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

shouldNotHaveSameDayAs

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

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

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

Opposite of LocalDateTime.shouldHaveSameDayAs

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

    firstDate shouldNotHaveSameDayAs secondDate    // Assertion passes


    val firstDate = LocalDateTime.of(2018, 2, 9, 10, 0, 0)
    val secondDate = LocalDateTime.of(1998, 3, 9, 11, 30, 30)

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