1
exercism fetch scala matrix

src/test/scala/MatrixTest.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import org.scalatest.{Matchers, FunSuite}

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

  test("extract row from one number matrix") {
    Matrix("1").row(0) should be(Vector(1))
  }

  test("can extract row") {
    pending
    Matrix("1 2\n" +
           "3 4").row(1) should be(Vector(3, 4))
  }

  test("extract row where numbers have different widths") {
    pending
    Matrix("1 2\n" +
           "10 20").row(1) should be(Vector(10, 20))
  }

  test("can extract row from non-square matrix") {
    pending
    Matrix("1 2 3\n"
         + "4 5 6\n"
         + "7 8 9\n"
         + "8 7 6").row(2) should be(
      Vector(7, 8, 9))
  }

  test("extract column from one number matrix") {
    pending
    Matrix("1").column(0) should be(Vector(1))
  }

  test("can extract column") {
    pending
    Matrix("1 2 3\n"
         + "4 5 6\n"
         + "7 8 9").column(2) should be(Vector(3, 6, 9))
  }

  test("can extract column from non-square matrix") {
    pending
    Matrix("1 2 3\n"
         + "4 5 6\n"
         + "7 8 9\n"
         + "8 7 6").column(2) should be(Vector(3, 6, 9, 6))
  }

  test("extract column where numbers have different widths") {
    pending
    Matrix("89 1903 3\n"
         + "18 3 1\n"
         + "9 4 800").column(1) should be(Vector(1903, 3, 4))
  }
}