Inderjeet Singh 2009-08-10 17:47:11 +00:00
parent b7cbfc5c34
commit 41a1f8b89e
1 changed files with 13 additions and 0 deletions

View File

@ -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"};