13 Testing and debugging

This chapter covers

  • Avoiding runtime errors by moving them to compile-time
  • Understanding the benefits of pure functions in unit testing
  • Automatically generating test cases for pure functions
  • Testing code by comparing against existing solutions
  • Testing monad-based concurrent systems

Computers are becoming omnipresent. We have smart watches, TVs, toasters, and more. Consequences of bugs in software today range from minor annoyances to serious problems, including identity theft and even danger to our lives.

Therefore, it’s more important than ever that the software we write is correct: that it does exactly what it should and doesn’t contain bugs. Although this sounds like a no-brainer—because who in their right mind ...

Get Functional Programming in 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.