Skip to content

Commit

Permalink
#5108: Add a quick unit test covering VirtualFileSystem::forEachFileI…
Browse files Browse the repository at this point in the history
…nArchive
  • Loading branch information
codereader committed Nov 20, 2020
1 parent 0f615a1 commit 96e15e3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/VFS.cpp
Expand Up @@ -141,4 +141,22 @@ TEST_F(VfsTest, openArchiveInAbsolutePath)
ASSERT_NE(contents.find("textures/AFX/AFXmodulate"), std::string::npos);
}

TEST_F(VfsTest, VisitEachFileInArchive)
{
fs::path pk4Path = _context.getTestResourcePath();
pk4Path /= "tdm_example_mtrs.pk4";

// Use a visitor to walk the tree
std::set<std::string> foundFiles;
GlobalFileSystem().forEachFileInArchive(
pk4Path.string(), "*",
[&](const vfs::FileInfo& fi) { foundFiles.insert(fi.name); },
0
);

EXPECT_EQ(foundFiles.count("materials/tdm_ai_monsters_spiders.mtr"), 1);
EXPECT_EQ(foundFiles.count("materials/tdm_ai_nobles.mtr"), 1);
EXPECT_EQ(foundFiles.count("materials/tdm_bloom_afx.mtr"), 1);
}

}

0 comments on commit 96e15e3

Please sign in to comment.