Skip to content

Commit 017d09f

Browse files
committed
Add testing of codec generation for product types that extends a base ADT type, see #463
1 parent b1fd944 commit 017d09f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

jsoniter-scala-macros/src/test/scala/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMakerSpec.scala

+6
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,12 @@ class JsonCodecMakerSpec extends VerifyingSpec {
13811381
verifySerDeser(make[List[Weapon]](CodecMakerConfig.withDiscriminatorFieldName(_root_.scala.None)),
13821382
List(Weapon.Axe, Weapon.Sword), """["Axe","Sword"]""")
13831383
}
1384+
"serialize and deserialize product types without discriminators if their codecs are derived not from the base ADT type" in {
1385+
verifySerDeser(make[AAA](CodecMakerConfig), AAA(1), """{"a":1}""")
1386+
verifySerDeser(make[BBB](CodecMakerConfig), BBB(BigInt(1)), """{"a":1}""")
1387+
verifySerDeser(make[CCC](CodecMakerConfig), CCC(1, "VVV"), """{"a":1,"b":"VVV"}""")
1388+
verifySerDeser(make[DDD.type](CodecMakerConfig), DDD, """{}""")
1389+
}
13841390
"deserialize ADTs when discriminator field was serialized in far away last position" in {
13851391
val longStr = "W" * 100000
13861392
verifyDeser(codecOfADTList, List(CCC(2, longStr), CCC(1, "VVV")),

0 commit comments

Comments
 (0)