Skip to content

Commit 9f4003e

Browse files
committed
proto.kt: add structKeyEdgeCaseProbability to ListValueArb
1 parent fe40ebb commit 9f4003e

File tree

1 file changed

+7
-1
lines changed
  • firebase-dataconnect/testutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/property/arbitrary

1 file changed

+7
-1
lines changed

firebase-dataconnect/testutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/property/arbitrary/proto.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ private class ListValueArb(
450450
path = emptyList(),
451451
depth = depthArb.next(rs, edgeCaseProbability = rs.random.nextFloat()),
452452
sizeEdgeCaseProbability = rs.random.nextFloat(),
453+
structKeyEdgeCaseProbability = rs.random.nextFloat(),
453454
valueEdgeCaseProbability = rs.random.nextFloat(),
454455
nestedProbability = rs.random.nextFloat(),
455456
)
@@ -461,6 +462,7 @@ private class ListValueArb(
461462
path: ProtoValuePath,
462463
depth: Int,
463464
sizeEdgeCaseProbability: Float,
465+
structKeyEdgeCaseProbability: Float,
464466
valueEdgeCaseProbability: Float,
465467
nestedProbability: Float,
466468
): ProtoArb.ListValueInfo {
@@ -473,7 +475,7 @@ private class ListValueArb(
473475
path = curPath,
474476
depth = depth,
475477
sizeEdgeCaseProbability = sizeEdgeCaseProbability,
476-
structKeyEdgeCaseProbability = 0.33f,
478+
structKeyEdgeCaseProbability = structKeyEdgeCaseProbability,
477479
valueEdgeCaseProbability = valueEdgeCaseProbability,
478480
nestedProbability = nestedProbability,
479481
)
@@ -514,13 +516,15 @@ private class ListValueArb(
514516
val edgeCases = rs.nextEdgeCases()
515517
val sizeEdgeCaseProbability = if (edgeCases.contains(EdgeCase.Size)) 1.0f else 0.0f
516518
val depthEdgeCaseProbability = if (edgeCases.contains(EdgeCase.Depth)) 1.0f else 0.0f
519+
val structKeyEdgeCaseProbability = if (edgeCases.contains(EdgeCase.StructKey)) 1.0f else 0.0f
517520
val valueEdgeCaseProbability = if (edgeCases.contains(EdgeCase.Values)) 1.0f else 0.0f
518521
val nestedProbability = if (edgeCases.contains(EdgeCase.OnlyNested)) 1.0f else 0.0f
519522
return sample(
520523
rs,
521524
path = emptyList(),
522525
depth = depthArb.next(rs, depthEdgeCaseProbability),
523526
sizeEdgeCaseProbability = sizeEdgeCaseProbability,
527+
structKeyEdgeCaseProbability = structKeyEdgeCaseProbability,
524528
valueEdgeCaseProbability = valueEdgeCaseProbability,
525529
nestedProbability = nestedProbability,
526530
)
@@ -529,6 +533,7 @@ private class ListValueArb(
529533
private enum class EdgeCase {
530534
Size,
531535
Depth,
536+
StructKey,
532537
Values,
533538
OnlyNested,
534539
}
@@ -611,6 +616,7 @@ private fun RandomSource.nextNestedValue(
611616
path = path,
612617
depth = depth,
613618
sizeEdgeCaseProbability = sizeEdgeCaseProbability,
619+
structKeyEdgeCaseProbability = structKeyEdgeCaseProbability,
614620
valueEdgeCaseProbability = valueEdgeCaseProbability,
615621
nestedProbability = nestedProbability,
616622
)

0 commit comments

Comments
 (0)