Skip to content

Commit 5ee5bfd

Browse files
authored
Merge branch 'main' into dconeybe/dataconnect/ProtoStructListValueArbRefactor
2 parents a4b26dd + a9f0d20 commit 5ee5bfd

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

firebase-dataconnect/src/test/kotlin/com/google/firebase/dataconnect/core/DataConnectOperationFailureResponseImplUnitTest.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ import kotlinx.coroutines.test.runTest
5151
import org.junit.Test
5252

5353
private val propTestConfig =
54-
PropTestConfig(iterations = 20, edgeConfig = EdgeConfig(edgecasesGenerationProbability = 0.25))
54+
PropTestConfig(
55+
iterations = 20,
56+
edgeConfig = EdgeConfig(edgecasesGenerationProbability = 0.25),
57+
maxDiscardPercentage = 80,
58+
)
5559

5660
/** Unit tests for [DataConnectOperationFailureResponseImpl] */
5761
class DataConnectOperationFailureResponseImplUnitTest {

firebase-dataconnect/testutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/RandomSeedTestRule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class RandomSeedTestRule(val rs: Lazy<RandomSource>) : TestRule {
3636
result.onFailure {
3737
if (rs.isInitialized()) {
3838
println(
39-
"55negqf33k Test ${description.displayName} failed using " +
40-
"RandomSource with seed=${rs.value.seed}"
39+
"WARNING[55negqf33k]: RandomSeedTestRule: Test failed using " +
40+
"RandomSource with seed=${rs.value.seed}: ${description.displayName}"
4141
)
4242
}
4343
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ package com.google.firebase.dataconnect.testutil.property.arbitrary
1818

1919
import com.google.firebase.dataconnect.testutil.withNullAppended
2020
import io.kotest.property.Arb
21-
import io.kotest.property.EdgeConfig
2221
import io.kotest.property.Exhaustive
23-
import io.kotest.property.PropertyContext
24-
import io.kotest.property.Sample
2522
import io.kotest.property.arbitrary.arbitrary
2623
import io.kotest.property.arbitrary.filterNot
2724
import io.kotest.property.arbitrary.flatMap
@@ -89,11 +86,6 @@ private fun pow10(n: Int): Int {
8986
return result
9087
}
9188

92-
fun <T> PropertyContext.sampleFromArb(arb: Arb<T>, edgeCaseProbability: Double): Sample<T> {
93-
val edgeConfig = EdgeConfig(edgecasesGenerationProbability = edgeCaseProbability)
94-
return arb.generate(randomSource(), edgeConfig).first()
95-
}
96-
9789
/**
9890
* Creates and returns a new [Exhaustive] whose values are all of the values of [T] and also `null`.
9991
*/

firebase-dataconnect/testutil/src/test/kotlin/com/google/firebase/dataconnect/testutil/ListContainingNullUnitTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.google.firebase.dataconnect.testutil
1818

1919
import com.google.firebase.dataconnect.testutil.property.arbitrary.listContainingNull
20-
import com.google.firebase.dataconnect.testutil.property.arbitrary.sampleFromArb
20+
import com.google.firebase.dataconnect.testutil.property.arbitrary.next
2121
import io.kotest.assertions.asClue
2222
import io.kotest.assertions.assertSoftly
2323
import io.kotest.assertions.withClue
@@ -40,8 +40,8 @@ class ListContainingNullUnitTest {
4040
fun `listContainingNull generates values with lengths in the given range`() = runTest {
4141
checkAll(NUM_ITERATIONS, listLengthsArb) { lengthRange ->
4242
val arb = Arb.listContainingNull(valuesGen, lengthRange)
43-
val sample = sampleFromArb(arb, edgeCaseProbability = 0.5)
44-
sample.value.asClue {
43+
val value = arb.next(randomSource(), edgeCaseProbability = 0.5f)
44+
value.asClue {
4545
assertSoftly {
4646
it.size shouldBeGreaterThanOrEqual lengthRange.first
4747
it.size shouldBeLessThanOrEqual lengthRange.last
@@ -54,8 +54,8 @@ class ListContainingNullUnitTest {
5454
fun `listContainingNull generates values from the given arb`() = runTest {
5555
checkAll(NUM_ITERATIONS, listLengthsArb) { lengthRange ->
5656
val arb = Arb.listContainingNull(valuesGen, lengthRange)
57-
val sample = sampleFromArb(arb, edgeCaseProbability = 0.5)
58-
sample.value.asClue {
57+
val value = arb.next(randomSource(), edgeCaseProbability = 0.5f)
58+
value.asClue {
5959
assertSoftly {
6060
it.forEachIndexed { index, value ->
6161
if (value !== null) {
@@ -71,8 +71,8 @@ class ListContainingNullUnitTest {
7171
fun `listContainingNull generates lists that always contain null`() = runTest {
7272
checkAll(NUM_ITERATIONS, listLengthsArb) { lengthRange ->
7373
val arb = Arb.listContainingNull(valuesGen, lengthRange)
74-
val sample = sampleFromArb(arb, edgeCaseProbability = 0.5)
75-
sample.value.asClue { it shouldContain null }
74+
val value = arb.next(randomSource(), edgeCaseProbability = 0.5f)
75+
value.asClue { it shouldContain null }
7676
}
7777
}
7878

0 commit comments

Comments
 (0)