mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Implemented PluginSorter class tests.
This commit is contained in:
@@ -28,10 +28,167 @@ along with LOOT. If not, see
|
||||
#include "backend/plugin_sorter.h"
|
||||
#include "tests/fixtures.h"
|
||||
|
||||
class PluginSorter : public SkyrimTest {};
|
||||
class PluginSorter : public SkyrimTest {
|
||||
protected:
|
||||
inline virtual void SetUp() {
|
||||
SkyrimTest::SetUp();
|
||||
|
||||
game = loot::Game(loot::Game::tes5);
|
||||
game.SetGamePath(dataPath.parent_path());
|
||||
ASSERT_NO_THROW(game.Init(false, localPath));
|
||||
|
||||
callback = [](const std::string&) {};
|
||||
}
|
||||
|
||||
loot::Game game;
|
||||
std::function<void(const std::string&)> callback;
|
||||
};
|
||||
|
||||
TEST_F(PluginSorter, Sort_NoPlugins) {
|
||||
loot::PluginSorter ps;
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
EXPECT_TRUE(sorted.empty());
|
||||
}
|
||||
|
||||
TEST_F(PluginSorter, Sort) {
|
||||
FAIL() << "Test is unimplemented";
|
||||
ASSERT_NO_THROW(game.LoadPlugins(false));
|
||||
|
||||
loot::PluginSorter ps;
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
EXPECT_EQ(std::list<loot::Plugin>({
|
||||
loot::Plugin("Skyrim.esm"),
|
||||
loot::Plugin("Blank.esm"),
|
||||
loot::Plugin("Blank - Different.esm"),
|
||||
loot::Plugin("Blank - Master Dependent.esm"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esm"),
|
||||
loot::Plugin("Blank.esp"),
|
||||
loot::Plugin("Blank - Different.esp"),
|
||||
loot::Plugin("Blank - Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Plugin Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Plugin Dependent.esp"),
|
||||
}), sorted);
|
||||
|
||||
// Check stability.
|
||||
sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
EXPECT_EQ(std::list<loot::Plugin>({
|
||||
loot::Plugin("Skyrim.esm"),
|
||||
loot::Plugin("Blank.esm"),
|
||||
loot::Plugin("Blank - Different.esm"),
|
||||
loot::Plugin("Blank - Master Dependent.esm"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esm"),
|
||||
loot::Plugin("Blank.esp"),
|
||||
loot::Plugin("Blank - Different.esp"),
|
||||
loot::Plugin("Blank - Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Plugin Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Plugin Dependent.esp"),
|
||||
}), sorted);
|
||||
}
|
||||
|
||||
TEST_F(PluginSorter, Sort_HeadersOnly) {
|
||||
ASSERT_NO_THROW(game.LoadPlugins(true));
|
||||
|
||||
loot::PluginSorter ps;
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
EXPECT_EQ(std::list<loot::Plugin>({
|
||||
loot::Plugin("Skyrim.esm"),
|
||||
loot::Plugin("Blank.esm"),
|
||||
loot::Plugin("Blank - Different.esm"),
|
||||
loot::Plugin("Blank - Master Dependent.esm"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esm"),
|
||||
loot::Plugin("Blank.esp"),
|
||||
loot::Plugin("Blank - Different.esp"),
|
||||
loot::Plugin("Blank - Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Plugin Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Plugin Dependent.esp"),
|
||||
}), sorted);
|
||||
}
|
||||
|
||||
TEST_F(PluginSorter, Sort_WithPriority) {
|
||||
ASSERT_NO_THROW(game.LoadPlugins(false));
|
||||
loot::Plugin plugin("Blank - Different Master Dependent.esp");
|
||||
plugin.Priority(-1100000);
|
||||
game.userlist.AddPlugin(plugin);
|
||||
|
||||
loot::PluginSorter ps;
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
EXPECT_EQ(std::list<loot::Plugin>({
|
||||
loot::Plugin("Skyrim.esm"),
|
||||
loot::Plugin("Blank.esm"),
|
||||
loot::Plugin("Blank - Different.esm"),
|
||||
loot::Plugin("Blank - Master Dependent.esm"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esm"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esp"),
|
||||
loot::Plugin("Blank.esp"),
|
||||
loot::Plugin("Blank - Different.esp"),
|
||||
loot::Plugin("Blank - Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Plugin Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Plugin Dependent.esp"),
|
||||
}), sorted);
|
||||
}
|
||||
|
||||
TEST_F(PluginSorter, Sort_WithLoadAfter) {
|
||||
ASSERT_NO_THROW(game.LoadPlugins(false));
|
||||
loot::Plugin plugin("Blank.esp");
|
||||
plugin.LoadAfter({
|
||||
loot::File("Blank - Different.esp"),
|
||||
loot::File("Blank - Different Plugin Dependent.esp"),
|
||||
});
|
||||
game.userlist.AddPlugin(plugin);
|
||||
|
||||
loot::PluginSorter ps;
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
EXPECT_EQ(std::list<loot::Plugin>({
|
||||
loot::Plugin("Skyrim.esm"),
|
||||
loot::Plugin("Blank.esm"),
|
||||
loot::Plugin("Blank - Different.esm"),
|
||||
loot::Plugin("Blank - Master Dependent.esm"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esm"),
|
||||
loot::Plugin("Blank - Different.esp"),
|
||||
loot::Plugin("Blank - Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Plugin Dependent.esp"),
|
||||
loot::Plugin("Blank.esp"),
|
||||
loot::Plugin("Blank - Plugin Dependent.esp"),
|
||||
}), sorted);
|
||||
}
|
||||
|
||||
TEST_F(PluginSorter, Sort_WithRequirements) {
|
||||
ASSERT_NO_THROW(game.LoadPlugins(false));
|
||||
loot::Plugin plugin("Blank.esp");
|
||||
plugin.Reqs({
|
||||
loot::File("Blank - Different.esp"),
|
||||
loot::File("Blank - Different Plugin Dependent.esp"),
|
||||
});
|
||||
game.userlist.AddPlugin(plugin);
|
||||
|
||||
loot::PluginSorter ps;
|
||||
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
|
||||
EXPECT_EQ(std::list<loot::Plugin>({
|
||||
loot::Plugin("Skyrim.esm"),
|
||||
loot::Plugin("Blank.esm"),
|
||||
loot::Plugin("Blank - Different.esm"),
|
||||
loot::Plugin("Blank - Master Dependent.esm"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esm"),
|
||||
loot::Plugin("Blank - Different.esp"),
|
||||
loot::Plugin("Blank - Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Master Dependent.esp"),
|
||||
loot::Plugin("Blank - Different Plugin Dependent.esp"),
|
||||
loot::Plugin("Blank.esp"),
|
||||
loot::Plugin("Blank - Plugin Dependent.esp"),
|
||||
}), sorted);
|
||||
}
|
||||
|
||||
TEST_F(PluginSorter, Sort_HasCycle) {
|
||||
ASSERT_NO_THROW(game.LoadPlugins(false));
|
||||
loot::Plugin plugin("Blank.esm");
|
||||
plugin.LoadAfter({loot::File("Blank - Master Dependent.esm")});
|
||||
game.userlist.AddPlugin(plugin);
|
||||
|
||||
loot::PluginSorter ps;
|
||||
EXPECT_ANY_THROW(ps.Sort(game, loot::Language::english, callback));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user