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

shouldBeAfter

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

Asserts that this is after other

Verifies that this is after other, comparing year, month and day. For example, 09/02/1998 is after 08/02/1998, and this assertion should pass for this comparison.

Opposite of Date.shouldNotBeAfter

    val firstDate = Date(1998, 2, 9)
    val secondDate = Date(1998, 2, 8)

    firstDate shouldBeAfter secondDate  // Assertion passes


    val firstDate = Date(1998, 2, 9)
    val secondDate = Date(1998, 2, 10)

    firstDate shouldBeAfter secondDate  // Assertion fails, firstDate is NOT after secondDate

See Also

Date.shouldNotBeBefore