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

haveSameHours

fun haveSameHours(other: <ERROR CLASS>): Matcher<<ERROR CLASS>>

Matcher that compares hours of Dates

Verifies that two times have exactly the same hours, ignoring any other fields. For example, 23:59:30:9999 has the same hours as 23:01:02:3333, and the matcher will have a positive result for this comparison

    val firstTime = Date(23, 59, 30, 1000)
    val secondTime = Date(23, 1, 2, 3333)

    firstTime should haveSameHours(secondTime)   //  Assertion passes


    val firstTime = Date(23, 59, 30, 1000)
    val secondTime = Date(16, 59, 30, 1000)

    firstTime shouldNot haveSameHours(secondTime)   //  Assertion passes

See Also

Date.shouldHaveSameHoursAs

Date.shouldNotHaveSameHoursAs