2014-11-07 11 views

risposta

10

codice esempio:

import org.scalacheck.Gen 
import org.scalacheck.Prop.forAll  

// strGen generates a fixed length random string 
val strGen = (n: Int) => Gen.listOfN(n, Gen.alphaChar).map(_.mkString) 

val fixedLengthStr = forAll(strGen(10)){ s => 
    s.length == 10 
} 

fixedLengthStr.check 

ispezionare un uso stringa generata:

strGen(5).sample