13
How to Test Floating-Point and Custom Values
We first encountered the need to test floating-point values in Chapter 5, Adding More Confirm Types, and created a simple solution that would let us compare floating-point values within a margin of error. We need the small margin because floating-point values that are close and might even look identical when displayed are almost always not exactly equal. These small differences make it hard to verify test results.
The main topics in this chapter are as follows:
- More precise floating-point comparisons
- Adding floating-point Hamcrest matchers
- Writing custom Hamcrest matchers
We’re going to improve the simple solution developed earlier into a much better way to compare floating-point values that ...
Get Test-Driven Development with C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.