boostorg / json

A C++11 library for parsing and serializing JSON to and from a DOM container in memory.
https://boost.org/libs/json
Boost Software License 1.0
434 stars 96 forks source link

Inconsistent behavior for equality checks in tests #523

Open doganulus opened 3 years ago

doganulus commented 3 years ago

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.

vinniefalco commented 3 years ago

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 :)

doganulus commented 3 years ago

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

vinniefalco commented 3 years ago

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?)

doganulus commented 3 years ago

Yes, renaming the helper function would prevent the confusion.