Adding floating-point Hamcrest matchers
We explored better floating-point comparisons in the previous section, and now it’s time to use the comparison code in the unit test library. Some of the code should be moved into Test.h
where it fits better and can then be used by the test library. The rest of the code that was written should stay in Hamcrest.cpp
because it’s code that supports the tests.
The code that needs to be moved is the compareEq
function and the three getMargin
functions that compareEq
calls to get the margins. We also need to move the includes of cmath
and limits
into Test.h
, like this:
#include <cmath>
#include <cstring>
#include <limits>
#include <map>
#include <ostream>
#include <string_view>
#include <type_traits>
#include <vector>
The three getMargin
functions and the compareEq
function can be moved into Test.h
, right before the first override of the confirm
function that accepts Booleans. None...