Skip to content

Commit 625f82e

Browse files
committed
Merge branch '2.8' of github.com:FasterXML/jackson-dataformats-binary into 2.8
2 parents 3d81e07 + abab125 commit 625f82e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.fasterxml.jackson.dataformat.cbor.failing;
2+
3+
import java.util.*;
4+
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
7+
import com.fasterxml.jackson.dataformat.cbor.*;
8+
9+
public class NumberCoercing32Test extends CBORTestBase
10+
{
11+
/*
12+
/**********************************************************
13+
/* Test methods
14+
/**********************************************************
15+
*/
16+
17+
public void testPrimitiveTypeInvariance() throws Exception
18+
{
19+
ObjectMapper mapper = new ObjectMapper(
20+
new CBORFactory().disable(CBORGenerator.Feature.WRITE_MINIMAL_INTS)
21+
);
22+
Map<String, Object> map = new HashMap<>();
23+
map.put("longField", 1L);
24+
map.put("intField", 1);
25+
map.put("doubleField", 1.0d);
26+
map.put("floatField", 1.0f);
27+
byte[] json = mapper.writeValueAsBytes(map);
28+
Map<String, Object> result = mapper.readerFor(Map.class).readValue(json);
29+
assertEquals(Integer.class, result.get("intField").getClass());
30+
assertEquals(Long.class, result.get("longField").getClass());
31+
assertEquals(Double.class, result.get("doubleField").getClass());
32+
assertEquals(Float.class, result.get("floatField").getClass());
33+
}
34+
}

0 commit comments

Comments
 (0)