mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 00:39:43 +00:00
Use std::filesystem for unit tests temporary files path.
This commit is contained in:
parent
92680ab9cf
commit
b82176410b
4 changed files with 7 additions and 5 deletions
|
@ -109,8 +109,8 @@ file(DOWNLOAD
|
|||
)
|
||||
|
||||
target_compile_definitions(openmw_test_suite
|
||||
PRIVATE OPENMW_DATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data"
|
||||
OPENMW_TEST_SUITE_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
PRIVATE OPENMW_DATA_DIR=u8"${CMAKE_CURRENT_BINARY_DIR}/data"
|
||||
OPENMW_TEST_SUITE_SOURCE_DIR=u8"${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
|
||||
target_precompile_headers(openmw_test_suite PRIVATE
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace
|
|||
{
|
||||
static constexpr std::size_t sInitialOffset = 324;
|
||||
static constexpr std::size_t sSkip = 100;
|
||||
const Files::PathContainer mDataDirs {{std::string(OPENMW_DATA_DIR)}};
|
||||
const Files::PathContainer mDataDirs {{std::filesystem::path{OPENMW_DATA_DIR}}};
|
||||
const Files::Collections mFileCollections {mDataDirs, true};
|
||||
const std::string mContentFile = "template.omwgame";
|
||||
const std::filesystem::path mContentFilePath = mFileCollections.getCollection(".omwgame").getPath(mContentFile);
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace
|
|||
|
||||
struct EsmLoaderTest : Test
|
||||
{
|
||||
const Files::PathContainer mDataDirs {{std::string(OPENMW_DATA_DIR)}};
|
||||
const Files::PathContainer mDataDirs {{std::filesystem::path{OPENMW_DATA_DIR}}};
|
||||
const Files::Collections mFileCollections {mDataDirs, true};
|
||||
const std::vector<std::string> mContentFiles {{"template.omwgame"}};
|
||||
};
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include <components/to_utf8/to_utf8.hpp>
|
||||
#include <components/misc/strings/conversion.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#ifndef OPENMW_TEST_SUITE_SOURCE_DIR
|
||||
#define OPENMW_TEST_SUITE_SOURCE_DIR ""
|
||||
|
@ -24,7 +26,7 @@ namespace
|
|||
{
|
||||
std::ifstream file;
|
||||
file.exceptions(std::ios::failbit | std::ios::badbit);
|
||||
file.open(std::string(OPENMW_TEST_SUITE_SOURCE_DIR) + "/toutf8/data/" + fileName);
|
||||
file.open(std::filesystem::path{ OPENMW_TEST_SUITE_SOURCE_DIR } / "toutf8" / "data" / Misc::StringUtils::stringToU8String(fileName));
|
||||
std::stringstream buffer;
|
||||
buffer << file.rdbuf();
|
||||
return buffer.str();
|
||||
|
|
Loading…
Reference in a new issue