diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2022-04-26 12:51:36 +0200 |
---|---|---|
committer | Alberto Sartori <alberto.sartori@huawei.com> | 2022-04-26 13:44:00 +0200 |
commit | ad0560d65f1b5ad1ed042608df049963d53b15ec (patch) | |
tree | 953d89cec793ef51ccc058035aecafdf66d8d665 | |
parent | 233a5c2dd1bf7275a6c0217b25073acdaee39a63 (diff) | |
download | justbuild-ad0560d65f1b5ad1ed042608df049963d53b15ec.tar.gz |
test {Files,Directories}Iterator for an empty dir
-rw-r--r-- | test/buildtool/file_system/TARGETS | 3 | ||||
-rw-r--r-- | test/buildtool/file_system/directory_entries.test.cpp | 31 |
2 files changed, 33 insertions, 1 deletions
diff --git a/test/buildtool/file_system/TARGETS b/test/buildtool/file_system/TARGETS index 25189a5c..37b3c7d8 100644 --- a/test/buildtool/file_system/TARGETS +++ b/test/buildtool/file_system/TARGETS @@ -64,6 +64,7 @@ , "TESTS": { "type": "install" , "tainted": ["test"] - , "deps": ["file_root", "file_system_manager", "git_tree"] + , "deps": + ["file_root", "file_system_manager", "git_tree", "directory_entries"] } } diff --git a/test/buildtool/file_system/directory_entries.test.cpp b/test/buildtool/file_system/directory_entries.test.cpp index ed32ff65..86f91493 100644 --- a/test/buildtool/file_system/directory_entries.test.cpp +++ b/test/buildtool/file_system/directory_entries.test.cpp @@ -119,3 +119,34 @@ TEST_CASE("Get entries of a git tree", "[directory_entries]") { CHECK(counter == 2); } } + +TEST_CASE("Get entries of an empty directory", "[directory_entries]") { + // CreateDirectoryEntriesMap returns + // FileRoot::DirectoryEntries{FileRoot::DirectoryEntries::pairs_t{}} in case + // of a missing directory, which represents an empty directory + + auto dir_entries = + FileRoot::DirectoryEntries{FileRoot::DirectoryEntries::pairs_t{}}; + // of course, no files should be there + CHECK_FALSE(dir_entries.ContainsFile("test_repo.bundle")); + { + // FilesIterator should be an empty range + auto counter = 0; + for (const auto& x : dir_entries.FilesIterator()) { + CHECK_FALSE(dir_entries.ContainsFile(x)); // should never be called + ++counter; + } + + CHECK(counter == 0); + } + { + // DirectoriesIterator should be an empty range + auto counter = 0; + for (const auto& x : dir_entries.DirectoriesIterator()) { + CHECK(dir_entries.ContainsFile(x)); // should never be called + ++counter; + } + + CHECK(counter == 0); + } +}
\ No newline at end of file |