BAEL-2412
Change test for min and max values by negative and positive infinity.
This commit is contained in:
parent
366cb9a0bc
commit
78096d4712
@ -0,0 +1,6 @@
|
||||
package org.baeldung.gson.primitives.models;
|
||||
|
||||
public class InfinityValuesExample {
|
||||
public float negativeInfinity;
|
||||
public float positiveInfinity;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package org.baeldung.gson.primitives.models;
|
||||
|
||||
public class LimitValuesExample {
|
||||
public float minValue;
|
||||
public float maxValue;
|
||||
}
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user