1
exercism fetch scala sgf-parsing

src/test/scala/SgfTest.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
58
59
60
61
62
63
64
65
66
67
68
import org.scalatest.{FunSuite, Matchers}
import Sgf._

/** @version created manually **/
class SgfTest extends FunSuite with Matchers {
  test("parse \"\"") {
    Sgf.parseSgf("") should be (None)
  }

  test("parse \"()\"") {
    pending
    Sgf.parseSgf("()") should be (None)
  }

  test("parse \";\"") {
    pending
    Sgf.parseSgf(";") should be (None)
  }

  test("parse \"(;)\"") {
    pending
    Sgf.parseSgf("(;)") should be (Some(Node(Map())))
  }

  test("parse \"(;A[B])\"") {
    pending
    Sgf.parseSgf("(;A[B])") should be (Some(Node(Map("A" -> List("B")))))
  }

  test("parse \"(;a)\"") {
    pending
    Sgf.parseSgf("(;a)") should be (None)
  }

  test("parse \"(;a[b])\"") {
    pending
    Sgf.parseSgf("(;a[b])") should be (None)
  }

  test("parse \"(;Aa[b])\"") {
    pending
    Sgf.parseSgf("(;Aa[b])") should be (None)
  }

  test("parse \"(;A[B];B[C])\"") {
    pending
    Sgf.parseSgf("(;A[B];B[C])") should be (
        Some(Node(Map("A" -> List("B")), List(Node(Map("B" -> List("C")))))))
  }

  test("parse \"(;A[B](;B[C])(;C[D]))\"") {
    pending
    Sgf.parseSgf("(;A[B](;B[C])(;C[D]))") should be (
        Some(Node(Map("A" -> List("B")), List(Node(Map("B" -> List("C"))),
                                              Node(Map("C" -> List("D")))))))
  }

  test("parse \"(;A[b][c][d])\"") {
    pending
    Sgf.parseSgf("(;A[b][c][d])") should be (Some(Node(Map("A" -> List("b", "c", "d")))))
  }

  test("""parse "(;A[\\]b\nc\\\nd\t\te\\\\ \\\n\\]])"""") {
    pending
    Sgf.parseSgf("(;A[\\]b\nc\\\nd\t\te\\\\ \\\n\\]])") should be (
        Some(Node(Map("A" -> List("]b cd  e\\ ]")))))
  }
}