Skip to content

Commit 75b7049

Browse files
committed
minor test refactoring
1 parent 522f2ba commit 75b7049

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/JDKScalarsTest.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,28 @@ public void testBooleanPrimitive() throws Exception
111111
// first, simple case:
112112
BooleanBean result = MAPPER.readValue(new StringReader("{\"v\":true}"), BooleanBean.class);
113113
assertTrue(result._v);
114-
// then [JACKSON-79]:
115114
result = MAPPER.readValue(new StringReader("{\"v\":null}"), BooleanBean.class);
116115
assertNotNull(result);
117116
assertFalse(result._v);
117+
// [databind#1480]
118+
result = MAPPER.readValue(new StringReader("{\"v\":1}"), BooleanBean.class);
119+
assertNotNull(result);
120+
assertTrue(result._v);
118121

119122
// should work with arrays too..
120123
boolean[] array = MAPPER.readValue(new StringReader("[ null ]"), boolean[].class);
121124
assertNotNull(array);
122125
assertEquals(1, array.length);
123126
assertFalse(array[0]);
127+
128+
}
124129

125-
// [Issue#381]
130+
public void testBooleanPrimitiveArrayUnwrap() throws Exception
131+
{
132+
// [databind#381]
126133
final ObjectMapper mapper = new ObjectMapper();
127134
mapper.enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS);
128-
result = mapper.readValue(new StringReader("{\"v\":[true]}"), BooleanBean.class);
135+
BooleanBean result = mapper.readValue(new StringReader("{\"v\":[true]}"), BooleanBean.class);
129136
assertTrue(result._v);
130137

131138
try {
@@ -143,7 +150,7 @@ public void testBooleanPrimitive() throws Exception
143150
assertNotNull(result);
144151
assertFalse(result._v);
145152

146-
array = mapper.readValue(new StringReader("[ [ null ] ]"), boolean[].class);
153+
boolean[] array = mapper.readValue(new StringReader("[ [ null ] ]"), boolean[].class);
147154
assertNotNull(array);
148155
assertEquals(1, array.length);
149156
assertFalse(array[0]);
@@ -161,9 +168,9 @@ public void testBooleanWrapper() throws Exception
161168
assertEquals(Boolean.FALSE, result);
162169

163170
// should accept ints too, (0 == false, otherwise true)
164-
result = MAPPER.readValue(new StringReader("0"), Boolean.class);
171+
result = MAPPER.readValue("0", Boolean.class);
165172
assertEquals(Boolean.FALSE, result);
166-
result = MAPPER.readValue(new StringReader("1"), Boolean.class);
173+
result = MAPPER.readValue("1", Boolean.class);
167174
assertEquals(Boolean.TRUE, result);
168175
}
169176

0 commit comments

Comments
 (0)