I am trying to make some unit tests for database functions in C language, but i am not aware is it possible with cmocka? I couldn't find any example on the internet for database testing using cmocka, so i wonder if someone has an example of testing database functions with cmocka. For example it could be connecting to database, reading from database, writing to database, updating database, any example would help.
EDIT Let's say i have the following function in a separate Base.c file:
static void dbclose(int SQLnumber)
{
if (hDbc[SQLnumber])
{
SQLDisconnect(hDbc[SQLnumber]);
SQLFreeConnect(hDbc[SQLnumber]);
}
hDbc[SQLnumber] = NULL;
}
How to define the wrap method in CMakeLists.txt so i could use it in Tests.c file? Also, is it possible to wrap the SQLDisconnect and SQLFreeConnect from the SQL API separately?