incorporated fixes from code review of r341

This commit is contained in:
Inderjeet Singh 2008-12-23 18:24:13 +00:00
parent e0195fcc54
commit bc6ec50db9

View File

@ -350,9 +350,13 @@ public class PrimitiveTest extends TestCase {
} }
public void testDoubleNaNSerializationNotSupportedByDefault() { public void testDoubleNaNSerializationNotSupportedByDefault() {
double nan = Double.NaN;
try { try {
double nan = Double.NaN;
gson.toJson(nan); gson.toJson(nan);
fail("Gson should not accept NaN for serialization");
} catch (IllegalArgumentException expected) {
}
try {
gson.toJson(Double.NaN); gson.toJson(Double.NaN);
fail("Gson should not accept NaN for serialization"); fail("Gson should not accept NaN for serialization");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
@ -372,9 +376,13 @@ public class PrimitiveTest extends TestCase {
} }
public void testFloatNaNSerializationNotSupportedByDefault() { public void testFloatNaNSerializationNotSupportedByDefault() {
float nan = Float.NaN;
try { try {
float nan = Float.NaN;
gson.toJson(nan); gson.toJson(nan);
fail("Gson should not accept NaN for serialization");
} catch (IllegalArgumentException expected) {
}
try {
gson.toJson(Float.NaN); gson.toJson(Float.NaN);
fail("Gson should not accept NaN for serialization"); fail("Gson should not accept NaN for serialization");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
@ -402,9 +410,13 @@ public class PrimitiveTest extends TestCase {
} }
public void testDoubleInfinitySerializationNotSupportedByDefault() { public void testDoubleInfinitySerializationNotSupportedByDefault() {
double infinity = Double.POSITIVE_INFINITY;
try { try {
double infinity = Double.POSITIVE_INFINITY;
gson.toJson(infinity); gson.toJson(infinity);
fail("Gson should not accept positive infinity for serialization by default.");
} catch (IllegalArgumentException expected) {
}
try {
gson.toJson(Double.POSITIVE_INFINITY); gson.toJson(Double.POSITIVE_INFINITY);
fail("Gson should not accept positive infinity for serialization by default."); fail("Gson should not accept positive infinity for serialization by default.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
@ -424,9 +436,13 @@ public class PrimitiveTest extends TestCase {
} }
public void testFloatInfinitySerializationNotSupportedByDefault() { public void testFloatInfinitySerializationNotSupportedByDefault() {
float infinity = Float.POSITIVE_INFINITY;
try { try {
float infinity = Float.POSITIVE_INFINITY;
gson.toJson(infinity); gson.toJson(infinity);
fail("Gson should not accept positive infinity for serialization by default");
} catch (IllegalArgumentException expected) {
}
try {
gson.toJson(Float.POSITIVE_INFINITY); gson.toJson(Float.POSITIVE_INFINITY);
fail("Gson should not accept positive infinity for serialization by default"); fail("Gson should not accept positive infinity for serialization by default");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
@ -454,9 +470,13 @@ public class PrimitiveTest extends TestCase {
} }
public void testNegativeInfinitySerializationNotSupportedByDefault() { public void testNegativeInfinitySerializationNotSupportedByDefault() {
double negativeInfinity = Double.NEGATIVE_INFINITY;
try { try {
double negativeInfinity = Double.NEGATIVE_INFINITY;
gson.toJson(negativeInfinity); gson.toJson(negativeInfinity);
fail("Gson should not accept negative infinity for serialization by default");
} catch (IllegalArgumentException expected) {
}
try {
gson.toJson(Double.NEGATIVE_INFINITY); gson.toJson(Double.NEGATIVE_INFINITY);
fail("Gson should not accept negative infinity for serialization by default"); fail("Gson should not accept negative infinity for serialization by default");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
@ -476,9 +496,13 @@ public class PrimitiveTest extends TestCase {
} }
public void testNegativeInfinityFloatSerializationNotSupportedByDefault() { public void testNegativeInfinityFloatSerializationNotSupportedByDefault() {
float negativeInfinity = Float.NEGATIVE_INFINITY;
try { try {
float negativeInfinity = Float.NEGATIVE_INFINITY;
gson.toJson(negativeInfinity); gson.toJson(negativeInfinity);
fail("Gson should not accept negative infinity for serialization by default");
} catch (IllegalArgumentException expected) {
}
try {
gson.toJson(Float.NEGATIVE_INFINITY); gson.toJson(Float.NEGATIVE_INFINITY);
fail("Gson should not accept negative infinity for serialization by default"); fail("Gson should not accept negative infinity for serialization by default");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {