lukas-krecan/JsonUnit

Numerical comparison regression in 2.36.0

adrogon opened this issue · 4 comments

Hello, using json-unit-fluent, this was passing in 2.35.0:

assertThatJson("{\"a\": 1.0, \"b\": 1.00}")
    .node("a").isEqualTo(1.0)
    .node("b").isEqualTo(1.0);
}

but is failing in 2.36.0 with Different value found in node "b", expected: <1.0> but was: <1.00>.

It does not look documented, so probably an unintended change?

Thank you :)

Hi, thanks for reporting. It's both. It was a fix of Jackson config I did back in May and I have forgotten to mention it in the release notes. But the new behavior is intended, see this. I will mention it in the release notes.

So how do you make the second test pass without using withTolerance(0.0)?
Do you need to use BigDecimal("1.00")? Because .node("b").isEqualTo(1.00) of course fails.

        assertThatJson("{\"a\": 1.0, \"b\": 1.00}")
            .node("b").isEqualTo("1.00");

should work

Thank you for your reply, I'll stick with the .withTolerance(0.0) idea instead, and thank you for maintaining the library :)