aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2006-01-28 20:52:16 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2006-01-28 20:52:16 +0000
commitba5801299006895b21384599c6197782cb084b2d (patch)
tree14aa0c661d35d71c3f3e72d4d02c779980b78e4c
parent7e90ff3d510787d2548e6c5f21df910321f9b675 (diff)
downloadpaludis-ba5801299006895b21384599c6197782cb084b2d.tar.gz
paludis-ba5801299006895b21384599c6197782cb084b2d.tar.xz
Better equal_star_compare, plus some testcases.
-rw-r--r--paludis/version_spec.cc2
-rw-r--r--paludis/version_spec_TEST.cc4
2 files changed, 5 insertions, 1 deletions
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index 3b863d6..375eea3 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -297,7 +297,7 @@ VersionSpec::tilde_compare(const VersionSpec & other) const
bool
VersionSpec::equal_star_compare(const VersionSpec & other) const
{
- return std::equal(other._implementation->text.begin(), other._implementation->text.end(), _implementation->text.begin());
+ return 0 == _implementation->text.compare(0, other._implementation->text.length(), other._implementation->text);
}
std::size_t
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index bcee052..be9cffc 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -158,6 +158,10 @@ namespace test_cases
TEST_CHECK(VersionSpec("1.2.1").equal_star_compare(VersionSpec("1.2")));
TEST_CHECK(VersionSpec("2.2").equal_star_compare(VersionSpec("2")));
TEST_CHECK(VersionSpec("2").equal_star_compare(VersionSpec("2")));
+ TEST_CHECK(VersionSpec("2.59").equal_star_compare(VersionSpec("2.5")));
+ TEST_CHECK(VersionSpec("2.59_alpha5-r1").equal_star_compare(VersionSpec("2.59_alpha")));
+ TEST_CHECK(! VersionSpec("2").equal_star_compare(VersionSpec("2.5")));
+ TEST_CHECK(! VersionSpec("2.59").equal_star_compare(VersionSpec("2.50")));
TEST_CHECK(! VersionSpec("1").equal_star_compare(VersionSpec("2")));
}