Minor test fixes. Explicitly fail test if the expected exception was not thrown.

This commit is contained in:
Joel Leitch 2010-08-21 03:19:17 +00:00
parent de0f8da151
commit 3fc4bcc061

View File

@ -31,7 +31,6 @@ import java.lang.reflect.Type;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
/** /**
* Functional tests for Json serialization and deserialization of arrays. * Functional tests for Json serialization and deserialization of arrays.
* *
@ -81,7 +80,7 @@ public class ArrayTest extends TestCase {
actualObject = gson.fromJson("[ ]", int[].class); actualObject = gson.fromJson("[ ]", int[].class);
assertTrue(actualObject.length == 0); assertTrue(actualObject.length == 0);
} }
public void testNullsInArraySerialization() { public void testNullsInArraySerialization() {
String[] array = {"foo", null, "bar"}; String[] array = {"foo", null, "bar"};
@ -219,6 +218,7 @@ public class ArrayTest extends TestCase {
String json = "[1,'abc',{a:1},5]"; String json = "[1,'abc',{a:1},5]";
try { try {
gson.fromJson(json, Object[].class); gson.fromJson(json, Object[].class);
fail("This is crazy....how did we deserialize it!!!");
} catch (JsonParseException expected) { } catch (JsonParseException expected) {
} }
} }
@ -227,6 +227,7 @@ public class ArrayTest extends TestCase {
String json = "[1,'abc',[1,2],5]"; String json = "[1,'abc',[1,2],5]";
try { try {
gson.fromJson(json, Object[].class); gson.fromJson(json, Object[].class);
fail("This is crazy....how did we deserialize it!!!");
} catch (JsonParseException expected) { } catch (JsonParseException expected) {
} }
} }