/
VFSFixture.h
37 lines (30 loc) · 979 Bytes
/
VFSFixture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include "radiant/vfs/Doom3FileSystem.h"
// Fixture for tests that make use of the VFS
struct VFSFixture
{
// The Doom3FileSystem under test
vfs::Doom3FileSystem fs;
// Initialisation parameters for the Doom3FileSystem
vfs::VirtualFileSystem::ExtensionSet pakExtensions;
vfs::SearchPaths searchPaths;
// Get the srcdir environment variable (set by Automake)
std::string srcdir() const
{
const char* envVal = getenv("srcdir");
if (envVal)
return std::string(envVal);
else
throw std::runtime_error("srcdir not set");
}
VFSFixture()
{
// Setup the output stream
GlobalOutputStream().setStream(std::cout);
// Configure search paths and extensions
pakExtensions.insert("pk4");
searchPaths.insertIfNotExists(srcdir() + "/test/data/vfs_root");
// Initialise the VFS
fs.initialise(searchPaths, pakExtensions);
}
};