Skip to content

Commit

Permalink
Add VFSFixture to shadersTest
Browse files Browse the repository at this point in the history
VFSFixture is now in a separate header file so it can be included by both
vfsTest and shadersTest.
  • Loading branch information
Matthew Mott committed Mar 12, 2019
1 parent 4f46db8 commit 17be980
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 28 deletions.
3 changes: 2 additions & 1 deletion radiant/Makefile.am
Expand Up @@ -459,4 +459,5 @@ facePlaneTest_LDADD = $(top_builddir)/libs/math/libmath.la
vfsTest_SOURCES = test/vfsTest.cpp $(VFS_SOURCES)
vfsTest_LDFLAGS = $(FILESYSTEM_LIBS) $(Z_LIBS)

shadersTest_SOURCES = test/shadersTest.cpp $(SHADERS_SOURCES)
shadersTest_SOURCES = test/shadersTest.cpp $(SHADERS_SOURCES) $(VFS_SOURCES)
shadersTest_LDFLAGS = $(FILESYSTEM_LIBS) $(Z_LIBS)
29 changes: 29 additions & 0 deletions radiant/test/VFSFixture.h
@@ -0,0 +1,29 @@
#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;

VFSFixture()
{
// Setup the output stream
GlobalOutputStream().setStream(std::cout);

// Configure search paths and extensions
pakExtensions.insert("pk4");
searchPaths.insertIfNotExists(
std::string(getenv("srcdir")) + "/test/data/vfs_root"
);

// Initialise the VFS
fs.initialise(searchPaths, pakExtensions);
}
};
4 changes: 3 additions & 1 deletion radiant/test/shadersTest.cpp
@@ -1,6 +1,8 @@
#define BOOST_TEST_MODULE shadersTest
#include <boost/test/included/unit_test.hpp>

#include "VFSFixture.h"

#include "radiant/shaders/ShaderFileLoader.h"
#include "radiant/shaders/textures/GLTextureManager.h"

Expand Down Expand Up @@ -29,7 +31,7 @@ struct MockShaderLibrary
{ return true; }
};

BOOST_AUTO_TEST_CASE(loaderShaderFiles)
BOOST_FIXTURE_TEST_CASE(loaderShaderFiles, VFSFixture)
{
MockShaderLibrary library;
shaders::ShaderFileLoader<MockShaderLibrary> loader("materials", library);
Expand Down
27 changes: 1 addition & 26 deletions radiant/test/vfsTest.cpp
@@ -1,32 +1,7 @@
#define BOOST_TEST_MODULE vfsTest
#include <boost/test/included/unit_test.hpp>

#include "radiant/vfs/Doom3FileSystem.h"

struct VFSFixture
{
// The Doom3FileSystem under test
vfs::Doom3FileSystem fs;

// Initialisation parameters for the Doom3FileSystem
vfs::VirtualFileSystem::ExtensionSet pakExtensions;
vfs::SearchPaths searchPaths;

VFSFixture()
{
// Setup the output stream
GlobalOutputStream().setStream(std::cout);

// Configure search paths and extensions
pakExtensions.insert("pk4");
searchPaths.insertIfNotExists(
std::string(getenv("srcdir")) + "/test/data/vfs_root"
);

// Initialise the VFS
fs.initialise(searchPaths, pakExtensions);
}
};
#include "VFSFixture.h"

BOOST_FIXTURE_TEST_CASE(constructFileSystemModule, VFSFixture)
{
Expand Down

0 comments on commit 17be980

Please sign in to comment.