BAEL-2412

Change test for min and max values by negative and positive infinity.
This commit is contained in:
Javier 2018-12-14 20:21:50 +01:00
parent 366cb9a0bc
commit 78096d4712
3 changed files with 11 additions and 12 deletions

View File

@ -0,0 +1,6 @@
package org.baeldung.gson.primitives.models;
public class InfinityValuesExample {
public float negativeInfinity;
public float positiveInfinity;
}

View File

@ -1,6 +0,0 @@
package org.baeldung.gson.primitives.models;
public class LimitValuesExample {
public float minValue;
public float maxValue;
}

View File

@ -32,15 +32,14 @@ public class UnitTest {
assertEquals(expected, gson.toJson(primitiveBundle)); assertEquals(expected, gson.toJson(primitiveBundle));
} }
@Test public void toJsonLimitValues() { @Test(expected = IllegalArgumentException.class) public void toJsonInfinity() {
LimitValuesExample model = new LimitValuesExample(); InfinityValuesExample model = new InfinityValuesExample();
model.minValue = Float.MIN_VALUE; model.negativeInfinity = Float.NEGATIVE_INFINITY;
model.maxValue = Float.MAX_VALUE; model.positiveInfinity = Float.POSITIVE_INFINITY;
Gson gson = new Gson(); Gson gson = new Gson();
String expected = "{\"minValue\":1.4E-45,\"maxValue\":3.4028235E38}"; gson.toJson(model);
assertEquals(expected, gson.toJson(model));
} }
@Test(expected = IllegalArgumentException.class) public void toJsonNaN() { @Test(expected = IllegalArgumentException.class) public void toJsonNaN() {