4.3. Bitwise assertions
In the beginning of this chapter I described a primitive assertion as one that’s so cryptic because of its low abstraction level that its intent and meaning remain a mystery to the reader. A bitwise assertion is a special case of primitive assertion that I feel warrants special mention because its elements are close to home for so many programmers and far from home for equally many programmers.
Perhaps an example will help concretize this hazard.
4.3.1. Example
Let’s take a look at a concrete example that exhibits this particular smell. Consider the test in this listing.
Listing 4.8. Bitwise assertion, also known as “what did this operator do again?”
public class PlatformTest { @Test public void platformBitLength() { assertTrue(Platform.IS_32_BIT ...
Get Effective Unit Testing 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.