mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Improve API version compatibility check
It has worked so far, but generally pre-1.0.0 versions use the minor version number to determine compatibility.
This commit is contained in:
+4
-1
@@ -203,7 +203,10 @@ LOOT_API void loot_cleanup() {
|
||||
// Returns whether this version of LOOT supports the API from the given
|
||||
// LOOT version. Abstracts LOOT API stability policy away from clients.
|
||||
LOOT_API bool loot_is_compatible(const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch) {
|
||||
return versionMajor == loot::g_version_major;
|
||||
if (versionMajor > 0)
|
||||
return versionMajor == loot::g_version_major;
|
||||
else
|
||||
return versionMinor == loot::g_version_minor;
|
||||
}
|
||||
|
||||
// Returns the version string for this version of LOOT.
|
||||
|
||||
@@ -54,26 +54,18 @@ TEST(GetBuildID, HandlesValidInput) {
|
||||
EXPECT_STRNE("@GIT_COMMIT_STRING@", revision); // The CMake placeholder.
|
||||
}
|
||||
|
||||
TEST(IsCompatible, HandlesCompatibleVersion) {
|
||||
TEST(IsCompatible, shouldReturnTrueWithEqualMajorAndMinorVersionsAndUnequalPatchVersion) {
|
||||
unsigned int vMajor, vMinor, vPatch;
|
||||
EXPECT_EQ(loot_ok, loot_get_version(&vMajor, &vMinor, &vPatch));
|
||||
|
||||
EXPECT_TRUE(loot_is_compatible(vMajor, vMinor, vPatch));
|
||||
// Test somewhat arbitrary variations.
|
||||
EXPECT_TRUE(loot_is_compatible(vMajor, vMinor + 1, vPatch + 1));
|
||||
if (vMinor > 0 && vPatch > 0)
|
||||
EXPECT_TRUE(loot_is_compatible(vMajor, vMinor - 1, vPatch - 1));
|
||||
EXPECT_TRUE(loot_is_compatible(vMajor, vMinor, vPatch + 1));
|
||||
}
|
||||
|
||||
TEST(IsCompatible, HandlesIncompatibleVersion) {
|
||||
TEST(IsCompatible, shouldReturnFalseWithEqualMajorVersionAndUnequalMinorAndPatchVersions) {
|
||||
unsigned int vMajor, vMinor, vPatch;
|
||||
EXPECT_EQ(loot_ok, loot_get_version(&vMajor, &vMinor, &vPatch));
|
||||
|
||||
EXPECT_FALSE(loot_is_compatible(vMajor + 1, vMinor, vPatch));
|
||||
// Test somewhat arbitrary variations.
|
||||
EXPECT_FALSE(loot_is_compatible(vMajor + 1, vMinor + 1, vPatch + 1));
|
||||
if (vMinor > 0 && vPatch > 0)
|
||||
EXPECT_FALSE(loot_is_compatible(vMajor + 1, vMinor - 1, vPatch - 1));
|
||||
EXPECT_FALSE(loot_is_compatible(vMajor, vMinor + 1, vPatch + 1));
|
||||
}
|
||||
|
||||
TEST(GetErrorMessage, HandlesInputCorrectly) {
|
||||
|
||||
Reference in New Issue
Block a user