aboutsummaryrefslogtreecommitdiff
path: root/gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'gson/src/test/java/com/google/gson/functional/InternationalizationTest.java')
-rw-r--r--gson/src/test/java/com/google/gson/functional/InternationalizationTest.java42
1 files changed, 23 insertions, 19 deletions
diff --git a/gson/src/test/java/com/google/gson/functional/InternationalizationTest.java b/gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
index 169c37a5..bdf6ea6e 100644
--- a/gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
+++ b/gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
@@ -17,7 +17,6 @@
package com.google.gson.functional;
import com.google.gson.Gson;
-
import junit.framework.TestCase;
/**
@@ -34,32 +33,16 @@ public class InternationalizationTest extends TestCase {
gson = new Gson();
}
- /*
- public void testStringsWithRawChineseCharactersSerialization() throws Exception {
- String target = "好好好";
- String json = gson.toJson(target);
- String expected = "\"\\u597d\\u597d\\u597d\"";
- assertEquals(expected, json);
- }
- */
-
- public void testStringsWithRawChineseCharactersDeserialization() throws Exception {
- String expected = "好好好";
- String json = "\"" + expected + "\"";
- String actual = gson.fromJson(json, String.class);
- assertEquals(expected, actual);
- }
-
public void testStringsWithUnicodeChineseCharactersSerialization() throws Exception {
String target = "\u597d\u597d\u597d";
String json = gson.toJson(target);
- String expected = "\"\u597d\u597d\u597d\"";
+ String expected = '"' + target + '"';
assertEquals(expected, json);
}
public void testStringsWithUnicodeChineseCharactersDeserialization() throws Exception {
String expected = "\u597d\u597d\u597d";
- String json = "\"" + expected + "\"";
+ String json = '"' + expected + '"';
String actual = gson.fromJson(json, String.class);
assertEquals(expected, actual);
}
@@ -68,4 +51,25 @@ public class InternationalizationTest extends TestCase {
String actual = gson.fromJson("'\\u597d\\u597d\\u597d'", String.class);
assertEquals("\u597d\u597d\u597d", actual);
}
+
+ public void testSupplementaryUnicodeSerialization() throws Exception {
+ // Supplementary code point U+1F60A
+ String supplementaryCodePoint = new String(new int[] {0x1F60A}, 0, 1);
+ String json = gson.toJson(supplementaryCodePoint);
+ assertEquals('"' + supplementaryCodePoint + '"', json);
+ }
+
+ public void testSupplementaryUnicodeDeserialization() throws Exception {
+ // Supplementary code point U+1F60A
+ String supplementaryCodePoint = new String(new int[] {0x1F60A}, 0, 1);
+ String actual = gson.fromJson('"' + supplementaryCodePoint + '"', String.class);
+ assertEquals(supplementaryCodePoint, actual);
+ }
+
+ public void testSupplementaryUnicodeEscapedDeserialization() throws Exception {
+ // Supplementary code point U+1F60A
+ String supplementaryCodePoint = new String(new int[] {0x1F60A}, 0, 1);
+ String actual = gson.fromJson("\"\\uD83D\\uDE0A\"", String.class);
+ assertEquals(supplementaryCodePoint, actual);
+ }
}