aboutsummaryrefslogtreecommitdiff
path: root/yamlesque/test/src/StreamTest.scala
blob: e739d650c07c67fccd702f284338f42409abcd74 (plain) (blame)
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
package yamlesque

import utest._
import java.io.StringReader

// test multiple documents
object StreamTest extends TestSuite {
  def tests = Tests {
    "empty doc" - {
      readAll("") ==> Null :: Nil
    }
    "empty doc, start only" - {
      // first --- is optional
      readAll("---") ==> Null :: Nil
    }
    "empty docs" - {
      readAll("---\n---") ==> Null :: Null :: Nil
      readAll("---\n---\n---") ==> Null :: Null :: Null :: Nil
    }
    "empty and non-empty docs" - {
      val s = """|---
                 |a
                 |---
                """.stripMargin
      readAll(s) ==> Str("a") :: Null :: Nil
    }
    "non-empty doc, implicit start" - {
      val s = """|a
                 |""".stripMargin
      readAll(s) ==> Str("a") :: Nil
    }
    "non-empty doc, explicit start" - {
      val s = """|---
                 |a
                 |""".stripMargin
      readAll(s) ==> Str("a") :: Nil
    }
    "non-empty docs, implicit start" - {
      val s = """|a
                 |---
                 |b
                """.stripMargin
      readAll(s) ==> Str("a") :: Str("b") :: Nil
    }
    "non-empty docs, explicit start" - {
      val s = """|---
                 |a
                 |---
                 |b
                """.stripMargin
      readAll(s) ==> Str("a") :: Str("b") :: Nil
    }
  }
}