Skip to content

Commit c694c43

Browse files
committed
Use testing::EndsWith rather than custom lambda
1 parent 2d50283 commit c694c43

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

test/Filesystem.test.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,17 @@ namespace {
5555
}
5656

5757

58-
constexpr auto EndsWithDirSeparator = []() {
59-
return testing::Truly([](const auto& path) { return path.string().ends_with(NAS2D::Filesystem::dirSeparator()); });
60-
};
61-
62-
63-
constexpr auto HasPartialPath = [](const auto& subString) {
64-
return testing::Truly([&](const auto& path) { return path.string().find(subString) != std::string::npos; });
65-
};
66-
67-
6858
TEST_F(Filesystem, basePath) {
6959
// Result is a directory, and should end with a directory separator
70-
EXPECT_THAT(fs.basePath(), EndsWithDirSeparator());
60+
const auto dirSeparator = NAS2D::Filesystem::dirSeparator();
61+
EXPECT_THAT(fs.basePath(), testing::EndsWith(dirSeparator));
7162
}
7263

7364
TEST_F(Filesystem, prefPath) {
7465
// Result is a directory, and should end with a directory separator
75-
EXPECT_THAT(fs.prefPath(), EndsWithDirSeparator());
76-
EXPECT_THAT(fs.prefPath(), HasPartialPath(AppName));
66+
const auto dirSeparator = NAS2D::Filesystem::dirSeparator();
67+
EXPECT_THAT(fs.prefPath(), testing::EndsWith(dirSeparator));
68+
EXPECT_THAT(fs.prefPath(), testing::EndsWith(AppName + dirSeparator));
7769
}
7870

7971
TEST_F(Filesystem, findInParentsExist) {
@@ -94,8 +86,8 @@ TEST_F(Filesystem, findInParentsNotExist) {
9486
TEST_F(Filesystem, searchPath) {
9587
auto pathList = fs.searchPath();
9688
EXPECT_EQ(3u, pathList.size());
97-
EXPECT_THAT(pathList, Contains(HasPartialPath(AppName)));
98-
EXPECT_THAT(pathList, Contains(HasPartialPath("data/")));
89+
EXPECT_THAT(pathList, Contains(testing::EndsWith(AppName + NAS2D::Filesystem::dirSeparator())));
90+
EXPECT_THAT(pathList, Contains(testing::EndsWith("data/")));
9991
}
10092

10193
TEST_F(Filesystem, directoryList) {
@@ -164,7 +156,7 @@ TEST_F(Filesystem, mountUnmount) {
164156

165157
EXPECT_FALSE(fs.exists(extraFile));
166158
EXPECT_NO_THROW(fs.mount(extraMount));
167-
EXPECT_THAT(fs.searchPath(), Contains(HasPartialPath(extraMount)));
159+
EXPECT_THAT(fs.searchPath(), Contains(testing::EndsWith(extraMount)));
168160
EXPECT_TRUE(fs.exists(extraFile));
169161

170162
EXPECT_NO_THROW(fs.unmount(extraMount));

0 commit comments

Comments
 (0)