1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 10:22:52 +01:00
openrw/tests/test_FileIndex.cpp
Anonymous Maarten 21c722f7cc run_tests: fix 'Type has to implement operator<< to be printable' (MSVC compiler)
fixes:
error C2338: Type has to implement operator<< to be printable
error C2679: binary '<<': no operator found which takes a right-hand
operand of type 'const boost::filesystem::path::string_type' (or there
is no acceptable conversion)
2018-01-05 06:21:34 +00:00

56 lines
1.5 KiB
C++

#include <boost/test/unit_test.hpp>
#include <platform/FileIndex.hpp>
#include "test_Globals.hpp"
#include <rw/filesystem.hpp>
namespace fs = rwfs;
BOOST_AUTO_TEST_SUITE(FileIndexTests)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_directory_paths) {
FileIndex index;
index.indexGameDirectory(Global::getGamePath());
{
std::string upperpath{"DATA/CULLZONE.DAT"};
auto truepath = index.findFilePath(upperpath);
BOOST_ASSERT(!truepath.empty());
BOOST_CHECK(upperpath != truepath);
fs::path expected{Global::getGamePath()};
expected /= "data/CULLZONE.DAT";
BOOST_CHECK_EQUAL(truepath.string(), expected.string());
}
{
std::string upperpath{"DATA/MAPS/COMNBTM/COMNBTM.IPL"};
auto truepath = index.findFilePath(upperpath);
BOOST_ASSERT(!truepath.empty());
BOOST_CHECK(upperpath != truepath);
fs::path expected{Global::getGamePath()};
expected /= "data/maps/comnbtm/comNbtm.ipl";
BOOST_CHECK_EQUAL(truepath.string(), expected.string());
}
}
BOOST_AUTO_TEST_CASE(test_file) {
FileIndex index;
index.indexTree(Global::getGamePath() + "/data");
auto handle = index.openFile("cullzone.dat");
BOOST_CHECK(handle != nullptr);
}
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);
}
#endif
BOOST_AUTO_TEST_SUITE_END()