Added test for pretty printing of Maps.
This commit is contained in:
parent
e8619405be
commit
f4f92a699d
@ -15,19 +15,21 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.gson.functional;
|
package com.google.gson.functional;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.common.TestTypes.ArrayOfObjects;
|
import com.google.gson.common.TestTypes.ArrayOfObjects;
|
||||||
import com.google.gson.common.TestTypes.BagOfPrimitives;
|
import com.google.gson.common.TestTypes.BagOfPrimitives;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functional tests for pretty printing option.
|
* Functional tests for pretty printing option.
|
||||||
*
|
*
|
||||||
@ -38,7 +40,7 @@ public class PrettyPrintingTest extends TestCase {
|
|||||||
private static int PRINT_MARGIN = 80;
|
private static int PRINT_MARGIN = 80;
|
||||||
private static int RIGHT_MARGIN = 4;
|
private static int RIGHT_MARGIN = 4;
|
||||||
|
|
||||||
private static boolean DEBUG = false;
|
private static boolean DEBUG = true;
|
||||||
|
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
|
|
||||||
@ -87,6 +89,14 @@ public class PrettyPrintingTest extends TestCase {
|
|||||||
assertEquals("[[1,2],[3,4],[5,6],[7,8],[9,0],[10]]\n", json);
|
assertEquals("[[1,2],[3,4],[5,6],[7,8],[9,0],[10]]\n", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMap() {
|
||||||
|
Map<String, Integer> map = new LinkedHashMap<String, Integer>();
|
||||||
|
map.put("abc", 1);
|
||||||
|
map.put("def", 5);
|
||||||
|
String json = gson.toJson(map);
|
||||||
|
assertEquals("{\"abc\":1,\"def\":5}\n", json);
|
||||||
|
}
|
||||||
|
|
||||||
public void testMultipleArrays() {
|
public void testMultipleArrays() {
|
||||||
int[][][] ints = new int[][][] { { { 1 }, { 2 } } };
|
int[][][] ints = new int[][][] { { { 1 }, { 2 } } };
|
||||||
String json = gson.toJson(ints);
|
String json = gson.toJson(ints);
|
||||||
|
Loading…
Reference in New Issue
Block a user