Added a test for issue 389

This commit is contained in:
Inderjeet Singh 2011-12-16 17:21:31 +00:00
parent c01fc5c935
commit 4b8fd66c9d

View File

@ -149,11 +149,19 @@ public class NullObjectAndFieldTest extends TestCase {
assertEquals("[\"1\",null,\"3\"]", result);
}
// test for issue 389
public void testAbsentJsonElementsAreSetToNull() {
Gson gson = new Gson();
ClassWithMembers target = gson.fromJson("{array:[1,2,3]}", ClassWithMembers.class);
assertTrue(target.array.length == 3 && target.array[1] == 2);
assertNull(target.str);
assertNull(target.col);
}
private static class ClassWithNullWrappedPrimitive {
private Long value;
}
@SuppressWarnings("unused")
private static class ClassWithMembers {
String str;
int[] array;