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

shouldNotHaveSameYearAs

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

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

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

Opposite of LocalDate.shouldHaveSameYearAs

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

    firstDate shouldNotHaveSameYearAs secondDate    //  Assertion passes


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

    firstDate shouldNotHaveSameYearAs  secondDate   //  Assertion fails, 1998 == 1998, and we expected a difference