Skip to content

Commit ed2c9c1

Browse files
committed
Polishing.
Widen test assertions to avoid double rounding errors failing the test. See #2575
1 parent 5e8f73a commit ed2c9c1

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/test/java/org/springframework/data/redis/core/DefaultValueOperationsIntegrationTests.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import static org.assertj.core.api.Assumptions.*;
2020
import static org.awaitility.Awaitility.*;
2121

22-
import java.text.DecimalFormat;
2322
import java.time.Duration;
2423
import java.util.Arrays;
2524
import java.util.Collection;
2625
import java.util.HashMap;
27-
import java.util.Locale;
2826
import java.util.Map;
2927
import java.util.concurrent.TimeUnit;
3028

@@ -117,13 +115,11 @@ void testIncrementDouble() {
117115

118116
valueOps.set(key, (V) value);
119117

120-
DecimalFormat twoDForm = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
121-
122-
assertThat(valueOps.increment(key, 1.4)).isEqualTo(Double.valueOf(twoDForm.format((Double) value + 1.4)));
123-
assertThat((Double) valueOps.get(key)).isBetween(value + 1.3, value + 1.4);
118+
assertThat(valueOps.increment(key, 1.4)).isBetween(value + 1.39, value + 1.41);
119+
assertThat((Double) valueOps.get(key)).isBetween(value + 1.39, value + 1.41);
124120

125121
valueOps.increment(key, -10d);
126-
assertThat((Double) valueOps.get(key)).isBetween(value + 1.3 - 10, value + 1.4 - 10);
122+
assertThat((Double) valueOps.get(key)).isBetween(value + 1.39 - 10, value + 1.41 - 10);
127123
}
128124

129125
@ParameterizedRedisTest // DATAREDIS-784

0 commit comments

Comments
 (0)