Skip to content

Commit

Permalink
test(CodecSpec): update big int size
Browse files Browse the repository at this point in the history
  • Loading branch information
ologbonowiwi committed Jun 28, 2024
1 parent 90801d2 commit 47f7adb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions zio-json/shared/src/test/scala/zio/json/CodecSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import zio.test.Assertion._
import zio.test.TestAspect.jvmOnly
import zio.test._

import java.math.BigInteger
import scala.collection.immutable

object CodecSpec extends ZIOSpecDefault {
Expand Down Expand Up @@ -37,10 +38,17 @@ object CodecSpec extends ZIOSpecDefault {
},
test("primitives") {
val exampleBDString = "234234.234"
// this big integer consumes more than 128 bits
assert("170141183460469231731687303715884105728".fromJson[java.math.BigInteger])(
isLeft(equalTo("(expected a 128 bit BigInteger)"))
) && assert(exampleBDString.fromJson[BigDecimal])(isRight(equalTo(BigDecimal(exampleBDString))))
// this big integer consumes more than 256 bits
assert(
"170141183460469231731687303715884105728489465165484668486513574864654818964653168465316546851"
.fromJson[java.math.BigInteger]
)(
isLeft(equalTo("(expected a 256 bit BigInteger)"))
) && assert(exampleBDString.fromJson[BigDecimal])(isRight(equalTo(BigDecimal(exampleBDString)))) && assert(
"170141183460469231731687303715884105728".fromJson[java.math.BigInteger]
)(
isRight(equalTo(new BigInteger("170141183460469231731687303715884105728")))
)
},
test("java.util.Currency") {
val exampleValue = "\"USD\""
Expand Down

0 comments on commit 47f7adb

Please sign in to comment.