Added tests in response to http://groups.google.com/group/google-gson/browse_thread/thread/41478d30b9f100b5
This commit is contained in:
parent
b7cbfc5c34
commit
41a1f8b89e
|
@ -19,6 +19,7 @@ package com.google.gson.functional;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.common.MoreAsserts;
|
||||
import com.google.gson.common.TestTypes.BagOfPrimitives;
|
||||
import com.google.gson.common.TestTypes.CrazyLongTypeAdapter;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
|
@ -83,6 +84,18 @@ public class ArrayTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testSingleNullInArraySerialization() {
|
||||
BagOfPrimitives[] array = new BagOfPrimitives[1];
|
||||
array[0] = null;
|
||||
String json = gson.toJson(array);
|
||||
assertEquals("[null]", json);
|
||||
}
|
||||
|
||||
public void testSingleNullInArrayDeserialization() {
|
||||
BagOfPrimitives[] array = gson.fromJson("[null]", BagOfPrimitives[].class);
|
||||
assertNull(array[0]);
|
||||
}
|
||||
|
||||
public void testNullsInArrayWithSerializeNullPropertySetSerialization() {
|
||||
gson = new GsonBuilder().serializeNulls().create();
|
||||
String[] array = {"foo", null, "bar"};
|
||||
|
|
Loading…
Reference in New Issue