Skip to content

Commit

Permalink
[TEST] fix float comparison in RandomObjects#getExpectedParsedValue
Browse files Browse the repository at this point in the history
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
  • Loading branch information
javanna authored and davidkyle committed Dec 18, 2018
1 parent 992b531 commit e2489a7
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ public static Object getExpectedParsedValue(XContentType xContentType, Object va
}
}
if (value instanceof Float) {
if (xContentType == XContentType.CBOR) {
//with CBOR we get back a float
return value;
}
if (xContentType == XContentType.SMILE) {
//with SMILE we get back a double (this will change in Jackson 2.9 where it will return a Float)
return ((Float)value).doubleValue();
} else {
//with JSON AND YAML we get back a double, but with float precision.
return Double.parseDouble(value.toString());
}
//with JSON AND YAML we get back a double, but with float precision.
return Double.parseDouble(value.toString());
}
if (value instanceof Byte) {
return ((Byte)value).intValue();
Expand Down

0 comments on commit e2489a7

Please sign in to comment.