aboutsummaryrefslogtreecommitdiff
path: root/paludis/dep_spec_TEST.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-16 03:20:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-16 03:20:28 +0000
commit9c7c820168a836afaa256008be1883fbce630a1c (patch)
treecca0f994e081e3c37044e29ea7d635b21d97e5b8 /paludis/dep_spec_TEST.cc
parentf2029ff168647fb4f3fa21ea8cf8adedc150117f (diff)
downloadpaludis-9c7c820168a836afaa256008be1883fbce630a1c.tar.gz
paludis-9c7c820168a836afaa256008be1883fbce630a1c.tar.xz
Switch syntax for ranged dependencies, and allow it for user and paludis EAPIs. Enable wildcard category and package parts in dep specs. Only allow unspecific dep specs where appropriate.
Diffstat (limited to 'paludis/dep_spec_TEST.cc')
-rw-r--r--paludis/dep_spec_TEST.cc94
1 files changed, 94 insertions, 0 deletions
diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc
index 6e3aecde8..341670d34 100644
--- a/paludis/dep_spec_TEST.cc
+++ b/paludis/dep_spec_TEST.cc
@@ -84,11 +84,13 @@ namespace test_cases
void run()
{
PackageDepSpec a("foo/bar", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(a, "foo/bar");
TEST_CHECK_STRINGIFY_EQUAL(*a.package_ptr(), "foo/bar");
TEST_CHECK(! a.slot_ptr());
TEST_CHECK(! a.version_requirements_ptr());
PackageDepSpec b(">=foo/bar-1.2.3", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(b, ">=foo/bar-1.2.3");
TEST_CHECK_STRINGIFY_EQUAL(*b.package_ptr(), "foo/bar");
TEST_CHECK(! b.slot_ptr());
TEST_CHECK(b.version_requirements_ptr());
@@ -98,12 +100,14 @@ namespace test_cases
TEST_CHECK_EQUAL(b.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
PackageDepSpec c("foo/bar:baz", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(c, "foo/bar:baz");
TEST_CHECK_STRINGIFY_EQUAL(*c.package_ptr(), "foo/bar");
TEST_CHECK(c.slot_ptr());
TEST_CHECK_STRINGIFY_EQUAL(*c.slot_ptr(), "baz");
TEST_CHECK(! c.version_requirements_ptr());
PackageDepSpec d("=foo/bar-1.2*:1.2.1", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(d, "=foo/bar-1.2*:1.2.1");
TEST_CHECK_STRINGIFY_EQUAL(*d.package_ptr(), "foo/bar");
TEST_CHECK(d.slot_ptr());
TEST_CHECK_STRINGIFY_EQUAL(*d.slot_ptr(), "1.2.1");
@@ -112,29 +116,35 @@ namespace test_cases
TEST_CHECK_EQUAL(d.version_requirements_ptr()->begin()->version_operator, vo_equal_star);
PackageDepSpec e("foo/bar:1.2.1", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(e, "foo/bar:1.2.1");
TEST_CHECK_STRINGIFY_EQUAL(*e.package_ptr(), "foo/bar");
TEST_CHECK(e.slot_ptr());
TEST_CHECK_STRINGIFY_EQUAL(*e.slot_ptr(), "1.2.1");
TEST_CHECK(! e.version_requirements_ptr());
PackageDepSpec f("foo/bar:0", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(f, "foo/bar:0");
TEST_CHECK_STRINGIFY_EQUAL(*f.package_ptr(), "foo/bar");
TEST_CHECK(f.slot_ptr());
TEST_CHECK_STRINGIFY_EQUAL(*f.slot_ptr(), "0");
TEST_CHECK(! f.version_requirements_ptr());
PackageDepSpec g("foo/bar-100dpi", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(g, "foo/bar-100dpi");
TEST_CHECK_STRINGIFY_EQUAL(*g.package_ptr(), "foo/bar-100dpi");
PackageDepSpec h(">=foo/bar-100dpi-1.23", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(h, ">=foo/bar-100dpi-1.23");
TEST_CHECK_STRINGIFY_EQUAL(*h.package_ptr(), "foo/bar-100dpi");
TEST_CHECK(h.version_requirements_ptr());
TEST_CHECK_STRINGIFY_EQUAL(h.version_requirements_ptr()->begin()->version_spec, "1.23");
TEST_CHECK_EQUAL(h.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
TEST_CHECK_THROWS(PackageDepSpec("", pds_pm_permissive), PackageDepSpecError);
+ TEST_CHECK_THROWS(PackageDepSpec("=foo/bar-1.2[=1.3]", pds_pm_permissive), PackageDepSpecError);
PackageDepSpec i("foo/bar[one][-two]", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(i, "foo/bar[one][-two]");
TEST_CHECK_STRINGIFY_EQUAL(*i.package_ptr(), "foo/bar");
TEST_CHECK(! i.version_requirements_ptr());
TEST_CHECK(! i.repository_ptr());
@@ -151,17 +161,101 @@ namespace test_cases
TEST_CHECK(i.use_requirements_ptr()->state(UseFlagName("moo")) == use_unspecified);
PackageDepSpec j("=foo/bar-scm-r3", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(j, "=foo/bar-scm-r3");
TEST_CHECK_STRINGIFY_EQUAL(*j.package_ptr(), "foo/bar");
TEST_CHECK(j.version_requirements_ptr());
TEST_CHECK_STRINGIFY_EQUAL(j.version_requirements_ptr()->begin()->version_spec, "scm-r3");
TEST_CHECK_EQUAL(j.version_requirements_ptr()->begin()->version_operator, vo_equal);
PackageDepSpec k("=foo/bar-scm", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(k, "=foo/bar-scm");
TEST_CHECK_STRINGIFY_EQUAL(*k.package_ptr(), "foo/bar");
TEST_CHECK(k.version_requirements_ptr());
TEST_CHECK_STRINGIFY_EQUAL(k.version_requirements_ptr()->begin()->version_spec, "scm");
TEST_CHECK_EQUAL(k.version_requirements_ptr()->begin()->version_operator, vo_equal);
+
+ PackageDepSpec l("foo/bar[one][-two][>=1.2&<2.0]", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(l, "foo/bar[>=1.2&<2.0][one][-two]");
+ TEST_CHECK_STRINGIFY_EQUAL(*l.package_ptr(), "foo/bar");
+ TEST_CHECK(l.version_requirements_ptr());
+ TEST_CHECK(! l.repository_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(l.version_requirements_ptr()->begin()->version_spec, "1.2");
+ TEST_CHECK_EQUAL(l.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
+ TEST_CHECK_STRINGIFY_EQUAL(next(l.version_requirements_ptr()->begin())->version_spec, "2.0");
+ TEST_CHECK_EQUAL(next(l.version_requirements_ptr()->begin())->version_operator, vo_less);
+ TEST_CHECK(! l.slot_ptr());
+ TEST_CHECK(l.use_requirements_ptr());
+ TEST_CHECK(l.use_requirements_ptr()->find(UseFlagName("one")) !=
+ l.use_requirements_ptr()->end());
+ TEST_CHECK(l.use_requirements_ptr()->find(UseFlagName("two")) !=
+ l.use_requirements_ptr()->end());
+ TEST_CHECK(l.use_requirements_ptr()->find(UseFlagName("three")) ==
+ l.use_requirements_ptr()->end());
+ TEST_CHECK(l.use_requirements_ptr()->state(UseFlagName("one")) == use_enabled);
+ TEST_CHECK(l.use_requirements_ptr()->state(UseFlagName("two")) == use_disabled);
+ TEST_CHECK(l.use_requirements_ptr()->state(UseFlagName("moo")) == use_unspecified);
+
+ PackageDepSpec m("foo/bar[=1.2|=1.3*|~1.4]", pds_pm_permissive);
+ TEST_CHECK_STRINGIFY_EQUAL(m, "foo/bar[=1.2|=1.3*|~1.4]");
+ TEST_CHECK_STRINGIFY_EQUAL(*m.package_ptr(), "foo/bar");
+ TEST_CHECK(m.version_requirements_ptr());
+ TEST_CHECK(! m.repository_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(m.version_requirements_ptr()->begin()->version_spec, "1.2");
+ TEST_CHECK_EQUAL(m.version_requirements_ptr()->begin()->version_operator, vo_equal);
+ TEST_CHECK_STRINGIFY_EQUAL(next(m.version_requirements_ptr()->begin())->version_spec, "1.3");
+ TEST_CHECK_EQUAL(next(m.version_requirements_ptr()->begin())->version_operator, vo_equal_star);
+ TEST_CHECK_STRINGIFY_EQUAL(next(next(m.version_requirements_ptr()->begin()))->version_spec, "1.4");
+ TEST_CHECK_EQUAL(next(next(m.version_requirements_ptr()->begin()))->version_operator, vo_tilde);
+ TEST_CHECK(! m.slot_ptr());
}
} test_package_dep_spec;
+
+ struct PackageDepSpecUnspecificTest : TestCase
+ {
+ PackageDepSpecUnspecificTest() : TestCase("package dep spec unspecific") { }
+
+ void run()
+ {
+ PackageDepSpec a("*/*", pds_pm_unspecific);
+ TEST_CHECK_STRINGIFY_EQUAL(a, "*/*");
+ TEST_CHECK(! a.package_ptr());
+ TEST_CHECK(! a.package_name_part_ptr());
+ TEST_CHECK(! a.category_name_part_ptr());
+
+ PackageDepSpec b("foo/*", pds_pm_unspecific);
+ TEST_CHECK_STRINGIFY_EQUAL(b, "foo/*");
+ TEST_CHECK(! b.package_ptr());
+ TEST_CHECK(! b.package_name_part_ptr());
+ TEST_CHECK(b.category_name_part_ptr());
+ TEST_CHECK_EQUAL(*b.category_name_part_ptr(), CategoryNamePart("foo"));
+
+ PackageDepSpec c("*/foo", pds_pm_unspecific);
+ TEST_CHECK_STRINGIFY_EQUAL(c, "*/foo");
+ TEST_CHECK(! c.package_ptr());
+ TEST_CHECK(c.package_name_part_ptr());
+ TEST_CHECK_EQUAL(*c.package_name_part_ptr(), PackageNamePart("foo"));
+ TEST_CHECK(! c.category_name_part_ptr());
+
+ PackageDepSpec d("~*/*-0", pds_pm_unspecific);
+ TEST_CHECK_STRINGIFY_EQUAL(d, "~*/*-0");
+ TEST_CHECK(! d.package_ptr());
+ TEST_CHECK(! d.package_name_part_ptr());
+ TEST_CHECK(! d.category_name_part_ptr());
+
+ PackageDepSpec e(">=foo/*-1.23", pds_pm_unspecific);
+ TEST_CHECK_STRINGIFY_EQUAL(e, ">=foo/*-1.23");
+ TEST_CHECK(! e.package_ptr());
+ TEST_CHECK(! e.package_name_part_ptr());
+ TEST_CHECK(e.category_name_part_ptr());
+ TEST_CHECK_EQUAL(*e.category_name_part_ptr(), CategoryNamePart("foo"));
+
+ PackageDepSpec f("=*/foo-1*", pds_pm_unspecific);
+ TEST_CHECK_STRINGIFY_EQUAL(f, "=*/foo-1*");
+ TEST_CHECK(! f.package_ptr());
+ TEST_CHECK(f.package_name_part_ptr());
+ TEST_CHECK_EQUAL(*f.package_name_part_ptr(), PackageNamePart("foo"));
+ TEST_CHECK(! f.category_name_part_ptr());
+ }
+ } test_package_dep_spec_unspecific;
}