@@ -32,7 +32,6 @@ import io.kotest.property.arbitrary.enum
3232import io.kotest.property.arbitrary.int
3333import io.kotest.property.arbitrary.of
3434import io.kotest.property.arbitrary.orNull
35- import kotlin.random.nextInt
3635import org.threeten.bp.Instant
3736import org.threeten.bp.OffsetDateTime
3837import org.threeten.bp.ZoneOffset
@@ -154,7 +153,11 @@ private fun Instant.toFdcFieldRegex(): Regex {
154153 return Regex (pattern)
155154}
156155
157- data class Nanoseconds (val nanoseconds : Int , val string : String )
156+ data class Nanoseconds (
157+ val nanoseconds : Int ,
158+ val string : String ,
159+ val digitCounts : JavaTimeArbs .NanosecondComponents
160+ )
158161
159162sealed interface TimeOffset {
160163
@@ -242,6 +245,16 @@ object JavaTimeArbs {
242245 )
243246 .toInstant()
244247
248+ // The valid range below was copied from:
249+ // com.google.firebase.Timestamp.Timestamp.validateRange()
250+ require(instant.epochSecond in - 62_135_596_800 until 253_402_300_800 ) {
251+ " internal error weppxzqj2y: " +
252+ " instant.epochSecond out of range: ${instant.epochSecond} (" +
253+ " year=$year , month=$month , day=$day , " +
254+ " hour=$hour , minute=$minute , second=$second , " +
255+ " nanosecond=$nanosecond timeOffset=$timeOffset )"
256+ }
257+
245258 val string = buildString {
246259 append(year)
247260 append(' -' )
@@ -350,15 +363,11 @@ object JavaTimeArbs {
350363 " $nanosecondsInt (digitCounts=$digitCounts )"
351364 }
352365
353- Nanoseconds (nanosecondsInt, nanosecondsString)
366+ Nanoseconds (nanosecondsInt, nanosecondsString, digitCounts )
354367 }
355368 }
356369
357- private data class NanosecondComponents (
358- val leadingZeroes : Int ,
359- val proper : Int ,
360- val trailingZeroes : Int
361- )
370+ data class NanosecondComponents (val leadingZeroes : Int , val proper : Int , val trailingZeroes : Int )
362371
363372 private fun nanosecondComponents (): Arb <NanosecondComponents > =
364373 arbitrary(
0 commit comments