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));
}
@Test public void toJsonLimitValues() {
LimitValuesExample model = new LimitValuesExample();
model.minValue = Float.MIN_VALUE;
model.maxValue = Float.MAX_VALUE;
@Test(expected = IllegalArgumentException.class) public void toJsonInfinity() {
InfinityValuesExample model = new InfinityValuesExample();
model.negativeInfinity = Float.NEGATIVE_INFINITY;
model.positiveInfinity = Float.POSITIVE_INFINITY;
Gson gson = new Gson();
String expected = "{\"minValue\":1.4E-45,\"maxValue\":3.4028235E38}";
assertEquals(expected, gson.toJson(model));
gson.toJson(model);
}
@Test(expected = IllegalArgumentException.class) public void toJsonNaN() {