summaryrefslogtreecommitdiff
path: root/tests/test_choice_set.cc
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2009-03-07 10:21:29 -0800
committerDaniel Burrows <dburrows@debian.org>2009-03-07 10:21:29 -0800
commitfeb412d443a447fe344b9d980f148d1eaf6a23e9 (patch)
treed091a534471680b160b7cb0c502ac3bcc0ef73f5 /tests/test_choice_set.cc
parent8be3e37473ae665e484a20026e8a6b139e018c58 (diff)
downloadaptitude-feb412d443a447fe344b9d980f148d1eaf6a23e9.tar.gz
Add a routine to look up the version of a package that a choice set installs.
Needed to use this in the solution object.
Diffstat (limited to 'tests/test_choice_set.cc')
-rw-r--r--tests/test_choice_set.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_choice_set.cc b/tests/test_choice_set.cc
index 163405e5..cd8feaae 100644
--- a/tests/test_choice_set.cc
+++ b/tests/test_choice_set.cc
@@ -43,6 +43,7 @@ class Choice_Set_Test : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(Choice_Set_Test);
CPPUNIT_TEST(testInsertNarrow);
+ CPPUNIT_TEST(testGetVersionOf);
CPPUNIT_TEST(testContainsChoice);
CPPUNIT_TEST(testContainsChoiceSet);
// No test for for_each(), because it's tested in testInsertNarrow
@@ -251,6 +252,50 @@ public:
CPPUNIT_ASSERT(!s.contains(make_break_soft_dep(av3d1)));
}
+ void testGetVersionOf()
+ {
+ dummy_universe_ref u(parseUniverse(dummy_universe_1));
+
+ package a(u.find_package("a"));
+ package b(u.find_package("b"));
+ package c(u.find_package("c"));
+
+ version av1(a.version_from_name("v1"));
+ version av2(a.version_from_name("v2"));
+ version av3(a.version_from_name("v3"));
+
+ version bv1(b.version_from_name("v1"));
+ version bv2(b.version_from_name("v2"));
+ version bv3(b.version_from_name("v3"));
+
+ version cv1(c.version_from_name("v1"));
+ version cv2(c.version_from_name("v2"));
+ version cv3(c.version_from_name("v3"));
+
+ dep av1d1(*av1.deps_begin());
+ dep bv2d1(*bv2.deps_begin());
+ dep av2d1(*av2.deps_begin());
+ dep av3d1(*av3.deps_begin());
+
+
+ choice_set s;
+ s.insert_or_narrow(choice::make_install_version(av1, -1));
+ s.insert_or_narrow(choice::make_install_version(bv3, -1));
+
+ version v;
+ CPPUNIT_ASSERT(s.get_version_of(a, v));
+ CPPUNIT_ASSERT_EQUAL(av1, v);
+
+ CPPUNIT_ASSERT(s.get_version_of(b, v));
+ CPPUNIT_ASSERT_EQUAL(bv3, v);
+
+ s.insert_or_narrow(choice::make_install_version_from_dep_source(bv3, bv2d1, -1));
+ CPPUNIT_ASSERT(s.get_version_of(b, v));
+ CPPUNIT_ASSERT_EQUAL(bv3, v);
+
+ CPPUNIT_ASSERT(!s.get_version_of(c, v));
+ }
+
void testContainsChoiceSet()
{
dummy_universe_ref u(parseUniverse(dummy_universe_1));