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

Commit

Permalink
Adding subsetOf scalacheck test.
Browse files Browse the repository at this point in the history
  • Loading branch information
msteindorfer committed Feb 3, 2018
1 parent 0b22e48 commit 7000f5a
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,18 @@ object ImmutableChampHashSetProperties extends Properties("immutable.ChampHashSe
xs == ys
}

property("smaller subsetOf larger") = forAll { (inputSet: ChampHashSet[K]) =>
if (inputSet.isEmpty) {
true
} else {
val randomSamples = scala.util.Random.nextInt(inputSet.size)
val randomIndices = ImmutableArray.fill(randomSamples)(scala.util.Random.nextInt(inputSet.size))

val inputArray = inputSet.toArray
val smallerSet = ChampHashSet.from(randomIndices.map(inputArray).toSet)

smallerSet.subsetOf(inputSet)
}
}

}

0 comments on commit 7000f5a

Please sign in to comment.