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

shouldHaveSameMonthAs

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

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

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

Opposite of LocalDate.shouldNotHaveSameMonthAs

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

    firstDate should haveSameYear(secondDate)   //  Assertion passes


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

    firstDate shouldNot haveSameYear(secondDate)    //  Assertion passes