1 package com.fasterxml.jackson.databind.convert;
2 
3 import com.fasterxml.jackson.databind.*;
4 
5 public class ScalarConversionTest extends BaseMapTest
6 {
7     private final ObjectMapper MAPPER = new ObjectMapper();
8 
9     // [databind#1433]
testConvertValueNullPrimitive()10     public void testConvertValueNullPrimitive() throws Exception
11     {
12         assertEquals(Byte.valueOf((byte) 0), MAPPER.convertValue(null, Byte.TYPE));
13         assertEquals(Short.valueOf((short) 0), MAPPER.convertValue(null, Short.TYPE));
14         assertEquals(Integer.valueOf(0), MAPPER.convertValue(null, Integer.TYPE));
15         assertEquals(Long.valueOf(0L), MAPPER.convertValue(null, Long.TYPE));
16         assertEquals(Float.valueOf(0f), MAPPER.convertValue(null, Float.TYPE));
17         assertEquals(Double.valueOf(0d), MAPPER.convertValue(null, Double.TYPE));
18         assertEquals(Character.valueOf('\0'), MAPPER.convertValue(null, Character.TYPE));
19         assertEquals(Boolean.FALSE, MAPPER.convertValue(null, Boolean.TYPE));
20     }
21 
22     // [databind#1433]
testConvertValueNullBoxed()23     public void testConvertValueNullBoxed() throws Exception
24     {
25         assertNull(MAPPER.convertValue(null, Byte.class));
26         assertNull(MAPPER.convertValue(null, Short.class));
27         assertNull(MAPPER.convertValue(null, Integer.class));
28         assertNull(MAPPER.convertValue(null, Long.class));
29         assertNull(MAPPER.convertValue(null, Float.class));
30         assertNull(MAPPER.convertValue(null, Double.class));
31         assertNull(MAPPER.convertValue(null, Character.class));
32         assertNull(MAPPER.convertValue(null, Boolean.class));
33     }
34 }
35