Every customer is happy to get correct software. It is often claimed that the Haskell type system provides software correctness. Unfortunately, some limitations exist to what the current type system is able to guarantee. That’s why we still need to test our code. Haskell supports many approaches to code correctness assurance, ranging from unit testing and property testing to lightweight formal verification. We don’t have to apply all of them, but it’s a good idea to apply at least some. Once we have tests, it’s much easier to refactor the code or make it run faster.
In this chapter, I present testing with an example of IP address processing built from scratch. We’ll continue working with this example later in this book to explore code behavior and tune performance.
We will work on a small utility program, namely, an IPv4 filtering application. It should check whether a given IPv4 address falls into some range from a large IP address range database (given as a text file). This utility could be part of a large project implementing an IP firewall in Haskell.