From 9cd72ca7fb9fb76fde0269963bee348e75da9812 Mon Sep 17 00:00:00 2001 From: Joel Leitch Date: Fri, 28 May 2010 02:13:11 +0000 Subject: [PATCH] Add new tests with SerializedName annotation that contains a space in the name. --- gson/src/test/java/com/google/gson/common/TestTypes.java | 8 +++++--- .../java/com/google/gson/functional/NamingPolicyTest.java | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gson/src/test/java/com/google/gson/common/TestTypes.java b/gson/src/test/java/com/google/gson/common/TestTypes.java index 6c04417b..ff52e0ab 100644 --- a/gson/src/test/java/com/google/gson/common/TestTypes.java +++ b/gson/src/test/java/com/google/gson/common/TestTypes.java @@ -395,16 +395,18 @@ public class TestTypes { public static class ClassWithSerializedNameFields { @SerializedName("fooBar") public final int f; + @SerializedName("Another Foo") public final int g; public ClassWithSerializedNameFields() { - this(1); + this(1, 4); } - public ClassWithSerializedNameFields(int f) { + public ClassWithSerializedNameFields(int f, int g) { this.f = f; + this.g = g; } public String getExpectedJson() { - return '{' + "\"fooBar\":" + f + '}'; + return '{' + "\"fooBar\":" + f + ",\"Another Foo\":" + g + '}'; } } diff --git a/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java b/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java index 901fa2eb..07f3c231 100644 --- a/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java +++ b/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java @@ -89,14 +89,14 @@ public class NamingPolicyTest extends TestCase { public void testGsonWithSerializedNameFieldNamingPolicySerialization() { Gson gson = builder.create(); - ClassWithSerializedNameFields expected = new ClassWithSerializedNameFields(5); + ClassWithSerializedNameFields expected = new ClassWithSerializedNameFields(5, 6); String actual = gson.toJson(expected); assertEquals(expected.getExpectedJson(), actual); } public void testGsonWithSerializedNameFieldNamingPolicyDeserialization() { Gson gson = builder.create(); - ClassWithSerializedNameFields expected = new ClassWithSerializedNameFields(5); + ClassWithSerializedNameFields expected = new ClassWithSerializedNameFields(5, 7); ClassWithSerializedNameFields actual = gson.fromJson(expected.getExpectedJson(), ClassWithSerializedNameFields.class); assertEquals(expected.f, actual.f);