Skip to content

Commit

Permalink
#5108: Unit test covering the new VFS method.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Nov 17, 2020
1 parent cb121ff commit 88e372b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/VFS.cpp
@@ -1,6 +1,7 @@
#include "RadiantTest.h"

#include "ifilesystem.h"
#include "os/path.h"

namespace test
{
Expand Down Expand Up @@ -120,4 +121,24 @@ TEST_F(VfsTest, assetsLstFileHandling)
EXPECT_EQ(fileVis.count("assets.lst"), 0);
}

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

auto archive = GlobalFileSystem().openArchiveInAbsolutePath(pk4Path.string());

EXPECT_TRUE(archive) << "Could not open " << pk4Path.string();

// Check file existence
ASSERT_TRUE(archive->containsFile("materials/tdm_bloom_afx.mtr"));

// Check file read access
auto file = archive->openTextFile("materials/tdm_bloom_afx.mtr");

std::istream fileStream(&(file->getInputStream()));
std::string contents(std::istreambuf_iterator<char>(fileStream), {});
ASSERT_NE(contents.find("textures/AFX/AFXmodulate"), std::string::npos);
}

}

0 comments on commit 88e372b

Please sign in to comment.