1
exercism fetch scala prime-factors

src/test/scala/PrimefactorsTest.scala

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import org.scalatest.{Matchers, FunSuite}

/** @version 1.0.0 */
class PrimeFactorsTest extends FunSuite with Matchers {

  test("no factors") {
    PrimeFactors.factors(1) should be (List())
  }

  test("prime number") {
    pending
    PrimeFactors.factors(2) should be (List(2))
  }

  test("square of a prime") {
    pending
    PrimeFactors.factors(9) should be (List(3, 3))
  }

  test("cube of a prime") {
    pending
    PrimeFactors.factors(8) should be (List(2, 2, 2))
  }

  test("product of primes and non-primes") {
    pending
    PrimeFactors.factors(12) should be (List(2, 2, 3))
  }

  test("product of primes") {
    pending
    PrimeFactors.factors(901255) should be (List(5, 17, 23, 461))
  }

  test("factors include a large prime") {
    pending
    PrimeFactors.factors(93819012551l) should be (List(11, 9539, 894119))
  }
}