mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Added loot_get_build_id() to API.
Also added tests for it, and fixed an undocumented return value for loot_get_version().
This commit is contained in:
+10
-1
@@ -217,6 +217,15 @@ LOOT_API unsigned int loot_get_version(unsigned int * const versionMajor, unsign
|
||||
return loot_ok;
|
||||
}
|
||||
|
||||
LOOT_API unsigned int loot_get_build_id(const char ** const revision) {
|
||||
if (revision == nullptr)
|
||||
return c_error(loot_error_invalid_args, "Null message pointer passed.");
|
||||
|
||||
*revision = loot::g_build_revision;
|
||||
|
||||
return loot_ok;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// Lifecycle Management Functions
|
||||
////////////////////////////////////
|
||||
@@ -263,7 +272,7 @@ LOOT_API unsigned int loot_create_db(loot_db * const db,
|
||||
return c_error(loot_error_invalid_args, "Given local data path \"" + std::string(gameLocalPath) + "\" is not a valid directory.");
|
||||
|
||||
*db = new _loot_db_int(clientGame, game_path, game_local_path);
|
||||
}
|
||||
}
|
||||
catch (loot::error& e) {
|
||||
return c_error(e);
|
||||
}
|
||||
|
||||
@@ -312,11 +312,21 @@ extern "C"
|
||||
* A pointer to the minor version number.
|
||||
* @param versionPatch
|
||||
* A pointer to the patch version number.
|
||||
* @returns A return code.
|
||||
*/
|
||||
LOOT_API unsigned int loot_get_version(unsigned int * const versionMajor,
|
||||
unsigned int * const versionMinor,
|
||||
unsigned int * const versionPatch);
|
||||
|
||||
/**
|
||||
* @brief Get the Git revision of the code from which the binary was
|
||||
* built.
|
||||
* @param revision
|
||||
* A pointer to the shortened Git revision ID string.
|
||||
* @returns A return code.
|
||||
*/
|
||||
LOOT_API unsigned int loot_get_build_id(const char ** const revision);
|
||||
|
||||
/**@}*/
|
||||
/**********************************************************************//**
|
||||
* @name Lifecycle Management Functions
|
||||
|
||||
@@ -41,6 +41,17 @@ TEST(GetVersion, HandlesValidInput) {
|
||||
EXPECT_EQ(loot_ok, loot_get_version(&vMajor, &vMinor, &vPatch));
|
||||
}
|
||||
|
||||
TEST(GetBuildID, HandlesNullInput) {
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_get_build_id(NULL));
|
||||
}
|
||||
|
||||
TEST(GetBuildID, HandlesValidInput) {
|
||||
const char * revision;
|
||||
EXPECT_EQ(loot_ok, loot_get_build_id(&revision));
|
||||
EXPECT_STRNE(NULL, revision);
|
||||
EXPECT_STRNE("@GIT_COMMIT_STRING@", revision); // The CMake placeholder.
|
||||
}
|
||||
|
||||
TEST(IsCompatible, HandlesCompatibleVersion) {
|
||||
unsigned int vMajor, vMinor, vPatch;
|
||||
EXPECT_EQ(loot_ok, loot_get_version(&vMajor, &vMinor, &vPatch));
|
||||
|
||||
Reference in New Issue
Block a user