#include "sntptest.h"
+#include <fstream>
+#include <string>
+
+using std::ifstream;
+using std::string;
+using std::ios;
+
class fileHandlingTest : public sntptest {
protected:
enum DirectoryType {
return path;
}
+
+ int GetFileSize(ifstream& file) {
+ int initial = file.tellg();
+
+ file.seekg(0, ios::end);
+ int length = file.tellg();
+ file.seekg(initial);
+
+ return length;
+ }
+
+ void CompareFileContent(ifstream& expected, ifstream& actual) {
+ int currentLine = 1;
+ while (actual.good() && expected.good()) {
+ string actualLine, expectedLine;
+ getline(actual, actualLine);
+ getline(expected, expectedLine);
+
+ EXPECT_EQ(expectedLine, actualLine) << "Comparision failed on line " << currentLine;
+ currentLine++;
+ }
+ }
};
#include "ntp_stdlib.h" // For estrdup()
};
-#include <fstream>
-using std::ifstream;
-using std::ios;
-using std::string;
-
/*
* We access some parts of the kod database directly, without
* going through the public interface
kod_db_file = estrdup("/dev/null");
}
-
- int GetFileSize(ifstream& file) {
- int initial = file.tellg();
-
- file.seekg(0, std::ios::end);
- int length = file.tellg();
- file.seekg(initial);
-
- return length;
- }
-
- void CompareFileContent(ifstream& expected, ifstream& actual) {
- int currentLine = 1;
- while (actual.good() && expected.good()) {
- string actualLine, expectedLine;
- getline(actual, actualLine);
- getline(expected, expectedLine);
-
- EXPECT_EQ(expectedLine, actualLine) << "Comparision failed on line " << currentLine;
- currentLine++;
- }
- }
};
TEST_F(kodFileTest, ReadEmptyFile) {