fun between(fromInstant: Instant, toInstant: Instant): Matcher<Instant>
fun between(a: LocalTime, b: LocalTime): Matcher<LocalTime>
Matcher that checks if LocalTime is between two other LocalTimes
Verifies that LocalTime is after the first LocalTime and before the second LocalTime For example, 12:30:59:2222 is between 12:30:59:1111 and 12:30:59:3333, and the matcher will have a positive result for this comparison
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 shouldBe after(firstTime, secondTime) // Assertion passes
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 shouldNotBe between(firstTime, secondTime) // Assertion passes
See Also
fun between(a: LocalDate, b: LocalDate): Matcher<LocalDate>
Matcher that checks if LocalDate is between two other LocalDates
Verifies that LocalDate is after the first LocalDate and before the second LocalDate For example, 20/03/2019 is between 19/03/2019 and 21/03/2019, and the matcher will have a positive result for this comparison
val date = LocalDate.of(2019, 2, 16)
val firstDate = LocalDate.of(2019, 2, 15)
val secondDate = LocalDate.of(2019, 2, 17)
date shouldBe after(firstDate, secondDate) // Assertion passes
val date = LocalDate.of(2019, 2, 15)
val firstDate = LocalDate.of(2019, 2, 16)
val secondDate = LocalDate.of(2019, 2, 17)
date shouldNotBe between(firstDate, secondDate) // Assertion passes
See Also
fun between(a: LocalDateTime, b: LocalDateTime): Matcher<LocalDateTime>
Matcher that checks if LocalDateTime is between two other LocalDateTimes
Verifies that LocalDateTime is after the first LocalDateTime and before the second LocalDateTime For example, 20/03/2019 10:00:00 is between 19/03/2019 10:00:00 and 21/03/2019 10:00:00, and the matcher will have a positive result for this comparison
val date = LocalDateTime.of(2019, 2, 16, 12, 0, 0)
val firstDate = LocalDateTime.of(2019, 2, 15, 12, 0, 0)
val secondDate = LocalDateTime.of(2019, 2, 17, 12, 0, 0)
date shouldBe after(firstDate, secondDate) // Assertion passes
val date = LocalDateTime.of(2019, 2, 15, 12, 0, 0)
val firstDate = LocalDateTime.of(2019, 2, 16, 12, 0, 0)
val secondDate = LocalDateTime.of(2019, 2, 17, 12, 0, 0)
date shouldNotBe between(firstDate, secondDate) // Assertion passes
See Also
LocalDateTime.shouldNotBeBetween
fun between(a: ZonedDateTime, b: ZonedDateTime): Matcher<ZonedDateTime>
Matcher that checks if ZonedDateTime is between two other ZonedDateTimes
Verifies that ZonedDateTime is after the first ZonedDateTime and before the second ZonedDateTime For example, 20/03/2019 10:00:00 -03:00 America/Sao_Paulo is between 19/03/2019 10:00:00 -03:00 America/Sao_Paulo and 21/03/2019 10:00:00 -03:00 America/Sao_Paulo, and the matcher will have a positive result for this comparison
val date = ZonedDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
val firstDate = ZonedDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
val secondDate = ZonedDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
date shouldBe after(firstDate, secondDate) // Assertion passes
val date = ZonedDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
val firstDate = ZonedDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
val secondDate = ZonedDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
date shouldNotBe between(firstDate, secondDate) // Assertion passes
See Also
ZonedDateTime.shouldNotBeBetween
fun between(a: OffsetDateTime, b: OffsetDateTime): Matcher<OffsetDateTime>
Matcher that checks if OffsetDateTime is between two other OffsetDateTimes
Verifies that OffsetDateTime is after the first OffsetDateTime and before the second OffsetDateTime For example, 20/03/2019 10:00:00 -03:00 is between 19/03/2019 10:00:00 -03:00 and 21/03/2019 10:00:00 -03:00, and the matcher will have a positive result for this comparison
val date = OffsetDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneOffset.ofHours(-3))
val firstDate = OffsetDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneOffset.ofHours(-3))
val secondDate = OffsetDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneOffset.ofHours(-3))
date shouldBe after(firstDate, secondDate) // Assertion passes
val date = OffsetDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneOffset.ofHours(-3))
val firstDate = OffsetDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneOffset.ofHours(-3))
val secondDate = OffsetDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneOffset.ofHours(-3))
date shouldNotBe between(firstDate, secondDate) // Assertion passes
See Also