unit test static function in C

Thread Starter


Joined Feb 13, 2012
Hi team,

Just wondering how other people unit test their static function in C? What I am doing now is either test the function first before I change them into static function. Or test the higher level functions that call the static functions only. (not testing the static function directly).

Here is how I usually structure my files.

/* file.h */
int publicFunction(int, int);

/* file.c */
static int privateFunction(int, int);

static int privateFunction(int data_1, int data_2)
    return data_1 * data_2;

int publicFunction(int data_1, int data_2)
    /* do stuff */
    return data_1 + data_2 + privateFunction(data_1, data_2);