From 9424949245bb46bd63f3fed83e67daa9fdbdbff9 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Fri, 9 Sep 2011 05:41:35 +0000 Subject: [PATCH] Don't unwrap single-element String arrays --- gson/GSON 2.0 NOTES.txt | 2 +- .../com/google/gson/functional/StringTest.java | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/gson/GSON 2.0 NOTES.txt b/gson/GSON 2.0 NOTES.txt index ffc57a31..43eeb8fe 100644 --- a/gson/GSON 2.0 NOTES.txt +++ b/gson/GSON 2.0 NOTES.txt @@ -10,7 +10,7 @@ com.google.gson.functional.PrimitiveTest.testPrimitiveBooleanAutoboxedInASingleE com.google.gson.functional.PrimitiveTest.testPrimitiveDoubleAutoboxedInASingleElementArrayDeserialization com.google.gson.functional.PrimitiveTest.testBigDecimalInASingleElementArrayDeserialization com.google.gson.functional.PrimitiveTest.testBigIntegerInASingleElementArrayDeserialization - +com.google.gson.functional.StringTest.testStringValueAsSingleElementArrayDeserialization GSON 1.x permitted primitive types to be overridden GSON 2.x doesn't. diff --git a/gson/src/test/java/com/google/gson/functional/StringTest.java b/gson/src/test/java/com/google/gson/functional/StringTest.java index d80e4634..7dcf6f0f 100644 --- a/gson/src/test/java/com/google/gson/functional/StringTest.java +++ b/gson/src/test/java/com/google/gson/functional/StringTest.java @@ -18,7 +18,7 @@ public class StringTest extends TestCase { super.setUp(); gson = new Gson(); } - + public void testStringValueSerialization() throws Exception { String value = "someRandomStringValue"; assertEquals('"' + value + '"', gson.toJson(value)); @@ -97,19 +97,13 @@ public class StringTest extends TestCase { assertEquals("[\"abc\"]", gson.toJson(target, String[].class)); } - public void testStringValueAsSingleElementArrayDeserialization() throws Exception { - String value = "someRandomStringValue"; - String actual = gson.fromJson("[\"" + value + "\"]", String.class); - assertEquals(value, actual); - } - public void testStringWithEscapedSlashDeserialization() { String value = "/"; String json = "'\\/'"; String actual = gson.fromJson(json, String.class); assertEquals(value, actual); } - + /** * Created in response to http://groups.google.com/group/google-gson/browse_thread/thread/2431d4a3d0d6cb23 */ @@ -118,7 +112,7 @@ public class StringTest extends TestCase { String json = gson.toJson(value); assertEquals("\"abc\\u003d\"", json); } - + /** * Created in response to http://groups.google.com/group/google-gson/browse_thread/thread/2431d4a3d0d6cb23 */ @@ -131,13 +125,13 @@ public class StringTest extends TestCase { value = gson.fromJson(json, String.class); assertEquals("abc=", value); } - + public void testJavascriptKeywordsInStringSerialization() { String value = "null true false function"; String json = gson.toJson(value); assertEquals("\"" + value + "\"", json); } - + public void testJavascriptKeywordsInStringDeserialization() { String json = "'null true false function'"; String value = gson.fromJson(json, String.class);