Skip to content

Commit

Permalink
Adds failure test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedquinn committed Feb 20, 2025
1 parent ef48c4a commit 9933104
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class IntervalMinusTests {
@Execution(ExecutionMode.CONCURRENT)
fun timeMinusInterval(tc: SuccessTestCase) = tc.run()

@ParameterizedTest
@MethodSource("timeMinusIntervalFailureCases")
@Execution(ExecutionMode.CONCURRENT)
fun timeMinusIntervalFailure(tc: FailureTestCase) = tc.run()

@ParameterizedTest
@MethodSource("intervalMinusTimeZCases")
@Execution(ExecutionMode.CONCURRENT)
Expand Down Expand Up @@ -142,6 +147,26 @@ class IntervalMinusTests {
SuccessTestCase("${case.arg0} - ${case.arg1}", case.expected)
}

/**
* These _may_ actually be okay, but for now, we will mark these as unsupported. These fail (for now)!
* I'm not entirely sure if it makes sense to subtract a year/month from a time.
*/
@JvmStatic
fun timeMinusIntervalFailureCases() = listOf(
FailureTestCase("$TIME - $INTERVAL_Y"),
FailureTestCase("$TIME - $INTERVAL_M"),
FailureTestCase("$TIME - $INTERVAL_YM"),
FailureTestCase("$TIME_Z - $INTERVAL_Y"),
FailureTestCase("$TIME_Z - $INTERVAL_M"),
FailureTestCase("$TIME_Z - $INTERVAL_YM"),
FailureTestCase("$INTERVAL_Y - $TIME"),
FailureTestCase("$INTERVAL_Y - $TIME_Z"),
FailureTestCase("$INTERVAL_M - $TIME"),
FailureTestCase("$INTERVAL_M - $TIME_Z"),
FailureTestCase("$INTERVAL_YM - $TIME"),
FailureTestCase("$INTERVAL_YM - $TIME_Z"),
)

@JvmStatic
fun intervalMinusTimeZCases() = listOf(
Input(TIME_Z, INTERVAL_D, OffsetTime.of(1, 1, 1, NANO, OFFSET)), // Should this work?
Expand All @@ -160,6 +185,9 @@ class IntervalMinusTests {

@JvmStatic
fun intervalMinusTimestampCases() = listOf(
Input(TIMESTAMP, INTERVAL_Y, LocalDateTime.of(2024, 1, 1, 1, 1, 1, NANO)),
Input(TIMESTAMP, INTERVAL_M, LocalDateTime.of(2024, 12, 1, 1, 1, 1, NANO)),
Input(TIMESTAMP, INTERVAL_YM, LocalDateTime.of(2023, 12, 1, 1, 1, 1, NANO)),
Input(TIMESTAMP, INTERVAL_D, LocalDateTime.of(2024, 12, 31, 1, 1, 1, NANO)),
Input(TIMESTAMP, INTERVAL_H, LocalDateTime.of(2025, 1, 1, 0, 1, 1, NANO)),
Input(TIMESTAMP, INTERVAL_MIN, LocalDateTime.of(2025, 1, 1, 1, 0, 1, NANO)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class IntervalPlusTests {
@Execution(ExecutionMode.CONCURRENT)
fun intervalPlusTime(tc: SuccessTestCase) = tc.run()

@ParameterizedTest
@MethodSource("timePlusIntervalFailureCases")
@Execution(ExecutionMode.CONCURRENT)
fun intervalPlusTimeFailure(tc: FailureTestCase) = tc.run()

@ParameterizedTest
@MethodSource("intervalPlusTimeZCases")
@Execution(ExecutionMode.CONCURRENT)
Expand Down Expand Up @@ -131,6 +136,26 @@ class IntervalPlusTests {
)
}

/**
* These _may_ actually be okay, but for now, we will mark these as unsupported. These fail (for now)!
* I'm not entirely sure if it makes sense to add a year/month from a time.
*/
@JvmStatic
fun timePlusIntervalFailureCases() = listOf(
FailureTestCase("$TIME + $INTERVAL_Y"),
FailureTestCase("$TIME + $INTERVAL_M"),
FailureTestCase("$TIME + $INTERVAL_YM"),
FailureTestCase("$TIME_Z + $INTERVAL_Y"),
FailureTestCase("$TIME_Z + $INTERVAL_M"),
FailureTestCase("$TIME_Z + $INTERVAL_YM"),
FailureTestCase("$INTERVAL_Y + $TIME"),
FailureTestCase("$INTERVAL_Y + $TIME_Z"),
FailureTestCase("$INTERVAL_M + $TIME"),
FailureTestCase("$INTERVAL_M + $TIME_Z"),
FailureTestCase("$INTERVAL_YM + $TIME"),
FailureTestCase("$INTERVAL_YM + $TIME_Z"),
)

@JvmStatic
fun intervalPlusTimeZCases() = listOf(
Input(INTERVAL_D, TIME_Z, OffsetTime.of(1, 1, 1, NANO, OFFSET)), // Should this work?
Expand All @@ -152,6 +177,9 @@ class IntervalPlusTests {

@JvmStatic
fun intervalPlusTimestampCases() = listOf(
Input(INTERVAL_Y, TIMESTAMP, LocalDateTime.of(2026, 1, 1, 1, 1, 1, NANO)),
Input(INTERVAL_M, TIMESTAMP, LocalDateTime.of(2025, 2, 1, 1, 1, 1, NANO)),
Input(INTERVAL_YM, TIMESTAMP, LocalDateTime.of(2026, 2, 1, 1, 1, 1, NANO)),
Input(INTERVAL_D, TIMESTAMP, LocalDateTime.of(2025, 1, 2, 1, 1, 1, NANO)),
Input(INTERVAL_H, TIMESTAMP, LocalDateTime.of(2025, 1, 1, 2, 1, 1, NANO)),
Input(INTERVAL_MIN, TIMESTAMP, LocalDateTime.of(2025, 1, 1, 1, 2, 1, NANO)),
Expand Down

0 comments on commit 9933104

Please sign in to comment.