Skip to content

Commit

Permalink
document-plusOrMinus-for-temporals (#34) (#3885)
Browse files Browse the repository at this point in the history
document new `plusOrMinus` matchers

---------

Co-authored-by: Emil Kantis <e.kantis@gmail.com>
  • Loading branch information
AlexCue987 and Kantis committed Feb 21, 2024
1 parent cc86a1d commit 6db02a6
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions documentation/docs/assertions/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,25 +207,28 @@ Matchers provided by the `kotest-assertions-core` module.
| `date.shouldHaveNano(nao)` | Asserts that the date have correct nano second. |
| `date.shouldBe(value plusOrMinus(tolerance))` | Asserts that the date is equal to the given value within a tolerance range of duration. |

| ZonedDateTime ||
|---------------------------------------------------------------| ---- |
| `zonedDateTime.shouldBeToday()` | Asserts that the ZonedDateTime has the same day as the today. |
| `zonedDateTime.shouldHaveSameInstantAs(other: ZonedDateTime)` | Asserts that the ZonedDateTime is equal to other ZonedDateTime using ```ChronoZonedDateTime.isEqual```. |

| OffsetDateTime | |
|-----------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| `offsetDateTime.shouldBeToday()` | Asserts that the OffsetDateTime has the same day as today. |
| `offsetDateTime.shouldHaveSameInstantAs(other: OffsetDateTime)` | Asserts that the OffsetDateTime is equal to other OffsetDateTime using ```OffsetDateTime.isEqual```. |

| Times ||
|-----------------------------------------------| ---- |
| `time.shouldHaveSameHoursAs(otherTime)` | Asserts that the time has the same hours as the given time. |
| `time.shouldHaveSameMinutesAs(otherTime)` | Asserts that the time has the same minutes as the given time. |
| `time.shouldHaveSameSecondsAs(otherTime)` | Asserts that the time has the same seconds as the given time. |
| `time.shouldHaveSameNanosAs(otherTime)` | Asserts that the time has the same nanos as the given time. |
| `time.shouldBeBefore(otherTime)` | Asserts that the time is before the given time. |
| `time.shouldBeAfter(otherTime)` | Asserts that the time is after the given time. |
| `time.shouldBeBetween(firstTime, secondTime)` | Asserts that the time is between firstTime and secondTime. |
| ZonedDateTime ||
|----------------------------------------------------------------------| ---- |
| `zonedDateTime.shouldBeToday()` | Asserts that the ZonedDateTime has the same day as the today. |
| `zonedDateTime.shouldHaveSameInstantAs(other: ZonedDateTime)` | Asserts that the ZonedDateTime is equal to other ZonedDateTime using ```ChronoZonedDateTime.isEqual```. |
| `zonedDateTime.shouldBe(other plusOrMinus 1.minutes)` | Asserts that the ZonedDateTime is within 1 minute of `other` ZonedDateTime. |

| OffsetDateTime | |
|--------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| `offsetDateTime.shouldBeToday()` | Asserts that the OffsetDateTime has the same day as today. |
| `offsetDateTime.shouldHaveSameInstantAs(other: OffsetDateTime)` | Asserts that the OffsetDateTime is equal to other OffsetDateTime using ```OffsetDateTime.isEqual```. |
| `offsetDateTime.shouldBe(other: OffsetDateTime plusOrMinus 1.minutes)` | Asserts that the OffsetDateTime is within 1 minute of other OffsetDateTime. |

| Times ||
|-----------------------------------------------------| ---- |
| `time.shouldHaveSameHoursAs(otherTime)` | Asserts that the time has the same hours as the given time. |
| `time.shouldHaveSameMinutesAs(otherTime)` | Asserts that the time has the same minutes as the given time. |
| `time.shouldHaveSameSecondsAs(otherTime)` | Asserts that the time has the same seconds as the given time. |
| `time.shouldHaveSameNanosAs(otherTime)` | Asserts that the time has the same nanos as the given time. |
| `time.shouldBeBefore(otherTime)` | Asserts that the time is before the given time. |
| `time.shouldBeAfter(otherTime)` | Asserts that the time is after the given time. |
| `time.shouldBeBetween(firstTime, secondTime)` | Asserts that the time is between firstTime and secondTime. |
| `time.shouldBe(otherTime plusOrMinus 1.minutes)` | Asserts that the time is within duration of other time. |



Expand All @@ -235,6 +238,7 @@ Matchers provided by the `kotest-assertions-core` module.
| `instant.shouldBeBefore(anotherInstant)` | Asserts that the instant is before anotherInstant |
| `instant.shouldBeBetween(fromInstant, toInstant)` | Asserts that the instant is between fromInstant and toInstant |
| `instant.shouldBeCloseTo(anotherInstant, duration)` | Asserts that the instant is close To anotherInstant in range by duration |
| `instant.shouldBe(otherTime plusOrMinus 1.minutes)` | Asserts that the instant is within duration of other instant. |

| Timestamp ||
|---------------------------------------------------------| ---- |
Expand Down

0 comments on commit 6db02a6

Please sign in to comment.