diff options
Diffstat (limited to 'gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java')
-rw-r--r-- | gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java b/gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java index 2e00dc9b..d92994fa 100644 --- a/gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java +++ b/gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java @@ -53,10 +53,16 @@ public class GsonTypeAdapterTest extends TestCase { fail("Type Adapter should have thrown an exception"); } catch (IllegalStateException expected) { } + // Verify that serializer is made null-safe, i.e. it is not called for null + assertEquals("null", gson.toJson(null, AtomicLong.class)); + try { gson.fromJson("123", AtomicLong.class); fail("Type Adapter should have thrown an exception"); } catch (JsonParseException expected) { } + + // Verify that deserializer is made null-safe, i.e. it is not called for null + assertNull(gson.fromJson(JsonNull.INSTANCE, AtomicLong.class)); } public void testTypeAdapterProperlyConvertsTypes() throws Exception { |