File tree Expand file tree Collapse file tree
msgpack-core/src/test/scala/org/msgpack/value Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616package org .msgpack .value
1717
1818import java .math .BigInteger
19-
2019import org .msgpack .core ._
2120
2221import scala .util .parsing .json .JSON
@@ -97,5 +96,35 @@ class ValueTest extends MessagePackSpec
9796
9897 }
9998
99+ " check appropriate range for integers" in {
100+ import ValueFactory ._
101+ import java .lang .Byte
102+ import java .lang .Short
103+
104+ newInteger(Byte .MAX_VALUE ).asByte() shouldBe Byte .MAX_VALUE
105+ newInteger(Byte .MIN_VALUE ).asByte() shouldBe Byte .MIN_VALUE
106+ newInteger(Short .MAX_VALUE ).asShort() shouldBe Short .MAX_VALUE
107+ newInteger(Short .MIN_VALUE ).asShort() shouldBe Short .MIN_VALUE
108+ newInteger(Integer .MAX_VALUE ).asInt() shouldBe Integer .MAX_VALUE
109+ newInteger(Integer .MIN_VALUE ).asInt() shouldBe Integer .MIN_VALUE
110+ intercept[MessageIntegerOverflowException ] {
111+ newInteger(Byte .MAX_VALUE + 1 ).asByte()
112+ }
113+ intercept[MessageIntegerOverflowException ] {
114+ newInteger(Byte .MIN_VALUE - 1 ).asByte()
115+ }
116+ intercept[MessageIntegerOverflowException ] {
117+ newInteger(Short .MAX_VALUE + 1 ).asShort()
118+ }
119+ intercept[MessageIntegerOverflowException ] {
120+ newInteger(Short .MIN_VALUE - 1 ).asShort()
121+ }
122+ intercept[MessageIntegerOverflowException ] {
123+ newInteger(Integer .MAX_VALUE + 1 ).asInt()
124+ }
125+ intercept[MessageIntegerOverflowException ] {
126+ newInteger(Integer .MIN_VALUE - 1 ).asInt()
127+ }
128+ }
100129 }
101130}
You can’t perform that action at this time.
0 commit comments