aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2009-05-16 22:50:35 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2009-05-16 22:52:24 +0100
commit9a4df007e07770d83a50f549c73b9f6d28a7022c (patch)
tree55e090784a74850b83ff17265d96e897d1e2410d
parentfb4784f9503227fc6ba6a61b588248afa56c5acb (diff)
downloadpaludis-9a4df007e07770d83a50f549c73b9f6d28a7022c.tar.gz
paludis-9a4df007e07770d83a50f549c73b9f6d28a7022c.tar.xz
Make nice_equal_star_compare do something (relatively) nice for float-like things
-rw-r--r--paludis/version_spec.cc3
-rw-r--r--paludis/version_spec_TEST.cc22
2 files changed, 25 insertions, 0 deletions
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index c9e1d5c..5957ef8 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -429,6 +429,9 @@ namespace
{
if (b.type() == vsct_empty)
return std::make_pair(true, true);
+ else if (a.type() == vsct_floatlike && b.type() == vsct_floatlike && next(b_it) == b_it_end &&
+ a.number_value().compare(0, b.number_value().length(), b.number_value()) == 0)
+ return std::make_pair(true, true);
else if (a.type() == b.type() && next(b_it) == b_it_end &&
(b.type() == vsct_alpha || b.type() == vsct_beta || b.type() == vsct_pre ||
b.type() == vsct_rc || b.type() == vsct_patch) &&
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index 4b6fc33..b4704f2 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -164,6 +164,17 @@ namespace test_cases
TEST_CHECK(! VersionSpec("1_pre1", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("1_pre0", VersionSpecOptions())));
TEST_CHECK(! VersionSpec("1_alpha1", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("1_alpha-r1", VersionSpecOptions())));
TEST_CHECK(! VersionSpec("1_alpha1", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("1_beta", VersionSpecOptions())));
+
+ TEST_CHECK(VersionSpec("010", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("010", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("010", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("01", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.010", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("2.01", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.0105", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("2.010", VersionSpecOptions())));
+ TEST_CHECK(! VersionSpec("2.0135", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("2.010", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.010.1", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("2.01", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.011.1", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("2.01", VersionSpecOptions())));
+ TEST_CHECK(! VersionSpec("2.010.1", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("2.01.1", VersionSpecOptions())));
+ TEST_CHECK(! VersionSpec("2.011.1", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("2.01.1", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.10", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("2.1", VersionSpecOptions())));
}
} test_version_spec_stupid_star_compare;
@@ -200,6 +211,17 @@ namespace test_cases
TEST_CHECK(! VersionSpec("1_pre1", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("1_pre0", VersionSpecOptions())));
TEST_CHECK(! VersionSpec("1_alpha1", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("1_alpha-r1", VersionSpecOptions())));
TEST_CHECK(! VersionSpec("1_alpha1", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("1_beta", VersionSpecOptions())));
+
+ TEST_CHECK(VersionSpec("010", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("010", VersionSpecOptions())));
+ TEST_CHECK(! VersionSpec("010", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("01", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.010", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("2.01", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.0105", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("2.010", VersionSpecOptions())));
+ TEST_CHECK(! VersionSpec("2.0135", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("2.010", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.010.1", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("2.01", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.011.1", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("2.01", VersionSpecOptions())));
+ TEST_CHECK(VersionSpec("2.010.1", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("2.01.1", VersionSpecOptions())));
+ TEST_CHECK(! VersionSpec("2.011.1", VersionSpecOptions()).stupid_equal_star_compare(VersionSpec("2.01.1", VersionSpecOptions())));
+ TEST_CHECK(! VersionSpec("2.10", VersionSpecOptions()).nice_equal_star_compare(VersionSpec("2.1", VersionSpecOptions())));
}
} test_version_spec_nice_star_compare;