This commit is contained in:
Zhao Jianing
2026-09-15 14:36:17 +08:00
committed by GitHub
3 changed files with 8 additions and 11 deletions
@@ -108,11 +108,8 @@ class OnlineParserTest {
MetricFamily metricFamily1 = metricFamilyMap1.get(metricFamilyName);
Set<Double> metricValueSet = metricFamily2.getMetricList().stream().map(MetricFamily.Metric::getValue).collect(Collectors.toSet());
metricFamily1.getMetricList().forEach(metric -> {
// this is for something different between two algorithms above, and both of them is current on this parsing behavior.
if (!(metric.getValue() == Double.POSITIVE_INFINITY || metric.getValue() == Double.NEGATIVE_INFINITY)) {
if (!metricValueSet.contains(metric.getValue())) {
fail();
}
if (!metricValueSet.contains(metric.getValue())) {
fail();
}
});
});
@@ -153,9 +153,9 @@ public class StrBuffer {
*/
public static double parseDouble(String s) {
if (POSITIVE_INF.equalsIgnoreCase(s)) {
return POSITIVE_INF_VALUE;
return Double.POSITIVE_INFINITY;
} else if (NEGATIVE_INF.equalsIgnoreCase(s)) {
return NEGATIVE_INF_VALUE;
return Double.NEGATIVE_INFINITY;
}
return Double.parseDouble(s);
}
@@ -91,10 +91,10 @@ class StrBufferTest {
assertEquals(123.45, buffer.toDouble());
buffer = new StrBuffer("+inf");
assertEquals(POSITIVE_INF_VALUE, buffer.toDouble());
assertEquals(Double.POSITIVE_INFINITY, buffer.toDouble());
buffer = new StrBuffer("-inf");
assertEquals(NEGATIVE_INF_VALUE, buffer.toDouble());
assertEquals(Double.NEGATIVE_INFINITY, buffer.toDouble());
}
@Test
@@ -144,8 +144,8 @@ class StrBufferTest {
void testParseDouble() {
assertEquals(123.45, StrBuffer.parseDouble("123.45"));
assertEquals(POSITIVE_INF_VALUE, StrBuffer.parseDouble("+inf"));
assertEquals(NEGATIVE_INF_VALUE, StrBuffer.parseDouble("-inf"));
assertEquals(Double.POSITIVE_INFINITY, StrBuffer.parseDouble("+inf"));
assertEquals(Double.NEGATIVE_INFINITY, StrBuffer.parseDouble("-inf"));
}
}