Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FizzBuzz spec using ScalaCheck
package org.scalabound.scatdd.scalacheck
import org.scalabound.scatdd.FizzBuzz
import org.scalacheck.ConsoleReporter.testReport
import org.scalacheck.Prop.forAll
import org.scalacheck.Prop.propBoolean
import org.scalacheck.ConsoleReporter
import org.scalacheck.Test
object FizzBuzzScalaCheck {
val propFizzBuzzCheck = forAll { n: Int =>{
if(n % 15 == 0) FizzBuzz.eval(n) == "FizzBuzz"
else if(n % 3 ==0) FizzBuzz.eval(n) == "Fizz"
else if(n % 5 ==0) FizzBuzz.eval(n) == "Buzz"
else "" + n == FizzBuzz.eval(n)
}
}
def main(args : Array[String] ) = {
ConsoleReporter.testStatsEx("blah", testReport(Test.check(propFizzBuzzCheck)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.