mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Refactor getting LOOT version string
This commit is contained in:
@@ -195,7 +195,7 @@ namespace loot {
|
||||
void LootSettings::updateLastVersion() {
|
||||
std::lock_guard<std::recursive_mutex> guard(mutex);
|
||||
|
||||
lastVersion = std::to_string(LootVersion::major) + "." + std::to_string(LootVersion::minor) + "." + std::to_string(LootVersion::patch);
|
||||
lastVersion = LootVersion::string();
|
||||
}
|
||||
|
||||
YAML::Node LootSettings::toYaml() const {
|
||||
|
||||
@@ -29,4 +29,8 @@ namespace loot {
|
||||
const unsigned int LootVersion::minor = 9;
|
||||
const unsigned int LootVersion::patch = 1;
|
||||
const std::string LootVersion::revision = "@GIT_COMMIT_STRING@";
|
||||
|
||||
std::string LootVersion::string() {
|
||||
return std::to_string(major) + '.' + std::to_string(minor) + '.' + std::to_string(patch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace loot {
|
||||
static const unsigned int minor;
|
||||
static const unsigned int patch;
|
||||
static const std::string revision;
|
||||
|
||||
static std::string string();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -566,7 +566,7 @@ namespace loot {
|
||||
|
||||
std::string QueryHandler::GetVersion() {
|
||||
BOOST_LOG_TRIVIAL(info) << "Getting LOOT version.";
|
||||
YAML::Node version(to_string(LootVersion::major) + "." + to_string(LootVersion::minor) + "." + to_string(LootVersion::patch) + "." + LootVersion::revision);
|
||||
YAML::Node version(LootVersion::string() + "." + LootVersion::revision);
|
||||
return JSON::stringify(version);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace loot {
|
||||
};
|
||||
|
||||
TEST_F(LootSettingsTest, defaultConstructorShouldSetDefaultValues) {
|
||||
const std::string currentVersion = std::to_string(LootVersion::major) + "." + std::to_string(LootVersion::minor) + "." + std::to_string(LootVersion::patch);
|
||||
const std::string currentVersion = LootVersion::string();
|
||||
const std::vector<GameSettings> expectedGameSettings({
|
||||
GameSettings(GameSettings::tes4),
|
||||
GameSettings(GameSettings::tes5),
|
||||
@@ -410,7 +410,7 @@ namespace loot {
|
||||
}
|
||||
|
||||
TEST_F(LootSettingsTest, updateLastVersionShouldSetValueToCurrentLootVersion) {
|
||||
const std::string currentVersion = std::to_string(LootVersion::major) + "." + std::to_string(LootVersion::minor) + "." + std::to_string(LootVersion::patch);
|
||||
const std::string currentVersion = LootVersion::string();
|
||||
YAML::Node inputYaml;
|
||||
inputYaml["lastVersion"] = "v0.7.1";
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ along with LOOT. If not, see
|
||||
#ifndef LOOT_TEST_BACKEND_HELPERS_VERSION
|
||||
#define LOOT_TEST_BACKEND_HELPERS_VERSION
|
||||
|
||||
#include "backend/app/loot_version.h"
|
||||
#include "backend/helpers/version.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
@@ -35,11 +36,7 @@ namespace loot {
|
||||
TEST(Version, shouldExtractVersionFromApiDll) {
|
||||
// Use the API DLL built.
|
||||
Version version(boost::filesystem::path("loot_api.dll"));
|
||||
std::string expected(
|
||||
std::to_string(LootVersion::major) + "." +
|
||||
std::to_string(LootVersion::minor) + "." +
|
||||
std::to_string(LootVersion::patch) + ".0"
|
||||
);
|
||||
std::string expected(LootVersion::string() + ".0");
|
||||
EXPECT_EQ(expected, version.AsString());
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user