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

shouldNotHaveSameMonthAs

infix fun LocalDateTime.shouldNotHaveSameMonthAs(date: LocalDateTime): 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 10:00:00 doesn't have the same month as 09/03/1998 10:00:00, and this assertion should pass for this comparison

Opposite of LocalDateTime.shouldHaveSameMonthAs

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

    firstDate shouldHaveSameMonthAs secondDate   //  Assertion passes


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

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