From 7d6dff2b8d202ca6c52bca25d39760a41e5ec4c0 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 30 Jan 2024 00:34:35 +0100 Subject: [PATCH] add map serializer tests --- .../module/scala/ser/Map2SerializerTest.scala | 21 +++++++++++++++++++ .../module/scala/ser/Map2SerializerTest.scala | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/test/scala-2.13/tools/jackson/module/scala/ser/Map2SerializerTest.scala create mode 100644 src/test/scala-3/tools/jackson/module/scala/ser/Map2SerializerTest.scala diff --git a/src/test/scala-2.13/tools/jackson/module/scala/ser/Map2SerializerTest.scala b/src/test/scala-2.13/tools/jackson/module/scala/ser/Map2SerializerTest.scala new file mode 100644 index 000000000..af7acd3bc --- /dev/null +++ b/src/test/scala-2.13/tools/jackson/module/scala/ser/Map2SerializerTest.scala @@ -0,0 +1,21 @@ +package tools.jackson.module.scala.ser + +import tools.jackson.module.scala.{DefaultScalaModule, JacksonModule} + +import scala.collection.immutable.TreeSeqMap +import scala.collection.mutable + +class Map2SerializerTest extends SerializerTest { + + lazy val module: JacksonModule = DefaultScalaModule + + "MapSerializerModule" should "serialize a TreeSeqMap" in { + val result = serialize(TreeSeqMap("a" -> 1, "b" -> "two", "c" -> false)) + result shouldEqual """{"a":1,"b":"two","c":false}""" + } + + it should "serialize a CollisionProofHashMap" in { + val result = serialize(mutable.CollisionProofHashMap("a" -> 1, "b" -> "two", "c" -> false)) + result shouldEqual """{"a":1,"b":"two","c":false}""" + } +} diff --git a/src/test/scala-3/tools/jackson/module/scala/ser/Map2SerializerTest.scala b/src/test/scala-3/tools/jackson/module/scala/ser/Map2SerializerTest.scala new file mode 100644 index 000000000..af7acd3bc --- /dev/null +++ b/src/test/scala-3/tools/jackson/module/scala/ser/Map2SerializerTest.scala @@ -0,0 +1,21 @@ +package tools.jackson.module.scala.ser + +import tools.jackson.module.scala.{DefaultScalaModule, JacksonModule} + +import scala.collection.immutable.TreeSeqMap +import scala.collection.mutable + +class Map2SerializerTest extends SerializerTest { + + lazy val module: JacksonModule = DefaultScalaModule + + "MapSerializerModule" should "serialize a TreeSeqMap" in { + val result = serialize(TreeSeqMap("a" -> 1, "b" -> "two", "c" -> false)) + result shouldEqual """{"a":1,"b":"two","c":false}""" + } + + it should "serialize a CollisionProofHashMap" in { + val result = serialize(mutable.CollisionProofHashMap("a" -> 1, "b" -> "two", "c" -> false)) + result shouldEqual """{"a":1,"b":"two","c":false}""" + } +}