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));
|
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() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user