Skip to content

Commit 1dd2c08

Browse files
committed
Add a (failing) test for #3234
1 parent 509a4aa commit 1dd2c08

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.databind.*;
4+
5+
// [databind#3234]
6+
public class CoerceEmptyToInt3234Test extends BaseMapTest
7+
{
8+
static class BasicIntWrapper {
9+
public int value = 13;
10+
}
11+
12+
static class BasicLongWrapper {
13+
public long value = 7L;
14+
}
15+
16+
private final ObjectMapper MAPPER = newJsonMapper();
17+
private final ObjectReader READER_INT_BASIC = MAPPER.readerFor(BasicIntWrapper.class);
18+
private final ObjectReader READER_LONG_BASIC = MAPPER.readerFor(BasicLongWrapper.class);
19+
20+
// // // Ints
21+
22+
public void testSimpleIntFromEmpty() throws Exception
23+
{
24+
BasicIntWrapper w = READER_INT_BASIC.readValue(a2q("{'value':''}"));
25+
assertEquals(0, w.value);
26+
}
27+
28+
public void testSimpleIntFromBlank() throws Exception
29+
{
30+
BasicIntWrapper w = READER_INT_BASIC.readValue(a2q("{'value':' '}"));
31+
assertEquals(0, w.value);
32+
}
33+
34+
// // // Long
35+
36+
public void testSimpleLongFromEmpty() throws Exception
37+
{
38+
BasicLongWrapper w = READER_LONG_BASIC.readValue(a2q("{'value':''}"));
39+
assertEquals(0L, w.value);
40+
}
41+
42+
public void testSimpleLongFromBlank() throws Exception
43+
{
44+
BasicLongWrapper w = READER_LONG_BASIC.readValue(a2q("{'value':' '}"));
45+
assertEquals(0L, w.value);
46+
}
47+
}

0 commit comments

Comments
 (0)