Skip to content

Commit

Permalink
gh-674: Fix broken version range test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
PengZheng committed Mar 28, 2024
1 parent 06f1493 commit fc556fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 44 deletions.
52 changes: 9 additions & 43 deletions libs/utils/gtest/src/VersionRangeTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,8 @@ TEST_F(VersionRangeTestSuite, IsInRangeTest) {
celix_version_t* version = celix_version_create(1, 2, 3, nullptr);

{
celix_version_t* low = (celix_version_t*) calloc(1, sizeof(*low));
low->major = 1;
low->minor = 2;
low->micro = 3;
low->qualifier = nullptr;

celix_version_t* high = (celix_version_t*) calloc(1, sizeof(*high));
high->major = 1;
high->minor = 2;
high->micro = 3;
high->qualifier = nullptr;
celix_version_t* low = celix_version_create(1, 2, 3, nullptr);
celix_version_t* high = celix_version_create(1, 2, 3, nullptr);

celix_version_range_t* range = celix_versionRange_createVersionRange(low, true, high, true);
EXPECT_TRUE(range != nullptr);
Expand All @@ -84,27 +75,16 @@ TEST_F(VersionRangeTestSuite, IsInRangeTest) {
}

{
celix_version_t* low = (celix_version_t*) calloc(1, sizeof(*low));
low->major = 1;
low->minor = 2;
low->micro = 3;

celix_version_t* low = celix_version_create(1, 2, 3, nullptr);
celix_version_range_t* range = celix_versionRange_createVersionRange(low, true, nullptr, true);
EXPECT_TRUE(range != nullptr);
EXPECT_TRUE(celix_versionRange_isInRange(range, version));
celix_versionRange_destroy(range);
}

{
celix_version_t* low = (celix_version_t*) calloc(1, sizeof(*low));
low->major = 1;
low->minor = 2;
low->micro = 3;

celix_version_t* high = (celix_version_t*) calloc(1, sizeof(*high));
high->major = 1;
high->minor = 2;
high->micro = 3;
celix_version_t* low = celix_version_create(1, 2, 3, nullptr);
celix_version_t* high = celix_version_create(1, 2, 3, nullptr);

celix_version_range_t* range = celix_versionRange_createVersionRange(low, false, high, true);
EXPECT_TRUE(range != nullptr);
Expand All @@ -114,15 +94,8 @@ TEST_F(VersionRangeTestSuite, IsInRangeTest) {
}

{
celix_version_t* low = (celix_version_t*) calloc(1, sizeof(*low));
low->major = 1;
low->minor = 2;
low->micro = 3;

celix_version_t* high = (celix_version_t*) calloc(1, sizeof(*high));
high->major = 1;
high->minor = 2;
high->micro = 3;
celix_version_t* low = celix_version_create(1, 2, 3, nullptr);
celix_version_t* high = celix_version_create(1, 2, 3, nullptr);

celix_version_range_t* range = celix_versionRange_createVersionRange(low, true, high, false);
EXPECT_TRUE(range != nullptr);
Expand All @@ -132,15 +105,8 @@ TEST_F(VersionRangeTestSuite, IsInRangeTest) {
}

{
celix_version_t* low = (celix_version_t*) calloc(1, sizeof(*low));
low->major = 1;
low->minor = 2;
low->micro = 3;

celix_version_t* high = (celix_version_t*) calloc(1, sizeof(*high));
high->major = 1;
high->minor = 2;
high->micro = 3;
celix_version_t* low = celix_version_create(1, 2, 3, nullptr);
celix_version_t* high = celix_version_create(1, 2, 3, nullptr);

celix_version_range_t* range = celix_versionRange_createVersionRange(low, false, high, false);
EXPECT_TRUE(range != nullptr);
Expand Down
1 change: 0 additions & 1 deletion libs/utils/gtest/src/VersionTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ TEST_F(VersionTestSuite, CompareTest) {
EXPECT_TRUE(result > 0);
celix_version_destroy(compare);

// Compare against a lower version
compare = celix_version_create(1, 2, 3, nullptr);
EXPECT_TRUE(compare != nullptr);
result = celix_version_compareTo(version, compare);
Expand Down
1 change: 1 addition & 0 deletions libs/utils/src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ int celix_version_compareTo(const celix_version_t* version, const celix_version_
if (res != 0) {
result = res;
} else {
// by class invariant qualifier is never null
result = strcmp(version->qualifier, compare->qualifier);
}
}
Expand Down

0 comments on commit fc556fa

Please sign in to comment.