If you filter the generator (for example, using suchThat ), the generator can generate a large number of values ββthat do not satisfy your suchThat restriction, and therefore discard them. I came across this when limiting the length of strings. One of the suggestions that I can give you is to try to create your Gen in a different way, in which you do not drop so many of them.
For example, here is what I meant to generate 4-character strings:
val gen4CharString = Gen.listOfN(4, (Gen.listOfN[Char] suchThat (s => s != "" && s.length == 4)))
This caused too many generated values ββthat were discarded, resulting in an error similar to the one you saw. Changing the generator, as shown below, fixed the problem.
val gen4CharString = Gen.listOfN[Char] (4, Gen.alphaChar).map (_.mkString)
Ram rajamony
source share