@@ -24,6 +24,7 @@ import com.google.firebase.dataconnect.testutil.property.arbitrary.JavaTimeEdgeC
24
24
import com.google.firebase.dataconnect.testutil.property.arbitrary.JavaTimeEdgeCases.MIN_NANO
25
25
import com.google.firebase.dataconnect.testutil.property.arbitrary.JavaTimeEdgeCases.MIN_YEAR
26
26
import com.google.firebase.dataconnect.testutil.toTimestamp
27
+ import io.kotest.common.mapError
27
28
import io.kotest.property.Arb
28
29
import io.kotest.property.arbitrary.arbitrary
29
30
import io.kotest.property.arbitrary.choice
@@ -316,8 +317,12 @@ object JavaTimeArbs {
316
317
repeat(digitCounts.leadingZeroes) { append(' 0' ) }
317
318
if (digitCounts.proper > 0 ) {
318
319
append(nonZeroDigits.bind())
319
- repeat(digitCounts.proper - 2 ) { append(digits.bind()) }
320
- append(nonZeroDigits.bind())
320
+ if (digitCounts.proper > 1 ) {
321
+ if (digitCounts.proper > 2 ) {
322
+ repeat(digitCounts.proper - 2 ) { append(digits.bind()) }
323
+ }
324
+ append(nonZeroDigits.bind())
325
+ }
321
326
}
322
327
repeat(digitCounts.trailingZeroes) { append(' 0' ) }
323
328
}
@@ -327,9 +332,24 @@ object JavaTimeArbs {
327
332
if (nanosecondsStringTrimmed.isEmpty()) {
328
333
0
329
334
} else {
330
- nanosecondsStringTrimmed.toInt()
335
+ val toIntResult = nanosecondsStringTrimmed.runCatching { toInt() }
336
+ toIntResult.mapError { exception ->
337
+ Exception (
338
+ " internal error qbdgapmye2: " +
339
+ " failed to parse nanosecondsStringTrimmed as an int: " +
340
+ " \" $nanosecondsStringTrimmed \" (digitCounts=$digitCounts )" ,
341
+ exception
342
+ )
343
+ }
344
+ toIntResult.getOrThrow()
331
345
}
332
346
347
+ check(nanosecondsInt in 0 .. 999_999_999 ) {
348
+ " internal error c7j2myw6bd: " +
349
+ " nanosecondsStringTrimmed parsed to a value outside the valid range: " +
350
+ " $nanosecondsInt (digitCounts=$digitCounts )"
351
+ }
352
+
333
353
Nanoseconds (nanosecondsInt, nanosecondsString)
334
354
}
335
355
}
0 commit comments