From 9d97be5f3e2c0f571d3a6f8354c3d1a48369bb4a Mon Sep 17 00:00:00 2001 From: Wagner Dias Date: Wed, 9 Jun 2021 12:18:08 -0300 Subject: [PATCH] add samples for chronoLocalDateTimeExpectations of api-fluent #915 (#935) --- .../en_GB/chronoLocalDateTimeExpectations.kt | 20 +++ .../ChronoLocalDateTimeExpectationSamples.kt | 116 ++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ChronoLocalDateTimeExpectationSamples.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateTimeExpectations.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateTimeExpectations.kt index e04ffdae1..4814377e2 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateTimeExpectations.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateTimeExpectations.kt @@ -17,6 +17,8 @@ import java.time.chrono.ChronoLocalDateTime * * @return an [Expect] for the subject of `this` expectation. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeBeforeChronoLocalDateTime + * * @since 0.17.0 */ fun > Expect.toBeBefore( @@ -37,6 +39,8 @@ fun > Expect.toBeBefore( * @return an [Expect] for the subject of `this` expectation. * @throws [java.time.DateTimeException] in case an unsupported format is given. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeBeforeString + * * @since 0.17.0 */ fun > Expect.toBeBefore( @@ -50,6 +54,8 @@ fun > Expect.toBeBefore( * * @return an [Expect] for the subject of `this` expectation. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeBeforeOrTheSamePointInTimeAsChronoLocalDateTime + * * @since 0.17.0 */ fun > Expect.toBeBeforeOrTheSamePointInTimeAs( @@ -70,6 +76,8 @@ fun > Expect.toBeBeforeOrTheSame * @return an [Expect] for the subject of `this` expectation. * @throws [java.time.DateTimeException] in case an unsupported format is given. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeBeforeOrTheSamePointInTimeAsString + * * @since 0.17.0 */ fun > Expect.toBeBeforeOrTheSamePointInTimeAs( @@ -83,6 +91,8 @@ fun > Expect.toBeBeforeOrTheSame * * @return an [Expect] for the subject of `this` expectation. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeTheSamePointInTimeAsChronoLocalDateTime + * * @since 0.17.0 */ fun > Expect.toBeTheSamePointInTimeAs( @@ -103,6 +113,8 @@ fun > Expect.toBeTheSamePointInT * @return an [Expect] for the subject of `this` expectation. * @throws [java.time.DateTimeException] in case an unsupported format is given. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeTheSamePointInTimeAsString + * * @since 0.17.0 */ fun > Expect.toBeTheSamePointInTimeAs( @@ -116,6 +128,8 @@ fun > Expect.toBeTheSamePointInT * * @return an [Expect] for the subject of `this` expectation. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeAfterOrTheSamePointInTimeAsChronoLocalDateTime + * * @since 0.17.0 */ fun > Expect.toBeAfterOrTheSamePointInTimeAs( @@ -136,6 +150,8 @@ fun > Expect.toBeAfterOrTheSameP * @return an [Expect] for the subject of `this` expectation. * @throws [java.time.DateTimeException] in case an unsupported format is given. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeAfterOrTheSamePointInTimeAsString + * * @since 0.17.0 */ fun > Expect.toBeAfterOrTheSamePointInTimeAs( @@ -149,6 +165,8 @@ fun > Expect.toBeAfterOrTheSameP * * @return an [Expect] for the subject of `this` expectation. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeAfterChronoLocalDateTime + * * @since 0.17.0 */ fun > Expect.toBeAfter( @@ -169,6 +187,8 @@ fun > Expect.toBeAfter( * @return an [Expect] for the subject of `this` expectation. * @throws [java.time.DateTimeException] in case an unsupported format is given. * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ChronoLocalDateTimeExpectationSamples.toBeAfterString + * * @since 0.17.0 */ fun > Expect.toBeAfter( diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ChronoLocalDateTimeExpectationSamples.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ChronoLocalDateTimeExpectationSamples.kt new file mode 100644 index 000000000..f230173af --- /dev/null +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/ChronoLocalDateTimeExpectationSamples.kt @@ -0,0 +1,116 @@ +package ch.tutteli.atrium.api.fluent.en_GB.samples + +import ch.tutteli.atrium.api.fluent.en_GB.* +import ch.tutteli.atrium.api.verbs.internal.expect +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.Month +import kotlin.test.Test + +class ChronoLocalDateTimeExpectationSamples { + + @Test + fun toBeBeforeChronoLocalDateTime() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBefore(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)) + } + + @Test + fun toBeBeforeString() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBefore("2021-06-06T12:10:00.000000000") + + // format yyyy-MM-ddThh:mm:SS can be used, in which case .000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBefore("2021-06-06T12:10:00") + + // format yyyy-MM-ddThh:mm can be used, in which case 00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBefore("2021-06-06T12:10") + + // format yyyy-MM-dd can be used, in which case 00:00:00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBefore("2021-06-07") + } + + @Test + fun toBeBeforeOrTheSamePointInTimeAsChronoLocalDateTime() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBeforeOrTheSamePointInTimeAs(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)) + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBeforeOrTheSamePointInTimeAs(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)) + } + + @Test + fun toBeBeforeOrTheSamePointInTimeAsString() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBeforeOrTheSamePointInTimeAs("2021-06-06T12:10:00.000000000") + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBeforeOrTheSamePointInTimeAs("2021-06-06T10:05:35.000000103") + + // format yyyy-MM-ddThh:mm:SS can be used, in which case .000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 34, 0)).toBeBeforeOrTheSamePointInTimeAs("2021-06-06T12:10:00") + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 0)).toBeBeforeOrTheSamePointInTimeAs("2021-06-06T10:05:35") + + // format yyyy-MM-ddThh:mm can be used, in which case 00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBeforeOrTheSamePointInTimeAs("2021-06-06T12:10") + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 0, 0)).toBeBeforeOrTheSamePointInTimeAs("2021-06-06T10:05") + + // format yyyy-MM-dd can be used, in which case 00:00:00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeBeforeOrTheSamePointInTimeAs("2021-06-07") + expect(LocalDateTime.of(2021, Month.JUNE, 6, 0, 0, 0, 0)).toBeBeforeOrTheSamePointInTimeAs("2021-06-06") + } + + @Test + fun toBeTheSamePointInTimeAsChronoLocalDateTime() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeTheSamePointInTimeAs(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)) + } + + @Test + fun toBeTheSamePointInTimeAsString() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeTheSamePointInTimeAs("2021-06-06T10:05:35.000000103") + + // format yyyy-MM-ddThh:mm:SS can be used, in which case .000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 0)).toBeTheSamePointInTimeAs("2021-06-06T10:05:35") + + // format yyyy-MM-ddThh:mm can be used, in which case 00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 0, 0)).toBeTheSamePointInTimeAs("2021-06-06T10:05") + + // format yyyy-MM-dd can be used, in which case 00:00:00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 0, 0, 0, 0)).toBeTheSamePointInTimeAs("2021-06-06") + } + + @Test + fun toBeAfterOrTheSamePointInTimeAsChronoLocalDateTime() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfterOrTheSamePointInTimeAs(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)) + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeAfterOrTheSamePointInTimeAs(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)) + } + + @Test + fun toBeAfterOrTheSamePointInTimeAsString() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfterOrTheSamePointInTimeAs("2021-06-06T10:05:35.000000103") + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)).toBeAfterOrTheSamePointInTimeAs("2021-06-06T10:05:35.000000103") + + // format yyyy-MM-ddThh:mm:SS can be used, in which case .000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfterOrTheSamePointInTimeAs("2021-06-06T10:05:35") + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 0)).toBeAfterOrTheSamePointInTimeAs("2021-06-06T10:05:35") + + // format yyyy-MM-ddThh:mm can be used, in which case 00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfterOrTheSamePointInTimeAs("2021-06-06T10:05") + expect(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 0, 0)).toBeAfterOrTheSamePointInTimeAs("2021-06-06T10:05") + + // format yyyy-MM-dd can be used, in which case 00:00:00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfterOrTheSamePointInTimeAs("2021-06-06") + expect(LocalDateTime.of(2021, Month.JUNE, 6, 0, 0, 0, 0)).toBeAfterOrTheSamePointInTimeAs("2021-06-06") + } + + @Test + fun toBeAfterChronoLocalDateTime() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfter(LocalDateTime.of(2021, Month.JUNE, 6, 10, 5, 35, 103)) + } + + @Test + fun toBeAfterString() { + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfter("2021-06-06T10:05:35.103000000") + + // format yyyy-MM-ddThh:mm:SS can be used, in which case .000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfter("2021-06-06T10:05:35") + + // format yyyy-MM-ddThh:mm can be used, in which case 00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfter("2021-06-06T10:05") + + // format yyyy-MM-dd can be used, in which case 00:00:00.000000000 is used for the omitted part + expect(LocalDateTime.of(2021, Month.JUNE, 6, 12, 10, 0, 0)).toBeAfter("2021-06-06") + } +}