mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Add /W4 to MSVC compile options
Fix the warnings that this generates.
This commit is contained in:
+5
-3
@@ -444,12 +444,14 @@ endif()
|
||||
|
||||
if(MSVC)
|
||||
# Turn off permissive mode to be more standards-compliant and avoid compiler errors.
|
||||
target_compile_options(loot PRIVATE "/permissive-")
|
||||
target_compile_options(libloot_tests PRIVATE "/permissive-")
|
||||
target_compile_options(loot PRIVATE "/permissive-" "/W4")
|
||||
target_compile_options(libloot_tests PRIVATE "/permissive-" "/W4")
|
||||
|
||||
# Set /bigobj to allow building Debug and RelWithDebInfo tests
|
||||
target_compile_options(libloot_internals_tests PRIVATE
|
||||
"/permissive-" "$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:RelWithDebInfo>>:/bigobj>")
|
||||
"/permissive-"
|
||||
"/W4"
|
||||
"$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:RelWithDebInfo>>:/bigobj>")
|
||||
|
||||
set(LOOT_LIBS
|
||||
version
|
||||
|
||||
+3
-2
@@ -65,7 +65,7 @@ LOOT_API void SetLoggingCallback(
|
||||
|
||||
LOOT_API bool IsCompatible(const unsigned int versionMajor,
|
||||
const unsigned int versionMinor,
|
||||
const unsigned int versionPatch) {
|
||||
const unsigned int) {
|
||||
if (versionMajor > 0)
|
||||
return versionMajor == loot::LootVersion::major;
|
||||
else
|
||||
@@ -92,7 +92,8 @@ LOOT_API std::shared_ptr<GameInterface> CreateGameHandle(
|
||||
|
||||
auto resolvedGameLocalPath = ResolvePath(gameLocalPath);
|
||||
if (!gameLocalPath.empty() && !fs::is_directory(resolvedGameLocalPath))
|
||||
throw std::invalid_argument("Given game local path \"" + gameLocalPath.u8string() +
|
||||
throw std::invalid_argument("Given game local path \"" +
|
||||
gameLocalPath.u8string() +
|
||||
"\" does not resolve to a valid directory.");
|
||||
|
||||
return std::make_shared<Game>(game, resolvedGamePath, resolvedGameLocalPath);
|
||||
|
||||
@@ -22,19 +22,18 @@
|
||||
<https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "loot/exception/error_categories.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace loot {
|
||||
namespace detail {
|
||||
class libloadorder_category : public std::error_category {
|
||||
virtual const char* name() const noexcept { return "libloadorder"; }
|
||||
|
||||
virtual std::string message(int ev) const { return "Libloadorder error"; }
|
||||
virtual std::string message(int) const { return "Libloadorder error"; }
|
||||
|
||||
virtual bool equivalent(const std::error_code& code, int condition) const
|
||||
noexcept {
|
||||
virtual bool equivalent(const std::error_code& code) const noexcept {
|
||||
return code.category().name() == name();
|
||||
}
|
||||
};
|
||||
|
||||
+10
-12
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "api/plugin.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
#include "api/game/game.h"
|
||||
#include "api/helpers/crc.h"
|
||||
@@ -233,10 +232,10 @@ bool Plugin::IsValid(const GameType gameType,
|
||||
// Check that the file has a valid extension.
|
||||
if (hasPluginFileExtension(pluginPath.filename().u8string(), gameType)) {
|
||||
bool isValid;
|
||||
int returnCode = esp_plugin_is_valid(GetEspluginGameId(gameType),
|
||||
pluginPath.u8string().c_str(),
|
||||
true,
|
||||
&isValid);
|
||||
auto returnCode = esp_plugin_is_valid(GetEspluginGameId(gameType),
|
||||
pluginPath.u8string().c_str(),
|
||||
true,
|
||||
&isValid);
|
||||
|
||||
if (returnCode != ESP_OK || !isValid) {
|
||||
// Try adding .ghost extension.
|
||||
@@ -270,7 +269,7 @@ void Plugin::Load(const std::filesystem::path& path,
|
||||
GameType gameType,
|
||||
bool headerOnly) {
|
||||
::Plugin* plugin;
|
||||
int ret = esp_plugin_new(
|
||||
auto ret = esp_plugin_new(
|
||||
&plugin, GetEspluginGameId(gameType), path.u8string().c_str());
|
||||
if (ret != ESP_OK) {
|
||||
throw FileAccessError(path.u8string() +
|
||||
@@ -428,11 +427,10 @@ bool hasPluginFileExtension(std::string filename, GameType gameType) {
|
||||
}
|
||||
|
||||
bool isEspOrEsm = boost::iends_with(filename, ".esp") ||
|
||||
boost::iends_with(filename, ".esm");
|
||||
bool isEsl =
|
||||
(gameType == GameType::fo4 || gameType == GameType::fo4vr ||
|
||||
gameType == GameType::tes5se || gameType == GameType::tes5vr) &&
|
||||
boost::iends_with(filename, ".esl");
|
||||
boost::iends_with(filename, ".esm");
|
||||
bool isEsl = (gameType == GameType::fo4 || gameType == GameType::fo4vr ||
|
||||
gameType == GameType::tes5se || gameType == GameType::tes5vr) &&
|
||||
boost::iends_with(filename, ".esl");
|
||||
|
||||
return isEspOrEsm || isEsl;
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
namespace loot {
|
||||
namespace test {
|
||||
void testLoggingCallback(LogLevel level, const char * message) {
|
||||
void testLoggingCallback(LogLevel, const char *) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
struct TestLogger {
|
||||
void callback(LogLevel level, const char * message) {
|
||||
void callback(LogLevel, const char *message) {
|
||||
loggedMessages += std::string(message);
|
||||
}
|
||||
|
||||
@@ -55,9 +55,8 @@ TEST(SetLoggingCallback, shouldAcceptAFreeFunction) {
|
||||
try {
|
||||
CreateGameHandle(GameType::tes4, "dummy");
|
||||
FAIL();
|
||||
}
|
||||
catch (...) {
|
||||
//SetLoggingCallback([](LogLevel, const char *) {});
|
||||
} catch (...) {
|
||||
SetLoggingCallback([](LogLevel, const char *) {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +97,7 @@ TEST(SetLoggingCallback, shouldNotBreakLoggingIfPassedMemberFunctionGoesOutOfSco
|
||||
|
||||
TEST(SetLoggingCallback, shouldAcceptALambdaFunction) {
|
||||
std::string loggedMessages;
|
||||
auto callback = [&](LogLevel level, const char *string) {
|
||||
auto callback = [&](LogLevel, const char *string) {
|
||||
loggedMessages += std::string(string);
|
||||
};
|
||||
SetLoggingCallback(callback);
|
||||
@@ -119,7 +118,7 @@ TEST(SetLoggingCallback, shouldAcceptALambdaFunction) {
|
||||
TEST(SetLoggingCallback, shouldNotBreakLoggingIfPassedLambdaFunctionGoesOutOfScope) {
|
||||
std::string loggedMessages;
|
||||
{
|
||||
SetLoggingCallback([&](LogLevel level, const char *string) {
|
||||
SetLoggingCallback([&](LogLevel, const char *string) {
|
||||
loggedMessages += std::string(string);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -85,8 +85,9 @@ TEST(Filesystem,
|
||||
EXPECT_NE(utf16, path.u16string());
|
||||
}
|
||||
|
||||
TEST(Filesystem,
|
||||
pathStringAndLocaleConstructorDoesNotConvertCharacterEncodingFromUtf8WithClassicLocale) {
|
||||
TEST(
|
||||
Filesystem,
|
||||
pathStringAndLocaleConstructorDoesNotConvertCharacterEncodingFromUtf8WithClassicLocale) {
|
||||
std::string utf8 = u8"Andr\u00E9_settings.toml";
|
||||
std::u16string utf16 = u"Andr\u00E9_settings.toml";
|
||||
|
||||
@@ -101,8 +102,7 @@ TEST(Filesystem,
|
||||
EXPECT_NE(utf16, path.u16string());
|
||||
}
|
||||
#else
|
||||
TEST(Filesystem,
|
||||
pathStringConstructorUsesNativeEncodingOfUtf8) {
|
||||
TEST(Filesystem, pathStringConstructorUsesNativeEncodingOfUtf8) {
|
||||
std::string utf8 = u8"Andr\u00E9_settings.toml";
|
||||
std::u16string utf16 = u"Andr\u00E9_settings.toml";
|
||||
|
||||
@@ -117,7 +117,7 @@ TEST(Filesystem,
|
||||
}
|
||||
|
||||
TEST(Filesystem,
|
||||
pathStringAndLocaleConstructorUsesNativeEncodingOfUtf8WithCUtf8Locale) {
|
||||
pathStringAndLocaleConstructorUsesNativeEncodingOfUtf8WithCUtf8Locale) {
|
||||
std::string utf8 = u8"Andr\u00E9_settings.toml";
|
||||
std::u16string utf16 = u"Andr\u00E9_settings.toml";
|
||||
|
||||
@@ -184,7 +184,8 @@ TEST(Filesystem, equivalentShouldRequireThatBothPathsExist) {
|
||||
auto upper = std::filesystem::path("LICENSE");
|
||||
auto lower = std::filesystem::path("license2");
|
||||
|
||||
EXPECT_THROW(std::filesystem::equivalent(lower, upper), std::filesystem::filesystem_error);
|
||||
EXPECT_THROW(std::ignore = std::filesystem::equivalent(lower, upper),
|
||||
std::filesystem::filesystem_error);
|
||||
}
|
||||
|
||||
TEST(Filesystem, equivalentShouldBeCaseInsensitive) {
|
||||
@@ -194,11 +195,16 @@ TEST(Filesystem, equivalentShouldBeCaseInsensitive) {
|
||||
EXPECT_TRUE(std::filesystem::equivalent(lower, upper));
|
||||
}
|
||||
|
||||
TEST(Filesystem, equivalentCannotHandleCharactersThatAreUnrepresentableInTheSystemCodePage) {
|
||||
auto path1 = std::filesystem::u8path(u8"\u2551\u00BB\u00C1\u2510\u2557\u00FE\u00C3\u00CE.txt");
|
||||
auto path2 = std::filesystem::u8path(u8"\u2551\u00BB\u00C1\u2510\u2557\u00FE\u00C3\u00CE.txt");
|
||||
TEST(
|
||||
Filesystem,
|
||||
equivalentCannotHandleCharactersThatAreUnrepresentableInTheSystemCodePage) {
|
||||
auto path1 = std::filesystem::u8path(
|
||||
u8"\u2551\u00BB\u00C1\u2510\u2557\u00FE\u00C3\u00CE.txt");
|
||||
auto path2 = std::filesystem::u8path(
|
||||
u8"\u2551\u00BB\u00C1\u2510\u2557\u00FE\u00C3\u00CE.txt");
|
||||
|
||||
EXPECT_THROW(std::filesystem::equivalent(path1, path2), std::system_error);
|
||||
EXPECT_THROW(std::ignore = std::filesystem::equivalent(path1, path2),
|
||||
std::system_error);
|
||||
}
|
||||
#else
|
||||
TEST(Filesystem, equivalentShouldNotRequireThatBothPathsExist) {
|
||||
|
||||
@@ -25,10 +25,9 @@ along with LOOT. If not, see
|
||||
#ifndef LOOT_TESTS_API_INTERNALS_METADATA_PLUGIN_CLEANING_DATA
|
||||
#define LOOT_TESTS_API_INTERNALS_METADATA_PLUGIN_CLEANING_DATA
|
||||
|
||||
#include "loot/metadata/plugin_cleaning_data.h"
|
||||
|
||||
#include "api/game/game.h"
|
||||
#include "api/metadata/yaml/plugin_cleaning_data.h"
|
||||
#include "loot/metadata/plugin_cleaning_data.h"
|
||||
#include "tests/common_game_test_fixture.h"
|
||||
|
||||
namespace loot {
|
||||
@@ -46,26 +45,26 @@ protected:
|
||||
// Pass an empty first argument, as it's a prefix for the test instantation,
|
||||
// but we only have the one so no prefix is necessary.
|
||||
INSTANTIATE_TEST_SUITE_P(,
|
||||
PluginCleaningDataTest,
|
||||
::testing::Values(GameType::tes4));
|
||||
PluginCleaningDataTest,
|
||||
::testing::Values(GameType::tes4));
|
||||
|
||||
TEST_P(PluginCleaningDataTest,
|
||||
defaultConstructorShouldLeaveAllCountsAtZeroAndTheUtilityStringEmpty) {
|
||||
PluginCleaningData info;
|
||||
EXPECT_EQ(0, info.GetCRC());
|
||||
EXPECT_EQ(0, info.GetITMCount());
|
||||
EXPECT_EQ(0, info.GetDeletedReferenceCount());
|
||||
EXPECT_EQ(0, info.GetDeletedNavmeshCount());
|
||||
EXPECT_EQ(0u, info.GetCRC());
|
||||
EXPECT_EQ(0u, info.GetITMCount());
|
||||
EXPECT_EQ(0u, info.GetDeletedReferenceCount());
|
||||
EXPECT_EQ(0u, info.GetDeletedNavmeshCount());
|
||||
EXPECT_TRUE(info.GetCleaningUtility().empty());
|
||||
EXPECT_TRUE(info.GetDetail().empty());
|
||||
}
|
||||
|
||||
TEST_P(PluginCleaningDataTest, contentConstructorShouldStoreAllGivenData) {
|
||||
PluginCleaningData info(0x12345678, "cleaner", info_, 2, 10, 30);
|
||||
EXPECT_EQ(0x12345678, info.GetCRC());
|
||||
EXPECT_EQ(2, info.GetITMCount());
|
||||
EXPECT_EQ(10, info.GetDeletedReferenceCount());
|
||||
EXPECT_EQ(30, info.GetDeletedNavmeshCount());
|
||||
EXPECT_EQ(0x12345678u, info.GetCRC());
|
||||
EXPECT_EQ(2u, info.GetITMCount());
|
||||
EXPECT_EQ(10u, info.GetDeletedReferenceCount());
|
||||
EXPECT_EQ(30u, info.GetDeletedNavmeshCount());
|
||||
EXPECT_EQ("cleaner", info.GetCleaningUtility());
|
||||
EXPECT_EQ(info_, info.GetDetail());
|
||||
}
|
||||
@@ -322,7 +321,8 @@ TEST_P(PluginCleaningDataTest,
|
||||
chooseDetailShouldCreateADefaultContentObjectIfNoneExists) {
|
||||
PluginCleaningData dirtyInfo(
|
||||
0xDEADBEEF, "cleaner", std::vector<MessageContent>(), 2, 10, 30);
|
||||
EXPECT_FALSE(dirtyInfo.ChooseDetail(MessageContent::defaultLanguage).has_value());
|
||||
EXPECT_FALSE(
|
||||
dirtyInfo.ChooseDetail(MessageContent::defaultLanguage).has_value());
|
||||
}
|
||||
|
||||
TEST_P(PluginCleaningDataTest,
|
||||
@@ -385,7 +385,7 @@ TEST_P(PluginCleaningDataTest, encodingAsYamlShouldOmitAllZeroCountFields) {
|
||||
YAML::Node node;
|
||||
node = info;
|
||||
|
||||
EXPECT_EQ(0x12345678, node["crc"].as<uint32_t>());
|
||||
EXPECT_EQ(0x12345678u, node["crc"].as<uint32_t>());
|
||||
EXPECT_EQ("cleaner", node["util"].as<std::string>());
|
||||
EXPECT_EQ(info_, node["detail"].as<std::vector<MessageContent>>());
|
||||
EXPECT_FALSE(node["itm"]);
|
||||
@@ -399,12 +399,12 @@ TEST_P(PluginCleaningDataTest,
|
||||
YAML::Node node;
|
||||
node = info;
|
||||
|
||||
EXPECT_EQ(0x12345678, node["crc"].as<uint32_t>());
|
||||
EXPECT_EQ(0x12345678u, node["crc"].as<uint32_t>());
|
||||
EXPECT_EQ("cleaner", node["util"].as<std::string>());
|
||||
EXPECT_EQ(info_, node["detail"].as<std::vector<MessageContent>>());
|
||||
EXPECT_EQ(2, node["itm"].as<unsigned int>());
|
||||
EXPECT_EQ(10, node["udr"].as<unsigned int>());
|
||||
EXPECT_EQ(30, node["nav"].as<unsigned int>());
|
||||
EXPECT_EQ(2u, node["itm"].as<unsigned int>());
|
||||
EXPECT_EQ(10u, node["udr"].as<unsigned int>());
|
||||
EXPECT_EQ(30u, node["nav"].as<unsigned int>());
|
||||
}
|
||||
|
||||
TEST_P(PluginCleaningDataTest,
|
||||
@@ -412,24 +412,25 @@ TEST_P(PluginCleaningDataTest,
|
||||
YAML::Node node = YAML::Load("{crc: 0x12345678, util: cleaner}");
|
||||
PluginCleaningData info = node.as<PluginCleaningData>();
|
||||
|
||||
EXPECT_EQ(0x12345678, info.GetCRC());
|
||||
EXPECT_EQ(0x12345678u, info.GetCRC());
|
||||
EXPECT_TRUE(info.GetDetail().empty());
|
||||
EXPECT_EQ(0, info.GetITMCount());
|
||||
EXPECT_EQ(0, info.GetDeletedReferenceCount());
|
||||
EXPECT_EQ(0, info.GetDeletedNavmeshCount());
|
||||
EXPECT_EQ(0u, info.GetITMCount());
|
||||
EXPECT_EQ(0u, info.GetDeletedReferenceCount());
|
||||
EXPECT_EQ(0u, info.GetDeletedNavmeshCount());
|
||||
EXPECT_EQ("cleaner", info.GetCleaningUtility());
|
||||
}
|
||||
|
||||
TEST_P(PluginCleaningDataTest, decodingFromYamlShouldStoreAllNonZeroCounts) {
|
||||
YAML::Node node = YAML::Load(
|
||||
"{crc: 0x12345678, util: cleaner, detail: info, itm: 2, udr: 10, nav: 30}");
|
||||
"{crc: 0x12345678, util: cleaner, detail: info, itm: 2, udr: 10, nav: "
|
||||
"30}");
|
||||
PluginCleaningData info = node.as<PluginCleaningData>();
|
||||
|
||||
EXPECT_EQ(0x12345678, info.GetCRC());
|
||||
EXPECT_EQ(0x12345678u, info.GetCRC());
|
||||
EXPECT_EQ(info_, info.GetDetail());
|
||||
EXPECT_EQ(2, info.GetITMCount());
|
||||
EXPECT_EQ(10, info.GetDeletedReferenceCount());
|
||||
EXPECT_EQ(30, info.GetDeletedNavmeshCount());
|
||||
EXPECT_EQ(2u, info.GetITMCount());
|
||||
EXPECT_EQ(10u, info.GetDeletedReferenceCount());
|
||||
EXPECT_EQ(30u, info.GetDeletedNavmeshCount());
|
||||
EXPECT_EQ("cleaner", info.GetCleaningUtility());
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,8 @@ along with LOOT. If not, see
|
||||
#ifndef LOOT_TESTS_API_INTERNALS_PLUGIN_TEST
|
||||
#define LOOT_TESTS_API_INTERNALS_PLUGIN_TEST
|
||||
|
||||
#include "api/plugin.h"
|
||||
|
||||
#include "api/game/game.h"
|
||||
#include "api/plugin.h"
|
||||
#include "tests/common_game_test_fixture.h"
|
||||
|
||||
namespace loot {
|
||||
@@ -153,20 +152,20 @@ public:
|
||||
bool IsValidAsLightPlugin() const { return false; }
|
||||
bool IsEmpty() const { return false; }
|
||||
bool LoadsArchive() const { return false; }
|
||||
bool DoFormIDsOverlap(const PluginInterface& plugin) const { return true; }
|
||||
bool DoFormIDsOverlap(const PluginInterface&) const { return true; }
|
||||
};
|
||||
|
||||
// Pass an empty first argument, as it's a prefix for the test instantation,
|
||||
// but we only have the one so no prefix is necessary.
|
||||
INSTANTIATE_TEST_SUITE_P(,
|
||||
PluginTest,
|
||||
::testing::Values(GameType::tes3,
|
||||
GameType::tes4,
|
||||
GameType::tes5,
|
||||
GameType::fo3,
|
||||
GameType::fonv,
|
||||
GameType::fo4,
|
||||
GameType::tes5se));
|
||||
PluginTest,
|
||||
::testing::Values(GameType::tes3,
|
||||
GameType::tes4,
|
||||
GameType::tes5,
|
||||
GameType::fo3,
|
||||
GameType::fonv,
|
||||
GameType::fo4,
|
||||
GameType::tes5se));
|
||||
|
||||
TEST_P(PluginTest, loadingShouldHandleNonAsciiFilenamesCorrectly) {
|
||||
Plugin plugin(game_.Type(),
|
||||
@@ -548,11 +547,11 @@ TEST_P(PluginTest, getRecordAndGroupCountShouldReturnTheHeaderFieldValue) {
|
||||
game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true);
|
||||
|
||||
if (GetParam() == GameType::tes3) {
|
||||
EXPECT_EQ(10, plugin.GetRecordAndGroupCount());
|
||||
EXPECT_EQ(10u, plugin.GetRecordAndGroupCount());
|
||||
} else if (GetParam() == GameType::tes4) {
|
||||
EXPECT_EQ(14, plugin.GetRecordAndGroupCount());
|
||||
EXPECT_EQ(14u, plugin.GetRecordAndGroupCount());
|
||||
} else {
|
||||
EXPECT_EQ(15, plugin.GetRecordAndGroupCount());
|
||||
EXPECT_EQ(15u, plugin.GetRecordAndGroupCount());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,116 +22,16 @@ along with LOOT. If not, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOOT_TESTS_API_INTERNALS_SORTING_PLUGIN_SORTER_TEST
|
||||
#define LOOT_TESTS_API_INTERNALS_SORTING_PLUGIN_SORTER_TEST
|
||||
#ifndef LOOT_TESTS_API_INTERNALS_SORTING_PLUGIN_GRAPH_TEST
|
||||
#define LOOT_TESTS_API_INTERNALS_SORTING_PLUGIN_GRAPH_TEST
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "api/sorting/plugin_graph.h"
|
||||
|
||||
#include "loot/exception/cyclic_interaction_error.h"
|
||||
#include "loot/exception/undefined_group_error.h"
|
||||
#include "tests/common_game_test_fixture.h"
|
||||
|
||||
namespace loot {
|
||||
namespace test {
|
||||
class PluginGraphTest : public CommonGameTestFixture {
|
||||
protected:
|
||||
PluginGraphTest() :
|
||||
game_(GetParam(), dataPath.parent_path(), localPath),
|
||||
masterlistPath_(metadataFilesPath / "userlist.yaml"),
|
||||
cccPath_(dataPath.parent_path() / getCCCFilename()),
|
||||
blankEslEsp("Blank.esl.esp") {}
|
||||
|
||||
void loadInstalledPlugins(Game &game_, bool headersOnly) {
|
||||
std::vector<std::string> plugins({
|
||||
masterFile,
|
||||
blankEsm,
|
||||
blankDifferentEsm,
|
||||
blankMasterDependentEsm,
|
||||
blankDifferentMasterDependentEsm,
|
||||
blankEsp,
|
||||
blankDifferentEsp,
|
||||
blankMasterDependentEsp,
|
||||
blankDifferentMasterDependentEsp,
|
||||
blankPluginDependentEsp,
|
||||
blankDifferentPluginDependentEsp,
|
||||
});
|
||||
|
||||
if (GetParam() == GameType::fo4 || GetParam() == GameType::tes5se) {
|
||||
plugins.push_back(blankEsl);
|
||||
|
||||
if (std::filesystem::exists(dataPath / blankEslEsp)) {
|
||||
plugins.push_back(blankEslEsp);
|
||||
}
|
||||
}
|
||||
|
||||
game_.IdentifyMainMasterFile(masterFile);
|
||||
game_.LoadCurrentLoadOrderState();
|
||||
game_.LoadPlugins(plugins, headersOnly);
|
||||
}
|
||||
|
||||
void GenerateMasterlist() {
|
||||
using std::endl;
|
||||
|
||||
std::ofstream masterlist(masterlistPath_);
|
||||
masterlist << "groups:" << endl
|
||||
<< " - name: earliest" << endl
|
||||
<< " - name: earlier" << endl
|
||||
<< " after:" << endl
|
||||
<< " - earliest" << endl
|
||||
<< " - name: default" << endl
|
||||
<< " after:" << endl
|
||||
<< " - earlier" << endl
|
||||
<< " - name: group1" << endl
|
||||
<< " - name: group2" << endl
|
||||
<< " after:" << endl
|
||||
<< " - group1" << endl
|
||||
<< " - name: group3" << endl
|
||||
<< " after:" << endl
|
||||
<< " - group2" << endl
|
||||
<< " - name: group4" << endl
|
||||
<< " after:" << endl
|
||||
<< " - default" << endl;
|
||||
|
||||
masterlist.close();
|
||||
}
|
||||
|
||||
std::string getCCCFilename() {
|
||||
if (GetParam() == GameType::fo4) {
|
||||
return "Fallout4.ccc";
|
||||
} else {
|
||||
// Not every game has a .ccc file, but Skyrim SE does, so just assume
|
||||
// that.
|
||||
return "Skyrim.ccc";
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateCCCFile() {
|
||||
using std::endl;
|
||||
|
||||
if (GetParam() == GameType::fo4) {
|
||||
std::ofstream ccc(cccPath_);
|
||||
ccc << blankDifferentEsm << endl
|
||||
<< blankDifferentMasterDependentEsm << endl;
|
||||
|
||||
ccc.close();
|
||||
}
|
||||
}
|
||||
|
||||
Game game_;
|
||||
const std::string blankEslEsp;
|
||||
const std::filesystem::path masterlistPath_;
|
||||
const std::filesystem::path cccPath_;
|
||||
};
|
||||
|
||||
// Pass an empty first argument, as it's a prefix for the test instantation,
|
||||
// but we only have the one so no prefix is necessary.
|
||||
INSTANTIATE_TEST_SUITE_P(,
|
||||
PluginGraphTest,
|
||||
::testing::Values(GameType::tes4,
|
||||
GameType::tes5,
|
||||
GameType::tes5se));
|
||||
|
||||
TEST_P(PluginGraphTest, topologicalSortWithNoLoadedPluginsShouldReturnAnEmptyList) {
|
||||
TEST(PluginGraph, topologicalSortWithNoLoadedPluginsShouldReturnAnEmptyList) {
|
||||
PluginGraph graph;
|
||||
std::vector<std::string> sorted = graph.TopologicalSort();
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ protected:
|
||||
cccPath_(dataPath.parent_path() / getCCCFilename()),
|
||||
blankEslEsp("Blank.esl.esp") {}
|
||||
|
||||
void loadInstalledPlugins(Game &game_, bool headersOnly) {
|
||||
void loadInstalledPlugins(Game &game, bool headersOnly) {
|
||||
std::vector<std::string> plugins({
|
||||
masterFile,
|
||||
blankEsm,
|
||||
@@ -64,9 +64,9 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
game_.IdentifyMainMasterFile(masterFile);
|
||||
game_.LoadCurrentLoadOrderState();
|
||||
game_.LoadPlugins(plugins, headersOnly);
|
||||
game.IdentifyMainMasterFile(masterFile);
|
||||
game.LoadCurrentLoadOrderState();
|
||||
game.LoadPlugins(plugins, headersOnly);
|
||||
}
|
||||
|
||||
void GenerateMasterlist() {
|
||||
|
||||
@@ -26,7 +26,6 @@ along with LOOT. If not, see
|
||||
#define LOOT_TESTS_API_INTERNALS_SORTING_PLUGIN_SORTING_DATA_TEST
|
||||
|
||||
#include "api/sorting/plugin_sorting_data.h"
|
||||
|
||||
#include "tests/common_game_test_fixture.h"
|
||||
|
||||
namespace loot {
|
||||
@@ -37,7 +36,7 @@ protected:
|
||||
game_(GetParam(), dataPath.parent_path(), localPath),
|
||||
blankEslEsp("Blank.esl.esp") {}
|
||||
|
||||
void loadInstalledPlugins(Game &game_, bool headersOnly) {
|
||||
void loadInstalledPlugins(Game &game, bool headersOnly) {
|
||||
std::vector<std::string> plugins({
|
||||
masterFile,
|
||||
blankEsm,
|
||||
@@ -60,9 +59,9 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
game_.IdentifyMainMasterFile(masterFile);
|
||||
game_.LoadCurrentLoadOrderState();
|
||||
game_.LoadPlugins(plugins, headersOnly);
|
||||
game.IdentifyMainMasterFile(masterFile);
|
||||
game.LoadCurrentLoadOrderState();
|
||||
game.LoadPlugins(plugins, headersOnly);
|
||||
}
|
||||
|
||||
Game game_;
|
||||
@@ -72,13 +71,12 @@ protected:
|
||||
// Pass an empty first argument, as it's a prefix for the test instantation,
|
||||
// but we only have the one so no prefix is necessary.
|
||||
INSTANTIATE_TEST_SUITE_P(,
|
||||
PluginSortingDataTest,
|
||||
::testing::Values(GameType::tes3,
|
||||
GameType::tes4,
|
||||
GameType::fo4));
|
||||
PluginSortingDataTest,
|
||||
::testing::Values(GameType::tes3,
|
||||
GameType::tes4,
|
||||
GameType::fo4));
|
||||
|
||||
TEST_P(PluginSortingDataTest,
|
||||
lightFlaggedEspFilesShouldNotBeTreatedAsMasters) {
|
||||
TEST_P(PluginSortingDataTest, lightFlaggedEspFilesShouldNotBeTreatedAsMasters) {
|
||||
if (GetParam() == GameType::fo4 || GetParam() == GameType::tes5se) {
|
||||
ASSERT_NO_THROW(
|
||||
std::filesystem::copy(dataPath / blankEsl, dataPath / blankEslEsp));
|
||||
@@ -140,8 +138,9 @@ TEST_P(PluginSortingDataTest,
|
||||
EXPECT_EQ(4, plugin.NumOverrideFormIDs());
|
||||
}
|
||||
|
||||
TEST_P(PluginSortingDataTest,
|
||||
constructorShouldUseTotalRecordCountAsOverrideFormIdCountForTes3PluginWithAMasterThatIsNotLoaded) {
|
||||
TEST_P(
|
||||
PluginSortingDataTest,
|
||||
constructorShouldUseTotalRecordCountAsOverrideFormIdCountForTes3PluginWithAMasterThatIsNotLoaded) {
|
||||
if (GetParam() != GameType::tes3) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user