Boost logo

Boost Users :

Subject: [Boost-users] [test] bitwise checks for non-integer types
From: Norbert Wenzel (norbert.wenzel.lists_at_[hidden])
Date: 2017-02-12 09:44:06


I was just surprised that BOOST_CHECK_BITWISE_EQUAL does not simply take
two memory ranges and compares them bitwise, but requires integers (or
types that support bit shifting). I wanted to compare two floats after
binary deserialization and wanted to make sure all bits had been placed
correctly, before doing value comparison.

What I came up with now is a reinterpret_cast to uint8_t* and then using
bitwise comparison byte for byte. I would have expected the test
framework to do exactly that internally.

Is comparing anything besides integers bitwise considered a bad practice
or is there another reason for this limitation of BITWISE_EQUAL? If
there is a rationale could that be documented at [0], since the
documentation currently only speaks of unconstrained "values".

thanks,
Norbert

[0]
http://www.boost.org/doc/libs/1_63_0/libs/test/doc/html/boost_test/utf_reference/testing_tool_ref/assertion_boost_level_bitwise_eq.html


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net