O'Reilly logo

Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming by Zed A. Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exercise 30. Automated Testing

Automated testing is used frequently in other languages like Python and Ruby, but rarely used in C. Part of the reason comes from the difficulty of automatically loading and testing pieces of C code. In this chapter, we’ll create a very small testing framework and get your skeleton directory to build an example test case.

The framework I’m going to use, and you’ll include in your c-skeleton skeleton, is called minunit which started with a tiny snippet of code by Jera Design. I evolved it further, to be this:

minunit.h

  1   #undef NDEBUG   2   #ifndef _minunit_h   3   #define _minunit_h   4   5   #include <stdio.h>   6   #include <dbg.h>   7   #include <stdlib.h>   8   9   #define ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required