@@ -32,7 +32,6 @@ import io.kotest.property.arbitrary.enum
32
32
import io.kotest.property.arbitrary.int
33
33
import io.kotest.property.arbitrary.of
34
34
import io.kotest.property.arbitrary.orNull
35
- import kotlin.random.nextInt
36
35
import org.threeten.bp.Instant
37
36
import org.threeten.bp.OffsetDateTime
38
37
import org.threeten.bp.ZoneOffset
@@ -154,7 +153,11 @@ private fun Instant.toFdcFieldRegex(): Regex {
154
153
return Regex (pattern)
155
154
}
156
155
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
+ )
158
161
159
162
sealed interface TimeOffset {
160
163
@@ -242,6 +245,16 @@ object JavaTimeArbs {
242
245
)
243
246
.toInstant()
244
247
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
+
245
258
val string = buildString {
246
259
append(year)
247
260
append(' -' )
@@ -350,15 +363,11 @@ object JavaTimeArbs {
350
363
" $nanosecondsInt (digitCounts=$digitCounts )"
351
364
}
352
365
353
- Nanoseconds (nanosecondsInt, nanosecondsString)
366
+ Nanoseconds (nanosecondsInt, nanosecondsString, digitCounts )
354
367
}
355
368
}
356
369
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 )
362
371
363
372
private fun nanosecondComponents (): Arb <NanosecondComponents > =
364
373
arbitrary(
0 commit comments