Skip to content

Commit a3bff18

Browse files
from needs to less than to in float range (#128329)
When testing float range, the from and to values are generated then it is decided whether or not to include the bounds within the range. If the values are not included in the range, the min value is calculated as the next higher float value than `from` and `to` as the next lower float value. If from and to are immediately adjacent to each other, and bounds are not included, the lower end of the range will be larger than the upper.
1 parent 3af0568 commit a3bff18

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/test/java/org/elasticsearch/index/mapper/FloatRangeFieldMapperTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ protected boolean supportsDecimalCoerce() {
4242

4343
@Override
4444
protected TestRange<Float> randomRangeForSyntheticSourceTest() {
45-
var includeFrom = randomBoolean();
4645
Float from = (float) randomDoubleBetween(-Float.MAX_VALUE, Float.MAX_VALUE - Math.ulp(Float.MAX_VALUE), true);
47-
var includeTo = randomBoolean();
4846
Float to = (float) randomDoubleBetween(from + Math.ulp(from), Float.MAX_VALUE, true);
47+
boolean valuesAdjacent = Math.nextUp(from) > Math.nextDown(to);
48+
var includeFrom = valuesAdjacent || randomBoolean();
49+
var includeTo = valuesAdjacent || randomBoolean();
4950

5051
if (rarely()) {
5152
from = null;

0 commit comments

Comments
 (0)