kotest-assertions-core / io.kotest.matchers.date / haveSameSeconds

haveSameSeconds

fun haveSameSeconds(time: LocalTime): Matcher<LocalTime>

Matcher that compares seconds of LocalTimes

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

    val firstTime = LocalTime.of(23, 59, 30, 1000)
    val secondTime = LocalTime.of(12, 27, 30, 3333)

    firstTime should haveSameSeconds(secondTime)   //  Assertion passes


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

    firstTime shouldNot haveSameSeconds(secondTime)   //  Assertion passes

See Also

LocalTime.shouldHaveSameSecondsAs

LocalTime.shouldNotHaveSameSecondsAs