Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Jul 22, 2024
1 parent b7ce4a7 commit f8196c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.fasterxml.jackson.module.scala.deser

import com.fasterxml.jackson.module.scala.{DefaultScalaModule, JacksonModule}

import scala.util.Properties.versionString
import scala.util.Properties.versionNumberString

object AnyValDeserializerTest {
case class DoubleAnyVal(underlying: Double) extends AnyVal
Expand Down Expand Up @@ -32,7 +32,8 @@ class AnyValDeserializerTest extends DeserializerTest {
val expected = BigIntAnyVal(42)
mapper.readValue("""{"underlying":42}""", classOf[BigIntAnyVal]) shouldEqual expected
mapper.readValue("""{"value":42}""", classOf[BigIntAnyValHolder]) shouldEqual BigIntAnyValHolder(expected)
if (!versionString.startsWith("2.11")) {
if (!versionNumberString.startsWith("2.11") && !versionNumberString.startsWith("3")) {
// see https://github.com/FasterXML/jackson-module-scala/pull/675
mapper.readValue("""{"value":{"underlying":42}}""", classOf[BigIntOptionAnyValHolder]) shouldEqual
BigIntOptionAnyValHolder(Some(expected))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package com.fasterxml.jackson.module.scala.ser

import com.fasterxml.jackson.module.scala.BaseFixture

import scala.util.Properties.versionNumberString

object AnyValSerializerTest {
case class DoubleAnyVal(underlying: Double) extends AnyVal
case class DoubleAnyValHolder(value: DoubleAnyVal)

case class BigIntAnyVal(underlying: BigInt) extends AnyVal
case class BigIntAnyValHolder(value: BigIntAnyVal)
case class BigIntOptionAnyValHolder(value: Option[BigIntAnyVal])
}

//see AnyVal2SerializerTest for cases that only work with Scala2 and Scala3.3 but not earlier versions of Scala3
Expand All @@ -26,6 +29,10 @@ class AnyValSerializerTest extends BaseFixture {
val value = BigIntAnyVal(42)
mapper.writeValueAsString(value) shouldBe """{"underlying":42}"""
mapper.writeValueAsString(BigIntAnyValHolder(value)) shouldBe """{"value":42}"""
if (!versionNumberString.startsWith("2.11") && !versionNumberString.startsWith("3")) {
// see https://github.com/FasterXML/jackson-module-scala/pull/675
mapper.writeValueAsString(BigIntOptionAnyValHolder(Some(value))) shouldBe """{"value":{"underlying":42}}"""
}
}

}

0 comments on commit f8196c5

Please sign in to comment.