1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-13 22:24:17 +01:00
openrw/rwengine/tests/test_FileIndex.cpp
Daniel Evans 25f28dbb42 New File handling implementation
- move FileHandle into a separate header
- Implement FileIndex, a system to normalize filenames and sources
2015-02-26 03:57:28 +00:00

53 lines
1.3 KiB
C++

#include <boost/test/unit_test.hpp>
#include <core/FileIndex.hpp>
#include <test_globals.hpp>
BOOST_AUTO_TEST_SUITE(FileIndexTests)
BOOST_AUTO_TEST_CASE(test_index)
{
FileIndex index;
index.indexDirectory(Global::getGamePath()+"/data");
FileIndex::IndexData data;
BOOST_CHECK( index.findFile("cullzone.dat", data) );
BOOST_CHECK_EQUAL( data.filename, "cullzone.dat" );
BOOST_CHECK_EQUAL( data.originalName, "CULLZONE.DAT" );
BOOST_CHECK( data.archive.empty() );
}
BOOST_AUTO_TEST_CASE(test_file)
{
FileIndex index;
index.indexDirectory(Global::getGamePath()+"/data");
auto handle = index.openFile("cullzone.dat");
BOOST_CHECK( handle != nullptr );
}
BOOST_AUTO_TEST_CASE(test_index_archive)
{
FileIndex index;
index.indexArchive(Global::getGamePath()+"/models/gta3.img");
FileIndex::IndexData data;
BOOST_CHECK( index.findFile("landstal.dff", data) );
BOOST_CHECK_EQUAL( data.filename, "landstal.dff" );
BOOST_CHECK_EQUAL( data.originalName, "landstal.dff" );
BOOST_CHECK_EQUAL( data.archive, "gta3.img" );
}
BOOST_AUTO_TEST_CASE(test_file_archive)
{
FileIndex index;
index.indexArchive(Global::getGamePath()+"/models/gta3.img");
auto handle = index.openFile("landstal.dff");
BOOST_CHECK( handle != nullptr );
}
BOOST_AUTO_TEST_SUITE_END()