kotest-assertions-core / io.kotest.matchers.date / java.time.LocalTime / shouldHaveSameSecondsAs

shouldHaveSameSecondsAs

infix fun LocalTime.shouldHaveSameSecondsAs(time: LocalTime): Unit

Asserts that seconds in this time are the same as time's seconds

Verifies that seconds in this time are the same as time's seconds, ignoring any other fields. For example, 1:59:03:7777 has the same seconds as 2:33:03:3333, and this assertion should pass for this comparison

Opposite of LocalTime.shouldNotHaveSameSecondsAs

    val firstTime = LocalTime.of(13, 59, 30, 1000)
    val secondTime = LocalTime.of(17, 22, 30, 3333)

    firstTime shouldHaveSameSecondsAs secondTime   //  Assertion passes


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

    firstTime shouldHaveSameSecondsAs secondTime   //  Assertion fails, 30 != 25