diff options
author | Jakob Odersky <jakob@odersky.com> | 2018-04-08 20:30:44 -0700 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2018-04-08 20:32:20 -0700 |
commit | da6a5cad7ef0fe723ac126f921f97c36962f42af (patch) | |
tree | d86aae792a7c96c22685ba1657abc766d56d4be0 /yamlesque-spray-json/src/test | |
parent | 98f1acf269312545192be115c75a6cce58c00766 (diff) | |
download | yamlesque-da6a5cad7ef0fe723ac126f921f97c36962f42af.tar.gz yamlesque-da6a5cad7ef0fe723ac126f921f97c36962f42af.tar.bz2 yamlesque-da6a5cad7ef0fe723ac126f921f97c36962f42af.zip |
Restructure build
Diffstat (limited to 'yamlesque-spray-json/src/test')
-rw-r--r-- | yamlesque-spray-json/src/test/scala/FormatTests.scala | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/yamlesque-spray-json/src/test/scala/FormatTests.scala b/yamlesque-spray-json/src/test/scala/FormatTests.scala new file mode 100644 index 0000000..93d763a --- /dev/null +++ b/yamlesque-spray-json/src/test/scala/FormatTests.scala @@ -0,0 +1,53 @@ +package yamlesque + +import spray.json._ +import utest._ + +object FormatTests extends TestSuite { + + case class A(a1: Int, a2: Seq[B]) + case class B(a: String, b: Option[Boolean]) + + object Protocol extends DefaultJsonProtocol with JsonYamlFormats { + implicit def bFormat = jsonFormat2(B) + implicit def aFormat = jsonFormat2(A) + } + import Protocol._ + + val tests = Tests { + "parse" - { + val str = + s"""|a1: 42 + |a2: + | - a: hello world + | b: true + | - a: yoyo + |""".stripMargin + + "parse yaml" - { + str.parseYaml ==> YamlMapping( + "a1" -> YamlScalar("42"), + "a2" -> YamlSequence( + YamlMapping( + "a" -> YamlScalar("hello world"), + "b" -> YamlScalar("true") + ), + YamlMapping( + "a" -> YamlScalar("yoyo") + ) + ) + ) + } + "parse with json readers" - { + str.parseYaml.convertTo[A] ==> A( + 42, + Seq( + B("hello world", Some(true)), + B("yoyo", None), + ) + ) + } + } + } + +} |