1 #ifndef FILE_HANDLING_TEST_H
2 #define FILE_HANDLING_TEST_H
16 const char * CreatePath(const char* filename, enum DirectoryType argument) {
18 char * path = malloc (sizeof (char) * 256);
21 if (m_params.size() >= argument + 1) {
22 path = m_params[argument];
25 if (path[path.size()-1] != DIR_SEP && !path.empty()) {
26 path.append(1, DIR_SEP);
29 //strcpy(path,filename);
30 //path.append(filename);
35 if (getcwd(cwd, sizeof(cwd)) != NULL)
36 printf("Current working dir: %s\n", cwd);
38 printf("builddir is <@builddir@>\n");
39 printf("abs_srcdir is <@abs_srcdir@>\n");
40 strcpy(path,"@abs_srcdir@/data/");
43 strcat(path,filename);
44 printf("PATH IS : %s\n",path);
48 int GetFileSize(FILE *file) {
50 fseek(file, 0L, SEEK_END);
51 int length = ftell(file);
52 fseek(file, 0L, SEEK_SET);
54 //int initial = file.tellg();
56 //file.seekg(0, ios::end);
57 //int length = file.tellg();
58 //file.seekg(initial);
63 bool CompareFileContent(FILE* expected, FILE* actual) {
66 char actualLine[1024];
67 char expectedLine[1024];
68 size_t lenAct = sizeof actualLine;
69 size_t lenExp = sizeof expectedLine;
71 while ( ( (fgets(actualLine, lenAct, actual)) != NULL)
72 && ( (fgets(expectedLine, lenExp, expected)) != NULL )
75 //printf("%s",actualLine);
76 //printf("%s",expectedLine);
78 if( strcmp(actualLine,expectedLine) !=0 ){
79 printf("Comparision failed on line %d",currentLine);
83 //I removed this and modified the test kodFile.c, because there shouldn't be any ASSERTs in .h files!
84 //TEST_ASSERT_EQUAL_STRING(actualLine,expectedLine);//EXPECT_EQ(expectedLine, actualLine) << "Comparision failed on line " << currentLine;
91 void ClearFile(const char * filename) {
92 FILE * clear = fopen(filename, "w");//ios::trunc); //similar to truncate, I GUESS???!
94 //I removed this because there shouldn't be any ASSERTs in .h files!
95 //TEST_ASSERT_TRUE(clear != NULL);
100 #endif // FILE_HANDLING_TEST_H