File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/failing Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments