Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit 7000f5a

Browse files
committed
Adding subsetOf scalacheck test.
1 parent 0b22e48 commit 7000f5a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/scalacheck/src/test/scala/strawman/collection/immutable/ImmutableChampHashSetProperties.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,18 @@ object ImmutableChampHashSetProperties extends Properties("immutable.ChampHashSe
218218
xs == ys
219219
}
220220

221+
property("smaller subsetOf larger") = forAll { (inputSet: ChampHashSet[K]) =>
222+
if (inputSet.isEmpty) {
223+
true
224+
} else {
225+
val randomSamples = scala.util.Random.nextInt(inputSet.size)
226+
val randomIndices = ImmutableArray.fill(randomSamples)(scala.util.Random.nextInt(inputSet.size))
227+
228+
val inputArray = inputSet.toArray
229+
val smallerSet = ChampHashSet.from(randomIndices.map(inputArray).toSet)
230+
231+
smallerSet.subsetOf(inputSet)
232+
}
233+
}
234+
221235
}

0 commit comments

Comments
 (0)