|
5 | 5 | import java.math.BigInteger;
|
6 | 6 |
|
7 | 7 | import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
| 8 | + |
8 | 9 | import com.fasterxml.jackson.core.JsonToken;
|
9 | 10 | import com.fasterxml.jackson.core.JsonParser.NumberType;
|
| 11 | + |
10 | 12 | import com.fasterxml.jackson.databind.ObjectMapper;
|
11 | 13 | import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
|
12 | 14 | import com.fasterxml.jackson.dataformat.cbor.CBORGenerator;
|
@@ -73,15 +75,28 @@ public void testLongRoundTrip() throws Exception
|
73 | 75 | 100L, -200L,
|
74 | 76 | 5000L, -3600L,
|
75 | 77 | Integer.MIN_VALUE, Integer.MAX_VALUE,
|
76 |
| - 1L + Integer.MAX_VALUE, -1L + Integer.MIN_VALUE, |
77 |
| - 2330462449L, // from [dataformats-binary#30] |
78 |
| - Long.MIN_VALUE, Long.MAX_VALUE |
79 |
| - }) { |
80 |
| - LongBean input = new LongBean(v); |
81 |
| - byte[] b = MAPPER.writeValueAsBytes(input); |
82 |
| - LongBean result = MAPPER.readValue(b, LongBean.class); |
83 |
| - assertEquals(input.value, result.value); |
| 78 | + 1L + Integer.MAX_VALUE, -1L + Integer.MIN_VALUE |
| 79 | + }) { |
| 80 | + _testLongRoundTrip(v); |
84 | 81 | }
|
| 82 | + |
| 83 | + _testLongRoundTrip(2330462449L); // from [dataformats-binary#30] |
| 84 | + _testLongRoundTrip(0xFFFFFFFFL); // max positive uint32 |
| 85 | + _testLongRoundTrip(-0xFFFFFFFFL); |
| 86 | + _testLongRoundTrip(0x100000000L); |
| 87 | + _testLongRoundTrip(-0x100000000L); |
| 88 | + _testLongRoundTrip(0x100000001L); |
| 89 | + _testLongRoundTrip(-0x100000001L); |
| 90 | + _testLongRoundTrip(Long.MIN_VALUE); |
| 91 | + _testLongRoundTrip(Long.MAX_VALUE); |
| 92 | + } |
| 93 | + |
| 94 | + private void _testLongRoundTrip(long v) throws Exception |
| 95 | + { |
| 96 | + LongBean input = new LongBean(v); |
| 97 | + byte[] b = MAPPER.writeValueAsBytes(input); |
| 98 | + LongBean result = MAPPER.readValue(b, LongBean.class); |
| 99 | + assertEquals(input.value, result.value); |
85 | 100 | }
|
86 | 101 |
|
87 | 102 | // for [dataformats-binary#32] coercion of Float into Double
|
@@ -218,7 +233,7 @@ public void testNumberTypeRetainingBuffering() throws Exception
|
218 | 233 | assertToken(JsonToken.END_ARRAY, p.nextToken());
|
219 | 234 | }
|
220 | 235 | }
|
221 |
| - |
| 236 | + |
222 | 237 | // [databind#2784]
|
223 | 238 | public void testBigDecimalWithBuffering() throws Exception
|
224 | 239 | {
|
|
0 commit comments