json icon indicating copy to clipboard operation
json copied to clipboard

Inconsistent behavior for equality checks in tests

Open doganulus opened this issue 4 years ago • 4 comments

Currently some test cases use a helper equal function defined in test/test.hpp to check the equality between json::values.

https://github.com/boostorg/json/blob/ee8d72d8502b409b5561200299cad30ccdb91415/test/test.hpp#L971-L1054

Its behavior is inconsistent with the operator== of json::value as it distinguishes the cases of int64 and uint64.

doganulus avatar Mar 07 '21 09:03 doganulus

The point of equal in the test is to check for bitwise equality. This is a different use-case than operator==. Otherwise, the tests would just use == instead of calling equal :)

vinniefalco avatar Mar 07 '21 15:03 vinniefalco

Ah equality over wires... ok, got it.

doganulus avatar Mar 07 '21 19:03 doganulus

Ah equality over wires

Not exactly "wire" but rather, that the tests expect a bitwise equality instead of a semantic equality (which could invalidate the test). In other words this version of equal is specifically for helping the tests ensure that the correct bit-patterns are produced. We could rename this if it would help (bitwise_equal?)

vinniefalco avatar Mar 07 '21 21:03 vinniefalco

Yes, renaming the helper function would prevent the confusion.

doganulus avatar Mar 08 '21 07:03 doganulus