Reputation: 778
I'm having trouble figuring out how to correctly setup the macro in FFF for faking a function that takes an array of strings. Trying to pass the 2D array seems illegal so I created a typedef to try and get around that.
/*Macro for faking the function*/
#define getFilesInDir fake_getFilesInDir
FAKE_VOID_FUNC7(fake_getFilesInDir, char*, FileNames, uint16_t, char*, char*,
int32_t*, uint8_t)
#define MAX_FILENAME_SIZE 400
typedef char FileNames[][MAX_FILENAME_SIZE];
/*Declaration in another header file*/
void getFilesInDir(char* dir, FileNames filesInDir, uint16_t maxNumFiles, char* includeString,
char* excludeString, int32_t* fileCnt, uint8_t recursive);
/*Code under test*/
char fileNames[CFU_MAX_NUM_FILES][MAX_FILENAME_SIZE]; //Local variable
//...
getFilesInDir(path, fileNames, CFU_MAX_NUM_FILES, (char*)cfgExt, NULL, &fileCount, false);
This code gives me 2 errors. arg1_history: missing subscript and struct fake_getFilesInDir_Fake has an illegal zero-sized array
Any idea what I'm doing wrong?
Upvotes: 0
Views: 374
Reputation: 778
I figured it out. The proper typedef for the 2D array is:
typedef char (*FileNames)[MAX_FILENAME_SIZE];
Upvotes: 1