Refactor getting LOOT version string

This commit is contained in:
Oliver Hamlet
2016-07-13 20:47:22 +01:00
parent 95937596da
commit e4d656df1d
6 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -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 {
+4
View File
@@ -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);
}
}
+2
View File
@@ -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();
};
}
+1 -1
View File
@@ -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);
}
+2 -2
View File
@@ -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";
+2 -5
View File
@@ -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