1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-10 04:42:38 +01:00
openrw/tests/test_FileIndex.cpp

54 lines
1.3 KiB
C++

#include <boost/test/unit_test.hpp>
#include <platform//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()