kotest-assertions / io.kotest.matchers.date / shouldHaveSameHoursAs

shouldHaveSameHoursAs

infix fun <ERROR CLASS>.shouldHaveSameHoursAs(other: <ERROR CLASS>): <ERROR CLASS>

Asserts that hours in this Date are the same as the given date.

Verifies that hours in this Date are the same as other's hours, ignoring any other fields. For example, 16:59:59:7777 has the same hours as 16:01:02:0001, and this assertion should pass for this comparison

Opposite of Date.shouldNotHaveSameHoursAs

    val firstTime = LocalTime.of(23, 59, 30, 1000)
    val secondTime = LocalTime.of(23, 1, 2, 3333)

    firstTime shouldHaveSameHoursAs secondTime   //  Assertion passes


    val firstTime = LocalTime.of(23, 59, 30, 1000)
    val secondTime = LocalTime.of(16, 59, 30, 1000)

    firstTime shouldHaveSameHoursAs secondTime   //  Assertion fails, 23 != 16