Skip to content

Instantly share code, notes, and snippets.

@labra
Created October 15, 2014 01:39
Show Gist options
  • Save labra/2c16ad44ac484d0271d6 to your computer and use it in GitHub Desktop.
Save labra/2c16ad44ac484d0271d6 to your computer and use it in GitHub Desktop.
Ejercicio Scala calcular factorial - ScalaTest
package es.poo
import org.scalatest._
import Matchers._
class FactSpec extends FunSpec with Matchers {
describe("Fact") {
val valores = Map(
0 -> 1,
1 -> 1,
2 -> 2,
3 -> 6,
4 -> 24,
5 -> 120
)
valores.foreach{ case (n,esperado) =>
it(s"debe detectar que factorial de ${n} es ${esperado}") {
Fact.factorial(n) should be (esperado)
}
}
it("debe lanzar excepcion con factorial de numero negativo") {
an [Exception] should be thrownBy Fact.factorial(-2)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment