clang-format
This commit is contained in:
@@ -10,9 +10,13 @@ class RealFilesystemTest : public ::testing::Test {
|
|||||||
protected:
|
protected:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
// Create a unique temporary directory for this test run
|
// Create a unique temporary directory for this test run
|
||||||
temp_dir = std::filesystem::temp_directory_path() /
|
temp_dir =
|
||||||
("finger_test_" + std::to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(
|
std::filesystem::temp_directory_path() /
|
||||||
std::chrono::high_resolution_clock::now().time_since_epoch()).count()));
|
("finger_test_" +
|
||||||
|
std::to_string(
|
||||||
|
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||||
|
std::chrono::high_resolution_clock::now().time_since_epoch())
|
||||||
|
.count()));
|
||||||
|
|
||||||
// Create the temporary directory
|
// Create the temporary directory
|
||||||
std::filesystem::create_directories(temp_dir);
|
std::filesystem::create_directories(temp_dir);
|
||||||
@@ -30,7 +34,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper method to create a test file with specified content
|
// Helper method to create a test file with specified content
|
||||||
void createTestFile(const std::string& filename, const std::string& content) {
|
void createTestFile(const std::string &filename, const std::string &content) {
|
||||||
std::filesystem::path file_path = test_base_path / filename;
|
std::filesystem::path file_path = test_base_path / filename;
|
||||||
std::ofstream file(file_path);
|
std::ofstream file(file_path);
|
||||||
if (file.is_open()) {
|
if (file.is_open()) {
|
||||||
@@ -40,13 +44,13 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper method to create a test directory
|
// Helper method to create a test directory
|
||||||
void createTestDirectory(const std::string& dirname) {
|
void createTestDirectory(const std::string &dirname) {
|
||||||
std::filesystem::path dir_path = test_base_path / dirname;
|
std::filesystem::path dir_path = test_base_path / dirname;
|
||||||
std::filesystem::create_directories(dir_path);
|
std::filesystem::create_directories(dir_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper method to check if a file exists in the test directory
|
// Helper method to check if a file exists in the test directory
|
||||||
bool testFileExists(const std::string& filename) {
|
bool testFileExists(const std::string &filename) {
|
||||||
return std::filesystem::exists(test_base_path / filename);
|
return std::filesystem::exists(test_base_path / filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,13 +139,13 @@ TEST_F(RealFilesystemTest, ProcessWithEmptyUserFile) {
|
|||||||
|
|
||||||
TEST_F(RealFilesystemTest, ProcessWithComplexUserInfo) {
|
TEST_F(RealFilesystemTest, ProcessWithComplexUserInfo) {
|
||||||
std::string user_content = "Name: Alice Smith\n"
|
std::string user_content = "Name: Alice Smith\n"
|
||||||
"Title: Senior Developer\n"
|
"Title: Senior Developer\n"
|
||||||
"Department: Engineering\n"
|
"Department: Engineering\n"
|
||||||
"Office: Building A, Room 123\n"
|
"Office: Building A, Room 123\n"
|
||||||
"Phone: +1-555-0123\n"
|
"Phone: +1-555-0123\n"
|
||||||
"Email: [email protected]\n"
|
"Email: [email protected]\n"
|
||||||
"Projects: Project Alpha, Project Beta\n"
|
"Projects: Project Alpha, Project Beta\n"
|
||||||
"Skills: C++, Python, JavaScript";
|
"Skills: C++, Python, JavaScript";
|
||||||
createTestFile("alice", user_content);
|
createTestFile("alice", user_content);
|
||||||
|
|
||||||
std::string result = process("alice", real_fs, test_base_path);
|
std::string result = process("alice", real_fs, test_base_path);
|
||||||
@@ -162,8 +166,8 @@ TEST_F(RealFilesystemTest, ProcessWithFileContainingOnlyNewlines) {
|
|||||||
createTestFile("newlineuser", user_content);
|
createTestFile("newlineuser", user_content);
|
||||||
|
|
||||||
std::string result = process("newlineuser", real_fs, test_base_path);
|
std::string result = process("newlineuser", real_fs, test_base_path);
|
||||||
// RealFilesystemWrapper reads line by line, so the last empty line after the final \n
|
// RealFilesystemWrapper reads line by line, so the last empty line after the
|
||||||
// is not read as a separate line, resulting in "\n\n\r\n"
|
// final \n is not read as a separate line, resulting in "\n\n\r\n"
|
||||||
EXPECT_EQ(result, "\n\n\r\n");
|
EXPECT_EQ(result, "\n\n\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user