rename chronoLocalDateTimeAssertion functions to new schema in api-fluent

This commit is contained in:
Robert Stoll
2021-05-21 21:30:42 +02:00
parent 4321ef071c
commit 7f104c5d18
5 changed files with 304 additions and 128 deletions

View File

@@ -25,7 +25,7 @@ fun <T : ChronoLocalDate> Expect<T>.toBeBefore(expected: ChronoLocalDate): Expec
* is before the [expected] [java.time.LocalDate] given as [String].
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd**
* @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd**
*
* @since 0.17.0
*/
@@ -49,7 +49,7 @@ fun <T : ChronoLocalDate> Expect<T>.toBeBeforeOrTheSamePointInTimeAs(expected: C
* is before or equal the [expected] [java.time.LocalDate] given as [String].
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd**
* @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd**
*
* @since 0.17.0
*/
@@ -73,7 +73,7 @@ fun <T : ChronoLocalDate> Expect<T>.toBeTheSamePointInTimeAs(expected: ChronoLoc
* is equal to the [expected] [java.time.LocalDate] given as [String].
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd**
* @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd**
*
* @since 0.17.0
*/
@@ -96,7 +96,7 @@ fun <T : ChronoLocalDate> Expect<T>.toBeAfterOrTheSamePointInTimeAs(expected: Ch
* is after or equal the [expected] [java.time.LocalDate] given as [String].
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd**
* @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd**
*
* @since 0.17.0
*/
@@ -120,7 +120,7 @@ fun <T : ChronoLocalDate> Expect<T>.toBeAfter(expected: ChronoLocalDate): Expect
* is after the [expected] [java.time.LocalDate] given as [String].
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd**
* @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd**
*
* @since 0.17.0
*/

View File

@@ -0,0 +1,176 @@
@file:Suppress(
// TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed
"JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE"
)
package ch.tutteli.atrium.api.fluent.en_GB
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic.*
import java.time.LocalDateTime
import java.time.chrono.ChronoLocalDate
import java.time.chrono.ChronoLocalDateTime
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is before the [expected] [ChronoLocalDateTime].
*
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeBefore(
expected: ChronoLocalDateTime<*>
): Expect<T> = _logicAppend { isBefore(expected) }
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format.
* The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation.
* The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a
* date without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest:
* yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds)
* yyyy-mm-ddThh:mm:ss
* yyyy-mm-ddThh:mm
* yyyy-mm-dd
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [java.time.DateTimeException] in case an unsupported format is given.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeBefore(
expected: String
): Expect<T> = _logicAppend { isBefore(expected) }
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is before or equal the [expected] [ChronoLocalDateTime].
*
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeBeforeOrTheSamePointInTimeAs(
expected: ChronoLocalDateTime<*>
): Expect<T> = _logicAppend { isBeforeOrEqual(expected) }
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format.
* The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation.
* The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a
* date without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest:
* yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds)
* yyyy-mm-ddThh:mm:ss
* yyyy-mm-ddThh:mm
* yyyy-mm-dd
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [java.time.DateTimeException] in case an unsupported format is given.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeBeforeOrTheSamePointInTimeAs(
expected: String
): Expect<T> = _logicAppend { isBeforeOrEqual(expected) }
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is equal to the [expected] [ChronoLocalDateTime].
*
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeTheSamePointInTimeAs(
expected: ChronoLocalDateTime<*>
): Expect<T> = _logicAppend { isEqual(expected) }
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format.
* The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation.
* The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a date
* without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest:
* yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds)
* yyyy-mm-ddThh:mm:ss
* yyyy-mm-ddThh:mm
* yyyy-mm-dd
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [java.time.DateTimeException] in case an unsupported format is given.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeTheSamePointInTimeAs(
expected: String
): Expect<T> = _logicAppend { isEqual(expected) }
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is after or equal the [expected] [ChronoLocalDateTime].
*
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeAfterOrTheSamePointInTimeAs(
expected: ChronoLocalDateTime<*>
): Expect<T> = _logicAppend { isAfterOrEqual(expected) }
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format.
* The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation.
* The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a date
* without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest:
* yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds)
* yyyy-mm-ddThh:mm:ss
* yyyy-mm-ddThh:mm
* yyyy-mm-dd
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [java.time.DateTimeException] in case an unsupported format is given.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeAfterOrTheSamePointInTimeAs(
expected: String
): Expect<T> = _logicAppend { isAfterOrEqual(expected) }
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is after the [expected] [ChronoLocalDateTime].
*
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeAfter(
expected: ChronoLocalDateTime<*>
): Expect<T> = _logicAppend { isAfter(expected) }
/**
* Expects that the subject of `this` expectation (a [ChronoLocalDateTime])
* is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format.
* The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation.
* The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a date
* without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest:
* yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds)
* yyyy-mm-ddThh:mm:ss
* yyyy-mm-ddThh:mm
* yyyy-mm-dd
*
* @return an [Expect] for the subject of `this` expectation.
* @throws [java.time.DateTimeException] in case an unsupported format is given.
*
* @since 0.17.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.toBeAfter(
expected: String
): Expect<T> = _logicAppend { isAfter(expected) }

View File

@@ -14,20 +14,20 @@ class ChronoLocalDateTimeExpectationsSpec : Spek({
include(ChronoLocalDateTimeAsStringSpec)
}) {
object ChronoLocalDateTimeSpec : ch.tutteli.atrium.specs.integration.ChronoLocalDateTimeExpectationsSpec(
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::isBefore),
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::isBeforeOrEqual),
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::isAfter),
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::isAfterOrEqual),
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::isEqual)
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::toBeBefore),
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::toBeBeforeOrTheSamePointInTimeAs),
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::toBeAfter),
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::toBeAfterOrTheSamePointInTimeAs),
fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::toBeTheSamePointInTimeAs)
)
object ChronoLocalDateTimeAsStringSpec :
ch.tutteli.atrium.specs.integration.ChronoLocalDateTimeAsStringExpectationsSpec(
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::isBefore),
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::isBeforeOrEqual),
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::isAfter),
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::isAfterOrEqual),
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::isEqual)
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::toBeBefore),
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::toBeBeforeOrTheSamePointInTimeAs),
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::toBeAfter),
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::toBeAfterOrTheSamePointInTimeAs),
fun1<ChronoLocalDateTime<*>, String>(Expect<ChronoLocalDateTime<*>>::toBeTheSamePointInTimeAs)
)
@Suppress("unused", "UNUSED_VALUE")

View File

@@ -13,11 +13,11 @@ import java.time.chrono.ChronoLocalDateTime
import java.time.chrono.JapaneseDate
abstract class ChronoLocalDateTimeExpectationsSpec(
isBefore: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
isBeforeOrEqual: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
isAfter: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
isAfterOrEqual: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
isEqual: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
toBeBefore: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
toBeBeforeOrTheSamePointInTimeAs: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
toBeAfter: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
toBeAfterOrTheSamePointInTimeAs: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
toBeTheSamePointInTimeAs: Fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>,
describePrefix: String = "[Atrium] "
) : Spek({
@@ -27,18 +27,18 @@ abstract class ChronoLocalDateTimeExpectationsSpec(
include(object : SubjectLessSpec<ChronoLocalDateTime<*>>(
describePrefix,
isBefore.forSubjectLess(eleven),
isBeforeOrEqual.forSubjectLess(eleven),
isAfter.forSubjectLess(eleven),
isAfterOrEqual.forSubjectLess(eleven),
isEqual.forSubjectLess(eleven)
toBeBefore.forSubjectLess(eleven),
toBeBeforeOrTheSamePointInTimeAs.forSubjectLess(eleven),
toBeAfter.forSubjectLess(eleven),
toBeAfterOrTheSamePointInTimeAs.forSubjectLess(eleven),
toBeTheSamePointInTimeAs.forSubjectLess(eleven)
) {})
val isBeforeDescr = DescriptionDateTimeLikeAssertion.IS_BEFORE.getDefault()
val isBeforeOrEqualDescr = DescriptionDateTimeLikeAssertion.IS_BEFORE_OR_EQUAL.getDefault()
val isAfterDescr = DescriptionDateTimeLikeAssertion.IS_AFTER.getDefault()
val isAfterOrEqualDescr = DescriptionDateTimeLikeAssertion.IS_AFTER_OR_EQUAL.getDefault()
val isEqualDescr = DescriptionDateTimeLikeAssertion.IS_EQUAL_TO.getDefault()
val toBeBeforeDescr = DescriptionDateTimeLikeAssertion.IS_BEFORE.getDefault()
val toBeBeforeOrTheSamePointInTimeAsDescr = DescriptionDateTimeLikeAssertion.IS_BEFORE_OR_EQUAL.getDefault()
val toBeAfterDescr = DescriptionDateTimeLikeAssertion.IS_AFTER.getDefault()
val toBeAfterOrTheSamePointInTimeAsDescr = DescriptionDateTimeLikeAssertion.IS_AFTER_OR_EQUAL.getDefault()
val toBeTheSamePointInTimeAsDescr = DescriptionDateTimeLikeAssertion.IS_EQUAL_TO.getDefault()
listOf<ChronoLocalDateTime<*>>(
eleven,
@@ -47,88 +47,88 @@ abstract class ChronoLocalDateTimeExpectationsSpec(
val fluent = expect(subject)
describe("$describePrefix subject is $subject") {
describe("${isBefore.name} ...") {
val isBeforeFun = isBefore.lambda
describe("${toBeBefore.name} ...") {
val toBeBeforeFun = toBeBefore.lambda
it("$ten throws an AssertionError") {
expect {
fluent.isBeforeFun(ten)
}.toThrow<AssertionError> { messageToContain("$isBeforeDescr: $ten") }
fluent.toBeBeforeFun(ten)
}.toThrow<AssertionError> { messageToContain("$toBeBeforeDescr: $ten") }
}
it("$eleven throws an AssertionError") {
expect {
fluent.isBeforeFun(eleven)
}.toThrow<AssertionError> { messageToContain("$isBeforeDescr: $eleven") }
fluent.toBeBeforeFun(eleven)
}.toThrow<AssertionError> { messageToContain("$toBeBeforeDescr: $eleven") }
}
it("$twelve does not throw") {
fluent.isBeforeFun(twelve)
fluent.toBeBeforeFun(twelve)
}
}
describe("${isBeforeOrEqual.name} ...") {
val isBeforeOrEqualFun = isBeforeOrEqual.lambda
describe("${toBeBeforeOrTheSamePointInTimeAs.name} ...") {
val toBeBeforeOrTheSamePointInTimeAsFun = toBeBeforeOrTheSamePointInTimeAs.lambda
it("$ten throws an AssertionError") {
expect {
fluent.isBeforeOrEqualFun(ten)
}.toThrow<AssertionError> { messageToContain("$isBeforeOrEqualDescr: $ten") }
fluent.toBeBeforeOrTheSamePointInTimeAsFun(ten)
}.toThrow<AssertionError> { messageToContain("$toBeBeforeOrTheSamePointInTimeAsDescr: $ten") }
}
it("$eleven does not throw") {
fluent.isBeforeOrEqualFun(eleven)
fluent.toBeBeforeOrTheSamePointInTimeAsFun(eleven)
}
it("$twelve does not throw") {
fluent.isBeforeOrEqualFun(twelve)
fluent.toBeBeforeOrTheSamePointInTimeAsFun(twelve)
}
}
describe("${isAfter.name} ...") {
val isAfterFun = isAfter.lambda
describe("${toBeAfter.name} ...") {
val toBeAfterFun = toBeAfter.lambda
it("$ten does not throw") {
fluent.isAfterFun(ten)
fluent.toBeAfterFun(ten)
}
it("$eleven throws an AssertionError") {
expect {
fluent.isAfterFun(eleven)
}.toThrow<AssertionError> { messageToContain("$isAfterDescr: $eleven") }
fluent.toBeAfterFun(eleven)
}.toThrow<AssertionError> { messageToContain("$toBeAfterDescr: $eleven") }
}
it("$twelve throws an AssertionError") {
expect {
fluent.isAfterFun(twelve)
}.toThrow<AssertionError> { messageToContain("$isAfterDescr: $twelve") }
fluent.toBeAfterFun(twelve)
}.toThrow<AssertionError> { messageToContain("$toBeAfterDescr: $twelve") }
}
}
describe("${isAfterOrEqual.name} ...") {
val isAfterOrEqualFun = isAfterOrEqual.lambda
describe("${toBeAfterOrTheSamePointInTimeAs.name} ...") {
val toBeAfterOrTheSamePointInTimeAsFun = toBeAfterOrTheSamePointInTimeAs.lambda
it("$ten does not throw") {
fluent.isAfterOrEqualFun(ten)
fluent.toBeAfterOrTheSamePointInTimeAsFun(ten)
}
it("$eleven does not throw") {
fluent.isAfterOrEqualFun(eleven)
fluent.toBeAfterOrTheSamePointInTimeAsFun(eleven)
}
it("$twelve throws an AssertionError") {
expect {
fluent.isAfterOrEqualFun(twelve)
}.toThrow<AssertionError> { messageToContain("$isAfterOrEqualDescr: $twelve") }
fluent.toBeAfterOrTheSamePointInTimeAsFun(twelve)
}.toThrow<AssertionError> { messageToContain("$toBeAfterOrTheSamePointInTimeAsDescr: $twelve") }
}
}
describe("${isEqual.name} ...") {
val isEqualFun = isEqual.lambda
describe("${toBeTheSamePointInTimeAs.name} ...") {
val toBeTheSamePointInTimeAsFun = toBeTheSamePointInTimeAs.lambda
it("$ten throws an AssertionError") {
expect {
fluent.isEqualFun(ten)
}.toThrow<AssertionError> { messageToContain("$isEqualDescr: $ten") }
fluent.toBeTheSamePointInTimeAsFun(ten)
}.toThrow<AssertionError> { messageToContain("$toBeTheSamePointInTimeAsDescr: $ten") }
}
it("$eleven does not throw") {
fluent.isEqualFun(eleven)
fluent.toBeTheSamePointInTimeAsFun(eleven)
}
it("$twelve throws an AssertionError") {
expect {
fluent.isEqualFun(twelve)
}.toThrow<AssertionError> { messageToContain("$isEqualDescr: $twelve") }
fluent.toBeTheSamePointInTimeAsFun(twelve)
}.toThrow<AssertionError> { messageToContain("$toBeTheSamePointInTimeAsDescr: $twelve") }
}
}
}

View File

@@ -17,58 +17,58 @@ import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException
abstract class ChronoZonedDateTimeAsStringExpectationsSpec(
isBefore: Fun1<ChronoZonedDateTime<*>, String>,
isBeforeOrEqual: Fun1<ChronoZonedDateTime<*>, String>,
isAfter: Fun1<ChronoZonedDateTime<*>, String>,
isAfterOrEqual: Fun1<ChronoZonedDateTime<*>, String>,
isEqual: Fun1<ChronoZonedDateTime<*>, String>,
toBeBefore: Fun1<ChronoZonedDateTime<*>, String>,
toBeBeforeOrTheSamePointInTimeAs: Fun1<ChronoZonedDateTime<*>, String>,
toBeAfter: Fun1<ChronoZonedDateTime<*>, String>,
toBeAfterOrTheSamePointInTimeAs: Fun1<ChronoZonedDateTime<*>, String>,
toBeTheSamePointInTimeAs: Fun1<ChronoZonedDateTime<*>, String>,
describePrefix: String = "[Atrium] "
) : Spek({
fun isBefore(
fun toBeBefore(
expect: Expect<ChronoZonedDateTime<*>>,
expected: ChronoZonedDateTime<*>
): Expect<ChronoZonedDateTime<*>> =
expect.(isBefore.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
expect.(toBeBefore.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
fun isBeforeOrEqual(
fun toBeBeforeOrTheSamePointInTimeAs(
expect: Expect<ChronoZonedDateTime<*>>,
expected: ChronoZonedDateTime<*>
): Expect<ChronoZonedDateTime<*>> =
expect.(isBeforeOrEqual.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
expect.(toBeBeforeOrTheSamePointInTimeAs.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
fun isAfter(
fun toBeAfter(
expect: Expect<ChronoZonedDateTime<*>>,
expected: ChronoZonedDateTime<*>
): Expect<ChronoZonedDateTime<*>> =
expect.(isAfter.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
expect.(toBeAfter.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
fun isAfterOrEqual(
fun toBeAfterOrTheSamePointInTimeAs(
expect: Expect<ChronoZonedDateTime<*>>,
expected: ChronoZonedDateTime<*>
): Expect<ChronoZonedDateTime<*>> =
expect.(isAfterOrEqual.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
expect.(toBeAfterOrTheSamePointInTimeAs.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
fun isEqual(
fun toBeTheSamePointInTimeAs(
expect: Expect<ChronoZonedDateTime<*>>,
expected: ChronoZonedDateTime<*>
): Expect<ChronoZonedDateTime<*>> =
expect.(isEqual.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
expect.(toBeTheSamePointInTimeAs.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME))
include(object : ChronoZonedDateTimeExpectationsSpec(
fun1(::isBefore),
fun1(::isBeforeOrEqual),
fun1(::isAfter),
fun1(::isAfterOrEqual),
fun1(::isEqual),
fun1(::toBeBefore),
fun1(::toBeBeforeOrTheSamePointInTimeAs),
fun1(::toBeAfter),
fun1(::toBeAfterOrTheSamePointInTimeAs),
fun1(::toBeTheSamePointInTimeAs),
describePrefix
) {})
val isBeforeFun = isBefore.lambda
val isBeforeOrEqualFun = isBeforeOrEqual.lambda
val isAfterFun = isAfter.lambda
val isAfterOrEqualFun = isAfterOrEqual.lambda
val isEqualFun = isEqual.lambda
val toBeBeforeFun = toBeBefore.lambda
val toBeBeforeOrTheSamePointInTimeAsFun = toBeBeforeOrTheSamePointInTimeAs.lambda
val toBeAfterFun = toBeAfter.lambda
val toBeAfterOrTheSamePointInTimeAsFun = toBeAfterOrTheSamePointInTimeAs.lambda
val toBeTheSamePointInTimeAsFun = toBeTheSamePointInTimeAs.lambda
val subject = ZonedDateTime.now() as ChronoZonedDateTime<*>
val now = expect(subject)
@@ -94,29 +94,29 @@ abstract class ChronoZonedDateTimeAsStringExpectationsSpec(
"2020-01-02T03:04Z-05:6"
).forEach { value ->
context(value) {
it("${isBefore.name} throws a DateTimeParseException") {
it("${toBeBefore.name} throws a DateTimeParseException") {
expect {
now.isBeforeFun(value)
now.toBeBeforeFun(value)
}.toThrow<DateTimeParseException> { messageToContain("could not be parsed") }
}
it("${isBeforeOrEqual.name} throws a DateTimeParseException") {
it("${toBeBeforeOrTheSamePointInTimeAs.name} throws a DateTimeParseException") {
expect {
now.isBeforeOrEqualFun(value)
now.toBeBeforeOrTheSamePointInTimeAsFun(value)
}.toThrow<DateTimeParseException> { messageToContain("could not be parsed") }
}
it("${isAfter.name} throws a DateTimeParseException") {
it("${toBeAfter.name} throws a DateTimeParseException") {
expect {
now.isAfterFun(value)
now.toBeAfterFun(value)
}.toThrow<DateTimeParseException> { messageToContain("could not be parsed") }
}
it("isAfterOrEqual throws a DateTimeParseException") {
it("toBeAfterOrTheSamePointInTimeAs throws a DateTimeParseException") {
expect {
now.isAfterOrEqualFun(value)
now.toBeAfterOrTheSamePointInTimeAsFun(value)
}.toThrow<DateTimeParseException> { messageToContain("could not be parsed") }
}
it("${isEqual.name} throws a DateTimeParseException") {
it("${toBeTheSamePointInTimeAs.name} throws a DateTimeParseException") {
expect {
now.isEqualFun(value)
now.toBeTheSamePointInTimeAsFun(value)
}.toThrow<DateTimeParseException> { messageToContain("could not be parsed") }
}
}
@@ -147,71 +147,71 @@ abstract class ChronoZonedDateTimeAsStringExpectationsSpec(
context("passing $zonedDateTimeAsString") {
it("$before ${isBefore.name} $zonedDateTimeReferenceValue does not throw") {
expect(before).isBeforeFun(zonedDateTimeAsString)
it("$before ${toBeBefore.name} $zonedDateTimeReferenceValue does not throw") {
expect(before).toBeBeforeFun(zonedDateTimeAsString)
}
it("$chronoZonedDateTime ${isBefore.name} $zonedDateTimeReferenceValue throws an AssertionError") {
it("$chronoZonedDateTime ${toBeBefore.name} $zonedDateTimeReferenceValue throws an AssertionError") {
expect {
expect(chronoZonedDateTime).isBeforeFun(zonedDateTimeAsString)
expect(chronoZonedDateTime).toBeBeforeFun(zonedDateTimeAsString)
}.toThrow<AssertionError> { messageToContain("${IS_BEFORE.getDefault()}: $zonedDateTimeReferenceValue") }
}
it("$after ${isBefore.name} $zonedDateTimeReferenceValue throws an AssertionError") {
it("$after ${toBeBefore.name} $zonedDateTimeReferenceValue throws an AssertionError") {
expect {
expect(after).isBeforeFun(zonedDateTimeAsString)
expect(after).toBeBeforeFun(zonedDateTimeAsString)
}.toThrow<AssertionError> { messageToContain("${IS_BEFORE.getDefault()}: $zonedDateTimeReferenceValue") }
}
it("$before ${isBeforeOrEqual.name} $zonedDateTimeReferenceValue does not throw") {
expect(before).isBeforeOrEqualFun(zonedDateTimeAsString)
it("$before ${toBeBeforeOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") {
expect(before).toBeBeforeOrTheSamePointInTimeAsFun(zonedDateTimeAsString)
}
it("$chronoZonedDateTime ${isBeforeOrEqual.name} $zonedDateTimeReferenceValue does not throw") {
expect(chronoZonedDateTime).isBeforeOrEqualFun(zonedDateTimeAsString)
it("$chronoZonedDateTime ${toBeBeforeOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") {
expect(chronoZonedDateTime).toBeBeforeOrTheSamePointInTimeAsFun(zonedDateTimeAsString)
}
it("$after ${isBeforeOrEqual.name} $zonedDateTimeReferenceValue throws an AssertionError") {
it("$after ${toBeBeforeOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue throws an AssertionError") {
expect {
expect(after).isBeforeOrEqualFun(zonedDateTimeAsString)
expect(after).toBeBeforeOrTheSamePointInTimeAsFun(zonedDateTimeAsString)
}.toThrow<AssertionError> {
messageToContain("${IS_BEFORE_OR_EQUAL.getDefault()}: $zonedDateTimeReferenceValue")
}
}
it("$before ${isAfter.name} $zonedDateTimeReferenceValue throws an AssertionError") {
it("$before ${toBeAfter.name} $zonedDateTimeReferenceValue throws an AssertionError") {
expect {
expect(before).isAfterFun(zonedDateTimeAsString)
expect(before).toBeAfterFun(zonedDateTimeAsString)
}.toThrow<AssertionError> { messageToContain("${IS_AFTER.getDefault()}: $zonedDateTimeReferenceValue") }
}
it("$chronoZonedDateTime ${isAfter.name} $zonedDateTimeReferenceValue throws an AssertionError") {
it("$chronoZonedDateTime ${toBeAfter.name} $zonedDateTimeReferenceValue throws an AssertionError") {
expect {
expect(chronoZonedDateTime).isAfterFun(zonedDateTimeAsString)
expect(chronoZonedDateTime).toBeAfterFun(zonedDateTimeAsString)
}.toThrow<AssertionError> { messageToContain("${IS_AFTER.getDefault()}: $zonedDateTimeReferenceValue") }
}
it("$after ${isAfter.name} $zonedDateTimeAsString does not throw") {
expect(after).isAfterFun(zonedDateTimeAsString)
it("$after ${toBeAfter.name} $zonedDateTimeAsString does not throw") {
expect(after).toBeAfterFun(zonedDateTimeAsString)
}
it("$before ${isAfterOrEqual.name} $zonedDateTimeReferenceValue throws an AssertionError") {
it("$before ${toBeAfterOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue throws an AssertionError") {
expect {
expect(before).isAfterOrEqualFun(zonedDateTimeAsString)
expect(before).toBeAfterOrTheSamePointInTimeAsFun(zonedDateTimeAsString)
}.toThrow<AssertionError> { messageToContain("${IS_AFTER_OR_EQUAL.getDefault()}: $zonedDateTimeReferenceValue") }
}
it("$chronoZonedDateTime ${isAfterOrEqual.name} $zonedDateTimeReferenceValue does not throw") {
expect(chronoZonedDateTime).isAfterOrEqualFun(zonedDateTimeAsString)
it("$chronoZonedDateTime ${toBeAfterOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") {
expect(chronoZonedDateTime).toBeAfterOrTheSamePointInTimeAsFun(zonedDateTimeAsString)
}
it("$after ${isAfterOrEqual.name} $zonedDateTimeReferenceValue does not throw") {
expect(after).isAfterOrEqualFun(zonedDateTimeAsString)
it("$after ${toBeAfterOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") {
expect(after).toBeAfterOrTheSamePointInTimeAsFun(zonedDateTimeAsString)
}
it("$before ${isEqual.name} $zonedDateTimeReferenceValue throws an AssertionError") {
it("$before ${toBeTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue throws an AssertionError") {
expect {
expect(before).isEqualFun(zonedDateTimeAsString)
expect(before).toBeTheSamePointInTimeAsFun(zonedDateTimeAsString)
}.toThrow<AssertionError> { messageToContain("${IS_EQUAL_TO.getDefault()}: $zonedDateTimeReferenceValue") }
}
it("$chronoZonedDateTime ${isEqual.name} $zonedDateTimeReferenceValue does not throw") {
expect(chronoZonedDateTime).isEqualFun(zonedDateTimeAsString)
it("$chronoZonedDateTime ${toBeTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") {
expect(chronoZonedDateTime).toBeTheSamePointInTimeAsFun(zonedDateTimeAsString)
}
it("$after ${isEqual.name} $zonedDateTimeReferenceValue throws an AssertionError") {
it("$after ${toBeTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue throws an AssertionError") {
expect {
expect(after).isEqualFun(zonedDateTimeAsString)
expect(after).toBeTheSamePointInTimeAsFun(zonedDateTimeAsString)
}.toThrow<AssertionError> { messageToContain("${IS_EQUAL_TO.getDefault()}: $zonedDateTimeReferenceValue") }
}
}