add Path::listdir()
This commit is contained in:
1 parent
5df998661b
commit
ff51d17344
3 files changed
+33
No files matched your search
@@ -1,5 +1,6 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "Path.h"
|
||||
#include <algorithm>
|
||||
|
||||
TEST(Path_dirname, returns_dot_when_no_directory_component)
|
||||
{
|
||||
@@ -98,3 +99,13 @@ TEST(Path_is_dir, returns_false_for_nonexistent_path)
|
||||
{
|
||||
EXPECT_FALSE(Path::is_dir("non.existent"));
|
||||
}
|
||||
|
||||
|
||||
TEST(Path_listdir, returns_list_of_directory_contents)
|
||||
{
|
||||
auto dir_ents = Path::listdir("test");
|
||||
EXPECT_NE(dir_ents->end(), std::find_if(dir_ents->begin(), dir_ents->end(), [](std::shared_ptr<std::string> & s) { return *s == "."; }));
|
||||
EXPECT_NE(dir_ents->end(), std::find_if(dir_ents->begin(), dir_ents->end(), [](std::shared_ptr<std::string> & s) { return *s == ".."; }));
|
||||
EXPECT_NE(dir_ents->end(), std::find_if(dir_ents->begin(), dir_ents->end(), [](std::shared_ptr<std::string> & s) { return *s == "src"; }));
|
||||
EXPECT_EQ(dir_ents->end(), std::find_if(dir_ents->begin(), dir_ents->end(), [](std::shared_ptr<std::string> & s) { return *s == "foo"; }));
|
||||
}
|
||||
Reference in new issue
Block a user