diff options
Diffstat (limited to 'yamlesque/test/src/StreamTest.scala')
-rw-r--r-- | yamlesque/test/src/StreamTest.scala | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/yamlesque/test/src/StreamTest.scala b/yamlesque/test/src/StreamTest.scala new file mode 100644 index 0000000..e739d65 --- /dev/null +++ b/yamlesque/test/src/StreamTest.scala @@ -0,0 +1,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 + } + } +} |