Created
October 15, 2014 01:39
-
-
Save labra/2c16ad44ac484d0271d6 to your computer and use it in GitHub Desktop.
Ejercicio Scala calcular factorial - ScalaTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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