Skip to content

Commit a9d1bfb

Browse files
committed
Add unit tests for Filesystem::findInParents
1 parent c705c71 commit a9d1bfb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/Filesystem.test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ TEST_F(Filesystem, prefPath) {
7676
EXPECT_THAT(fs.prefPath(), HasPartialPath(AppName));
7777
}
7878

79+
TEST_F(Filesystem, findInParentsExist) {
80+
// Try to find the unit test project folder
81+
const auto folder = "test/";
82+
EXPECT_THAT(fs.findInParents(folder, fs.basePath()), testing::EndsWith(folder));
83+
EXPECT_THAT(fs.findInParents(folder, fs.basePath(), 4), testing::EndsWith(folder));
84+
}
85+
86+
TEST_F(Filesystem, findInParentsNotExist) {
87+
EXPECT_EQ("", fs.findInParents("FolderThatDoesNotExist/", fs.basePath(), 0));
88+
EXPECT_EQ("", fs.findInParents("FolderThatDoesNotExist/", fs.basePath(), 1));
89+
EXPECT_EQ("", fs.findInParents("FolderThatDoesNotExist/", fs.basePath(), 2));
90+
EXPECT_EQ("", fs.findInParents("FolderThatDoesNotExist/", fs.basePath(), 3));
91+
EXPECT_EQ("", fs.findInParents("FolderThatDoesNotExist/", fs.basePath(), 4));
92+
}
93+
7994
TEST_F(Filesystem, searchPath) {
8095
auto pathList = fs.searchPath();
8196
EXPECT_EQ(3u, pathList.size());

0 commit comments

Comments
 (0)