Yuti-G commented on code in PR #1013:
URL: https://github.com/apache/lucene/pull/1013#discussion_r920790457
##########
lucene/facet/src/test/org/apache/lucene/facet/FacetTestCase.java:
##########
@@ -254,14 +254,38 @@ protected void assertFloatValuesEquals(FacetResult a,
FacetResult b) {
assertEquals(a.dim, b.dim);
assertTrue(Arrays.equals(a.path, b.path));
assertEquals(a.childCount, b.childCount);
- assertEquals(a.value.floatValue(), b.value.floatValue(),
a.value.floatValue() / 1e5);
+ assertNumericValuesEquals(a.value, b.value);
assertEquals(a.labelValues.length, b.labelValues.length);
for (int i = 0; i < a.labelValues.length; i++) {
assertEquals(a.labelValues[i].label, b.labelValues[i].label);
- assertEquals(
- a.labelValues[i].value.floatValue(),
- b.labelValues[i].value.floatValue(),
- a.labelValues[i].value.floatValue() / 1e5);
+ assertNumericValuesEquals(a.labelValues[i].value,
b.labelValues[i].value);
}
}
+
+ protected void assertNumericValuesEquals(Number a, Number b) {
+ assertTrue(a.getClass().isInstance(b));
+ if (a instanceof Float) {
+ assertEquals(a.floatValue(), b.floatValue(), a.floatValue() / 1e5);
+ } else if (a instanceof Double) {
+ assertEquals(a.doubleValue(), b.doubleValue(), a.doubleValue() / 1e5);
+ } else {
+ assertEquals(a, b);
Review Comment:
I think it does because assertEquals eventually calls equals() that compares
the values, and Long/Byte/Integer.java have this equals() function.
<img width="761" alt="Screen Shot 2022-07-13 at 11 16 00 PM"
src="https://user-images.githubusercontent.com/44444710/178913234-a36f76c4-af28-497a-993e-dab94f432c06.png">
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]