Is it possible to lift custom generating function into Gen
?
For example, generating ObjectId
s for mongo.
import org.mongodb.scala.bson.ObjectId
import org.scalacheck.Gen
val genObjectId: Gen[ObjectId] = Gen.lift(() => new ObjectId)
The only possible solution I've found is to hack the generator like:
val genObjectId: Gen[ObjectId] = Gen.numChar.map(_ => new ObjectId)
Generating ObjectId
s using Gen.hexChar
is irrelevant because:
- I need unique value each time
- Mongo could treat some of the generated hex strings as invalid
Aucun commentaire:
Enregistrer un commentaire