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

shouldNotBeBetween

fun LocalTime.shouldNotBeBetween(a: LocalTime, b: LocalTime): Unit

Asserts that this is NOT between a and b

Verifies that this is not after a and before b, comparing hours, minutes, seconds, nanos.

Opposite of LocalTime.shouldBeBetween

    val time = LocalTime.of(12, 30, 59, 1111)
    val firstTime = LocalTime.of(12, 30, 59, 2222)
    val secondTime = LocalTime.of(12, 30, 59, 3333)

    time.shouldNotBeBetween(firstTime, secondTime) // Assertion passes


    val time = LocalTime.of(12, 30, 59, 1111)
    val firstTime = LocalTime.of(11, 0, 0, 0)
    val secondTime = LocalTime.of(12, 31, 0, 0)

    time.shouldNotBeBetween(firstTime, secondTime)  // Assertion fails, time IS between firstTime and secondTime

See Also

LocalTime.shouldBeBetween