-
Book Overview & Buying
-
Table Of Contents
Test-Driven Development with C++
By :
In a way, the bool confirms do test for equality. They ensure that the actual bool value is equal to the expected value. This is what the new confirms that are introduced in this chapter will do, too. The only difference is that the CONFIRM_TRUE and CONFIRM_FALSE confirms don’t need to accept a parameter for the expected value. Their expected value is implied in their name. We can do this for bool types because there are only two possible values.
However, let’s say that we want to verify that an actual int value equals 1. Do we really want a macro that’s called CONFIRM_1? We would need billions of macros for each possible 32-bit int and even more for a 64-bit int. And verifying text strings to make sure they match expected values becomes impossible with this approach.
Instead, all we need to do is modify the macros for the other types to accept both an expected value and an actual value. If the two values are not equal to each other, then...