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

shouldNotHaveSameMonthAs

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

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

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

Opposite of LocalDate.shouldHaveSameMonthAs

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

    firstDate shouldHaveSameMonthAs secondDate   //  Assertion passes


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

    firstDate shouldHaveSameMonthAs secondDate   //  Assertion fails, 2 != 3