Unit Testing on a c code which writes on files in a particular directory : <p>I've written a C code which takes a path to a directory and a string s. 
After opening the directory, the code looks for files with a particular extension and write the string given as a second argument to the last line of these files and a \n after it. 
This is all my function does (finding files with a particular extension and writing something at the end of the file). 
The C code for the function is done but I need to write some tests for the function using Cunit and I don't have any Idea how to write them. I've just written down what I want to test (below) but I don't know how to write them using Cunit.
Can anyone help me with that? 
Thanks</p>

<ul>
<li>check if the user checks if the string 's' is nULL => segmentation fault</li>
<li>check if bad address is given to the path argument of the function 
when there is no ".extension" file </li>
<li>check if strcmp compares ".extension" and not "extension" </li>
<li>check if the user uses == instead of strcmp to compare the extension</li>
<li>check if the string 's' is written on a new line </li>
<li>check the size of the string 's' sent to write => sent without \0 by strlen and the type is size_t</li>
<li>check if the file is opened for writing (and not read only)</li>
<li>check if string 's' is converted to void* before giving it to write function </li>
<li>check if the return value of open ("fd") is checked </li>
<li>check if the return value of opening a directory is checked (null or not)</li>
<li>check if the return value of reading a directory is checked (null or not)</li>
<li>check if the extension is checked (the string 's' is not added to all the files with other extensions</li>
<li>check if the function ignores the '.' et '..' directories => DT_REG </li>
<li>check if the file is closed after being opened</li>
<li>check the return value of close </li>
<li>check if the directory is closed after being opened</li>
<li>check the return value of the directory</li>
</ul>
