Skip to content

Commit f1e1f93

Browse files
committed
[TEST] fix float comparison in RandomObjects#getExpectedParsedValue
This commit fixes a test bug introduced with #36597. This caused some test failure as stored field values comparisons would not work when CBOR xcontent type was used. Closes #29080
1 parent 3dd5a5a commit f1e1f93

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/framework/src/main/java/org/elasticsearch/test/RandomObjects.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,16 @@ public static Object getExpectedParsedValue(XContentType xContentType, Object va
135135
}
136136
}
137137
if (value instanceof Float) {
138+
if (xContentType == XContentType.CBOR) {
139+
//with CBOR we get back a float
140+
return value;
141+
}
138142
if (xContentType == XContentType.SMILE) {
139143
//with SMILE we get back a double (this will change in Jackson 2.9 where it will return a Float)
140144
return ((Float)value).doubleValue();
141-
} else {
142-
//with JSON AND YAML we get back a double, but with float precision.
143-
return Double.parseDouble(value.toString());
144145
}
146+
//with JSON AND YAML we get back a double, but with float precision.
147+
return Double.parseDouble(value.toString());
145148
}
146149
if (value instanceof Byte) {
147150
return ((Byte)value).intValue();

0 commit comments

Comments
 (0)