1 #ifndef FILE_HANDLING_TEST_H
2 #define FILE_HANDLING_TEST_H
4 #include "g_sntptest.h"
13 class fileHandlingTest : public sntptest {
20 std::string CreatePath(const char* filename, DirectoryType argument) {
23 if (m_params.size() >= argument + 1) {
24 path = m_params[argument];
27 if (path[path.size()-1] != DIR_SEP && !path.empty()) {
28 path.append(1, DIR_SEP);
30 path.append(filename);
35 int GetFileSize(ifstream& file) {
36 int initial = file.tellg();
38 file.seekg(0, ios::end);
39 int length = file.tellg();
45 void CompareFileContent(ifstream& expected, ifstream& actual) {
47 while (actual.good() && expected.good()) {
48 string actualLine, expectedLine;
49 getline(actual, actualLine);
50 getline(expected, expectedLine);
52 EXPECT_EQ(expectedLine, actualLine) << "Comparision failed on line " << currentLine;
57 void ClearFile(const std::string& filename) {
58 std::ofstream clear(filename.c_str(), ios::trunc);
59 ASSERT_TRUE(clear.good());
64 #endif // FILE_HANDLING_TEST_H