Add new tests with SerializedName annotation that contains a space in the name.
This commit is contained in:
parent
855a79a0f0
commit
9cd72ca7fb
|
@ -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 + '}';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user