diff options
-rw-r--r-- | src/generic/problemresolver/choice_set.h | 44 | ||||
-rw-r--r-- | tests/test_choice_set.cc | 98 | ||||
-rw-r--r-- | tests/test_promotion_set.cc | 187 |
3 files changed, 180 insertions, 149 deletions
diff --git a/src/generic/problemresolver/choice_set.h b/src/generic/problemresolver/choice_set.h index a1c22f25..2a5ee3b0 100644 --- a/src/generic/problemresolver/choice_set.h +++ b/src/generic/problemresolver/choice_set.h @@ -30,8 +30,17 @@ template<typename PackageUniverse> std::ostream &operator<<(std::ostream &out, const generic_choice_set<PackageUniverse> &choices); /** \brief Stores a set of choices, with the ability to quickly answer - * questions about containment and to prune choices that are - * redundant. + * questions about containment. + * + * If several choices overlap, only the most specific choice is + * stored. The reason for this is that this structure is used to + * store information of the form "if ever entry in this set of + * choices was chosen, then X". The only way to choose both a more + * general option and a more specific one is to take the more + * specific one; hence, it makes no sense to include both of them. + * To emphasize this behavior, the "insert" routine is called + * "insert_or_narrow". An "insert_widen" could be written without + * conflict; it just happens not to be needed right now. * * This object requires that the choices form a coherent installation * set. In particular, two install_version choices that install @@ -117,11 +126,11 @@ private: } }; - struct insert_choice + struct insert_choice_narrow { generic_choice_set &parent; - insert_choice(generic_choice_set &_parent) + insert_choice_narrow(generic_choice_set &_parent) : parent(_parent) { } @@ -146,11 +155,11 @@ private: choice &existing_choice(existing_choice_pair.second); if(existing_choice.contains(c)) - ; // The new choice adds no information. - else if(c.contains(existing_choice)) // Override the existing choice with the new one, - // which is more general. + // which is more specific. parent.install_version_choices.put(p, c); + else if(c.contains(existing_choice)) + ; // c is more general than the existing choice. else eassert(!"Internal error: attempted to add conflicting choices to the same set."); } @@ -197,14 +206,27 @@ public: { } - generic_choice_set(const imm::set<choice> &choices) + /** \brief Insert every choice in the given set into this set, + * overriding more general options with more specific ones. + */ + void insert_or_narrow(const imm::set<choice> &choices) { - choices.for_each(insert_choice(*this)); + choices.for_each(insert_choice_narrow(*this)); } - void insert(const choice &c) + /** \brief Insert the given choice into this set, overriding more + * general options with more specific ones. + * + * \param c The choice to insert. + * + * If the set contains a choice that is more general than c, that + * choice will be dropped in favor c. On the other hand, if the + * set contains a choice that is more specific than c, c will be + * discarded in favor of that choice. + */ + void insert_or_narrow(const choice &c) { - insert_choice(*this)(c); + insert_choice_narrow(*this)(c); } bool contains(const choice &c) const diff --git a/tests/test_choice_set.cc b/tests/test_choice_set.cc index 7362d322..1d629fc1 100644 --- a/tests/test_choice_set.cc +++ b/tests/test_choice_set.cc @@ -42,11 +42,12 @@ class Choice_Set_Test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(Choice_Set_Test); - CPPUNIT_TEST(testInsert); + CPPUNIT_TEST(testInsertNarrow); CPPUNIT_TEST(testContainsChoice); CPPUNIT_TEST(testContainsChoiceSet); - // No test for for_each(), because it's tested in testInsert (at - // each step, we learn what's really in the set using for_each()) + // No test for for_each(), because it's tested in testInsertNarrow + // (at each step, we learn what's really in the set using + // for_each()) CPPUNIT_TEST_SUITE_END(); @@ -90,8 +91,15 @@ class Choice_Set_Test : public CppUnit::TestFixture return rval; } + static choice_set make_choice_set_narrow(const imm::set<choice> &s) + { + choice_set rval; + rval.insert_or_narrow(s); + return rval; + } + public: - void testInsert() + void testInsertNarrow() { dummy_universe_ref u(parseUniverse(dummy_universe_1)); @@ -121,61 +129,61 @@ public: CPPUNIT_ASSERT_EQUAL(expected.size(), s.size()); CPPUNIT_ASSERT_EQUAL(expected, get_contents(s)); - CPPUNIT_ASSERT_EQUAL(expected, get_contents(choice_set(expected))); - CPPUNIT_ASSERT_EQUAL(s, choice_set(expected)); + CPPUNIT_ASSERT_EQUAL(expected, get_contents(make_choice_set_narrow(expected))); + CPPUNIT_ASSERT_EQUAL(s, make_choice_set_narrow(expected)); const choice c1(choice::make_install_version(av2)); - s.insert(c1); + s.insert_or_narrow(c1); expected.insert(c1); CPPUNIT_ASSERT_EQUAL(expected.size(), s.size()); CPPUNIT_ASSERT_EQUAL(expected, get_contents(s)); - CPPUNIT_ASSERT_EQUAL(expected, get_contents(choice_set(expected))); - CPPUNIT_ASSERT_EQUAL(s, choice_set(expected)); + CPPUNIT_ASSERT_EQUAL(expected, get_contents(make_choice_set_narrow(expected))); + CPPUNIT_ASSERT_EQUAL(s, make_choice_set_narrow(expected)); const choice c2(choice::make_install_version_from_dep_source(av2, av3d1)); - s.insert(c2); + expected.erase(c1); + expected.insert(c2); + s.insert_or_narrow(c2); CPPUNIT_ASSERT_EQUAL(expected.size(), s.size()); CPPUNIT_ASSERT_EQUAL(expected, get_contents(s)); - CPPUNIT_ASSERT_EQUAL(expected, get_contents(choice_set(expected))); - CPPUNIT_ASSERT_EQUAL(s, choice_set(expected)); + CPPUNIT_ASSERT_EQUAL(expected, get_contents(make_choice_set_narrow(expected))); + CPPUNIT_ASSERT_EQUAL(s, make_choice_set_narrow(expected)); const choice c3(choice::make_break_soft_dep(av2d1)); - s.insert(c3); + s.insert_or_narrow(c3); expected.insert(c3); CPPUNIT_ASSERT_EQUAL(expected.size(), s.size()); CPPUNIT_ASSERT_EQUAL(expected, get_contents(s)); - CPPUNIT_ASSERT_EQUAL(expected, get_contents(choice_set(expected))); - CPPUNIT_ASSERT_EQUAL(s, choice_set(expected)); + CPPUNIT_ASSERT_EQUAL(expected, get_contents(make_choice_set_narrow(expected))); + CPPUNIT_ASSERT_EQUAL(s, make_choice_set_narrow(expected)); const choice c4(choice::make_install_version_from_dep_source(bv1, bv2d1)); - s.insert(c4); + s.insert_or_narrow(c4); expected.insert(c4); CPPUNIT_ASSERT_EQUAL(expected.size(), s.size()); CPPUNIT_ASSERT_EQUAL(expected, get_contents(s)); - CPPUNIT_ASSERT_EQUAL(expected, get_contents(choice_set(expected))); - CPPUNIT_ASSERT_EQUAL(s, choice_set(expected)); + CPPUNIT_ASSERT_EQUAL(expected, get_contents(make_choice_set_narrow(expected))); + CPPUNIT_ASSERT_EQUAL(s, make_choice_set_narrow(expected)); const choice c5(choice::make_install_version(bv1)); - s.insert(c5); - expected.insert(c5); - expected.erase(c4); + s.insert_or_narrow(c5); CPPUNIT_ASSERT_EQUAL(expected.size(), s.size()); CPPUNIT_ASSERT_EQUAL(expected, get_contents(s)); - CPPUNIT_ASSERT_EQUAL(expected, get_contents(choice_set(expected))); - CPPUNIT_ASSERT_EQUAL(s, choice_set(expected)); + CPPUNIT_ASSERT_EQUAL(expected, get_contents(make_choice_set_narrow(expected))); + CPPUNIT_ASSERT_EQUAL(s, make_choice_set_narrow(expected)); const choice c6(choice::make_break_soft_dep(av3d1)); - s.insert(c6); + s.insert_or_narrow(c6); expected.insert(c6); CPPUNIT_ASSERT_EQUAL(expected.size(), s.size()); CPPUNIT_ASSERT_EQUAL(expected, get_contents(s)); - CPPUNIT_ASSERT_EQUAL(expected, get_contents(choice_set(expected))); - CPPUNIT_ASSERT_EQUAL(s, choice_set(expected)); + CPPUNIT_ASSERT_EQUAL(expected, get_contents(make_choice_set_narrow(expected))); + CPPUNIT_ASSERT_EQUAL(s, make_choice_set_narrow(expected)); } void testContainsChoice() @@ -204,10 +212,10 @@ public: dep av3d1(*av3.deps_begin()); choice_set s; - s.insert(choice::make_install_version_from_dep_source(av1, av3d1)); - s.insert(choice::make_install_version(cv3)); - s.insert(choice::make_install_version(bv1)); - s.insert(choice::make_break_soft_dep(av2d1)); + s.insert_or_narrow(choice::make_install_version_from_dep_source(av1, av3d1)); + s.insert_or_narrow(choice::make_install_version(cv3)); + s.insert_or_narrow(choice::make_install_version(bv1)); + s.insert_or_narrow(choice::make_break_soft_dep(av2d1)); CPPUNIT_ASSERT(s.contains(choice::make_install_version_from_dep_source(av1, av3d1))); CPPUNIT_ASSERT(!s.contains(choice::make_install_version_from_dep_source(av1, av2d1))); @@ -270,33 +278,33 @@ public: // Sn contains Sn for all n. choice_set s0; - s0.insert(choice::make_install_version(av1)); - s0.insert(choice::make_install_version(bv3)); - s0.insert(choice::make_install_version(cv2)); + s0.insert_or_narrow(choice::make_install_version(av1)); + s0.insert_or_narrow(choice::make_install_version(bv3)); + s0.insert_or_narrow(choice::make_install_version(cv2)); choice_set s1; - s1.insert(choice::make_install_version_from_dep_source(av1, av2d1)); - s1.insert(choice::make_install_version(bv3)); - s1.insert(choice::make_install_version(cv2)); + s1.insert_or_narrow(choice::make_install_version_from_dep_source(av1, av2d1)); + s1.insert_or_narrow(choice::make_install_version(bv3)); + s1.insert_or_narrow(choice::make_install_version(cv2)); choice_set s2; - s2.insert(choice::make_install_version_from_dep_source(av1, av3d1)); - s2.insert(choice::make_install_version(bv3)); - s2.insert(choice::make_install_version(cv2)); + s2.insert_or_narrow(choice::make_install_version_from_dep_source(av1, av3d1)); + s2.insert_or_narrow(choice::make_install_version(bv3)); + s2.insert_or_narrow(choice::make_install_version(cv2)); choice_set s3; - s3.insert(choice::make_install_version(cv2)); + s3.insert_or_narrow(choice::make_install_version(cv2)); choice_set s4; - s4.insert(choice::make_install_version(cv2)); - s4.insert(choice::make_break_soft_dep(av2d1)); + s4.insert_or_narrow(choice::make_install_version(cv2)); + s4.insert_or_narrow(choice::make_break_soft_dep(av2d1)); choice_set s5; - s5.insert(choice::make_break_soft_dep(av2d1)); - s5.insert(choice::make_break_soft_dep(bv2d1)); + s5.insert_or_narrow(choice::make_break_soft_dep(av2d1)); + s5.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); choice_set s6; - s6.insert(choice::make_break_soft_dep(bv2d1)); + s6.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); std::vector<choice_set> sets; sets.push_back(s0); diff --git a/tests/test_promotion_set.cc b/tests/test_promotion_set.cc index c4e8c442..4f5d3d87 100644 --- a/tests/test_promotion_set.cc +++ b/tests/test_promotion_set.cc @@ -61,6 +61,7 @@ class Promotion_SetTest : public CppUnit::TestFixture typedef dummy_universe_ref::version version; typedef dummy_universe_ref::dep dep; typedef generic_choice<dummy_universe_ref> choice; + typedef generic_choice_set<dummy_universe_ref> choice_set; typedef promotion_set<dummy_universe_ref> dummy_promotion_set; typedef dummy_promotion_set::promotion promotion; @@ -129,8 +130,8 @@ class Promotion_SetTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(expected_promotions.size(), empirical_promotions_size(promotions)); CPPUNIT_ASSERT_EQUAL(expected_promotions, get_promotions(promotions)); - imm::set<choice> p1_choices; - p1_choices.insert(choice::make_install_version_from_dep_source(av1, av2d1)); + choice_set p1_choices; + p1_choices.insert_or_narrow(choice::make_install_version_from_dep_source(av1, av2d1)); promotion p1(p1_choices, 100); expected_promotions.insert(p1); promotions.insert(p1); @@ -138,10 +139,10 @@ class Promotion_SetTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(expected_promotions.size(), empirical_promotions_size(promotions)); CPPUNIT_ASSERT_EQUAL(expected_promotions, get_promotions(promotions)); - imm::set<choice> p2_choices; - p2_choices.insert(choice::make_install_version(av1)); - p2_choices.insert(choice::make_install_version(bv2)); - p2_choices.insert(choice::make_install_version(cv3)); + choice_set p2_choices; + p2_choices.insert_or_narrow(choice::make_install_version(av1)); + p2_choices.insert_or_narrow(choice::make_install_version(bv2)); + p2_choices.insert_or_narrow(choice::make_install_version(cv3)); promotion p2(p2_choices, 50); expected_promotions.insert(p2); promotions.insert(p2); @@ -149,9 +150,9 @@ class Promotion_SetTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(expected_promotions.size(), empirical_promotions_size(promotions)); CPPUNIT_ASSERT_EQUAL(expected_promotions, get_promotions(promotions)); - imm::set<choice> p3_choices; - p3_choices.insert(choice::make_install_version(av1)); - p3_choices.insert(choice::make_install_version(bv2)); + choice_set p3_choices; + p3_choices.insert_or_narrow(choice::make_install_version(av1)); + p3_choices.insert_or_narrow(choice::make_install_version(bv2)); promotion p3(p3_choices, 75); expected_promotions.insert(p3); expected_promotions.erase(p2); @@ -160,18 +161,18 @@ class Promotion_SetTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(expected_promotions.size(), empirical_promotions_size(promotions)); CPPUNIT_ASSERT_EQUAL(expected_promotions, get_promotions(promotions)); - imm::set<choice> p4_choices; - p4_choices.insert(choice::make_install_version(av1)); - p4_choices.insert(choice::make_install_version(bv2)); - p4_choices.insert(choice::make_install_version(cv1)); + choice_set p4_choices; + p4_choices.insert_or_narrow(choice::make_install_version(av1)); + p4_choices.insert_or_narrow(choice::make_install_version(bv2)); + p4_choices.insert_or_narrow(choice::make_install_version(cv1)); promotion p4(p4_choices, 10); promotions.insert(p4); CPPUNIT_ASSERT_EQUAL(expected_promotions.size(), promotions.size()); CPPUNIT_ASSERT_EQUAL(expected_promotions.size(), empirical_promotions_size(promotions)); CPPUNIT_ASSERT_EQUAL(expected_promotions, get_promotions(promotions)); - imm::set<choice> p5_choices; - p5_choices.insert(choice::make_install_version(bv2)); + choice_set p5_choices; + p5_choices.insert_or_narrow(choice::make_install_version(bv2)); promotion p5(p5_choices, 30); expected_promotions.insert(p5); promotions.insert(p5); @@ -179,8 +180,8 @@ class Promotion_SetTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(expected_promotions.size(), empirical_promotions_size(promotions)); CPPUNIT_ASSERT_EQUAL(expected_promotions, get_promotions(promotions)); - imm::set<choice> p6_choices; - p6_choices.insert(choice::make_break_soft_dep(bv2d1)); + choice_set p6_choices; + p6_choices.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); promotion p6(p6_choices, 125); expected_promotions.insert(p6); promotions.insert(p6); @@ -188,9 +189,9 @@ class Promotion_SetTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(expected_promotions.size(), empirical_promotions_size(promotions)); CPPUNIT_ASSERT_EQUAL(expected_promotions, get_promotions(promotions)); - imm::set<choice> p7_choices; - p7_choices.insert(choice::make_install_version(cv3)); - p7_choices.insert(choice::make_break_soft_dep(bv2d1)); + choice_set p7_choices; + p7_choices.insert_or_narrow(choice::make_install_version(cv3)); + p7_choices.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); promotion p7(p7_choices, 500); expected_promotions.insert(p7); promotions.insert(p7); @@ -198,9 +199,9 @@ class Promotion_SetTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(expected_promotions.size(), empirical_promotions_size(promotions)); CPPUNIT_ASSERT_EQUAL(expected_promotions, get_promotions(promotions)); - imm::set<choice> p8_choices; - p8_choices.insert(choice::make_install_version_from_dep_source(bv3, bv2d1)); - p8_choices.insert(choice::make_install_version(cv2)); + choice_set p8_choices; + p8_choices.insert_or_narrow(choice::make_install_version_from_dep_source(bv3, bv2d1)); + p8_choices.insert_or_narrow(choice::make_install_version(cv2)); promotion p8(p8_choices, 50); expected_promotions.insert(p8); promotions.insert(p8); @@ -246,15 +247,15 @@ public: // // Checks that a search for a set with several hits returns the // highest-valued one. - imm::set<choice> search1; - search1.insert(choice::make_install_version(av1)); - search1.insert(choice::make_install_version(bv3)); - search1.insert(choice::make_install_version(cv3)); - search1.insert(choice::make_break_soft_dep(bv2d1)); - - imm::set<choice> expected1_choices; - expected1_choices.insert(choice::make_install_version(cv3)); - expected1_choices.insert(choice::make_break_soft_dep(bv2d1)); + choice_set search1; + search1.insert_or_narrow(choice::make_install_version(av1)); + search1.insert_or_narrow(choice::make_install_version(bv3)); + search1.insert_or_narrow(choice::make_install_version(cv3)); + search1.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); + + choice_set expected1_choices; + expected1_choices.insert_or_narrow(choice::make_install_version(cv3)); + expected1_choices.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); promotion expected1(expected1_choices, 500); dummy_promotion_set::const_iterator found = p.find_highest_promotion_for(search1); @@ -283,9 +284,9 @@ public: // Should turn up nothing. // // Checks that a search for a set with no hits returns nothing. - imm::set<choice> search2; - search2.insert(choice::make_install_version(av1)); - search2.insert(choice::make_install_version(bv1)); + choice_set search2; + search2.insert_or_narrow(choice::make_install_version(av1)); + search2.insert_or_narrow(choice::make_install_version(bv1)); CPPUNIT_ASSERT(p.find_highest_promotion_for(search2) == p.end()); CPPUNIT_ASSERT(p.find_highest_promotion_containing(search2, choice::make_install_version(av1)) == p.end()); @@ -296,10 +297,10 @@ public: // Should turn up only (T125: Break(b v2 -> <c v2>)) // // Checks that a higher-valued superset is correctly ignored. - imm::set<choice> search3; - search3.insert(choice::make_break_soft_dep(bv2d1)); + choice_set search3; + search3.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); - imm::set<choice> expected_choices3 = search3; + choice_set expected_choices3 = search3; promotion expected3(expected_choices3, 125); found = p.find_highest_promotion_for(search3); @@ -317,13 +318,13 @@ public: // Tests that choices made due to a dependency are matched by // choices made not due to a dependency, but not by choices made // due to a different dependency. - imm::set<choice> search4; - search4.insert(choice::make_install_version_from_dep_source(av1, av3d1)); - search4.insert(choice::make_install_version(bv2)); + choice_set search4; + search4.insert_or_narrow(choice::make_install_version_from_dep_source(av1, av3d1)); + search4.insert_or_narrow(choice::make_install_version(bv2)); - imm::set<choice> expected_choices4; - expected_choices4.insert(choice::make_install_version(av1)); - expected_choices4.insert(choice::make_install_version(bv2)); + choice_set expected_choices4; + expected_choices4.insert_or_narrow(choice::make_install_version(av1)); + expected_choices4.insert_or_narrow(choice::make_install_version(bv2)); promotion expected4(expected_choices4, 75); found = p.find_highest_promotion_for(search4); @@ -345,12 +346,12 @@ public: // // Tests that choices made due to a dependency are matched by // choices made due to the same dependency. - imm::set<choice> search5; - search5.insert(choice::make_install_version_from_dep_source(av1, av2d1)); - search5.insert(choice::make_install_version(bv2)); + choice_set search5; + search5.insert_or_narrow(choice::make_install_version_from_dep_source(av1, av2d1)); + search5.insert_or_narrow(choice::make_install_version(bv2)); - imm::set<choice> expected_choices5; - expected_choices5.insert(choice::make_install_version_from_dep_source(av1, av2d1)); + choice_set expected_choices5; + expected_choices5.insert_or_narrow(choice::make_install_version_from_dep_source(av1, av2d1)); promotion expected5(expected_choices5, 100); found = p.find_highest_promotion_for(search5); @@ -364,9 +365,9 @@ public: // In this case there is a different expectation: we should find // (T75: Install(a v1, b v2)), since the otherwise expected // solution doesn't contain the "key" element. - imm::set<choice> expected_choices5_2; - expected_choices5_2.insert(choice::make_install_version(av1)); - expected_choices5_2.insert(choice::make_install_version(bv2)); + choice_set expected_choices5_2; + expected_choices5_2.insert_or_narrow(choice::make_install_version(av1)); + expected_choices5_2.insert_or_narrow(choice::make_install_version(bv2)); promotion expected5_2(expected_choices5_2, 75); found = p.find_highest_promotion_containing(search5, choice::make_install_version(bv2)); CPPUNIT_ASSERT(found != p.end()); @@ -376,9 +377,9 @@ public: // doesn't have the right from-dep-source information. Tests that // find_highest_promotion_containing correctly checks the // from-dep-source information. - imm::set<choice> search6; - search6.insert(choice::make_install_version(bv3)); - search6.insert(choice::make_install_version(cv2)); + choice_set search6; + search6.insert_or_narrow(choice::make_install_version(bv3)); + search6.insert_or_narrow(choice::make_install_version(cv2)); CPPUNIT_ASSERT(p.end() == p.find_highest_promotion_for(search6)); CPPUNIT_ASSERT(p.end() == p.find_highest_promotion_containing(search6, choice::make_install_version(bv3))); @@ -386,9 +387,9 @@ public: // Check that we can match (Install(bv3 [bv2 -> <c v2>], cv2)) // instead. - imm::set<choice> search7; - search7.insert(choice::make_install_version_from_dep_source(bv3, bv2d1)); - search7.insert(choice::make_install_version(cv2)); + choice_set search7; + search7.insert_or_narrow(choice::make_install_version_from_dep_source(bv3, bv2d1)); + search7.insert_or_narrow(choice::make_install_version(cv2)); promotion expected7(search7, 50); @@ -442,29 +443,29 @@ public: // promotion set are maintained correctly. { imm::set<promotion> expected_promotions; - imm::set<choice> p1_choices; - p1_choices.insert(choice::make_install_version_from_dep_source(av1, av2d1)); + choice_set p1_choices; + p1_choices.insert_or_narrow(choice::make_install_version_from_dep_source(av1, av2d1)); promotion p1(p1_choices, 100); expected_promotions.insert(p1); p.insert(p1); - imm::set<choice> p2_choices; - p2_choices.insert(choice::make_install_version(av1)); - p2_choices.insert(choice::make_install_version(bv2)); + choice_set p2_choices; + p2_choices.insert_or_narrow(choice::make_install_version(av1)); + p2_choices.insert_or_narrow(choice::make_install_version(bv2)); promotion p2(p2_choices, 75); expected_promotions.insert(p2); p.insert(p2); - imm::set<choice> p3_choices; - p3_choices.insert(choice::make_install_version(bv2)); + choice_set p3_choices; + p3_choices.insert_or_narrow(choice::make_install_version(bv2)); promotion p3(p3_choices, 30); expected_promotions.insert(p3); p.insert(p3); - imm::set<choice> p4_choices; - p4_choices.insert(choice::make_break_soft_dep(bv2d1)); + choice_set p4_choices; + p4_choices.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); promotion p4(p4_choices, 125); expected_promotions.insert(p4); p.insert(p4); @@ -480,14 +481,14 @@ public: // Install(c v3), Break(b v2 -> <c v2>)) // // Should turn up (T125: Break(b v2 -> <c v2>)) - imm::set<choice> search1; - search1.insert(choice::make_install_version(av1)); - search1.insert(choice::make_install_version(bv3)); - search1.insert(choice::make_install_version(cv3)); - search1.insert(choice::make_break_soft_dep(bv2d1)); - - imm::set<choice> expected_choices1; - expected_choices1.insert(choice::make_break_soft_dep(bv2d1)); + choice_set search1; + search1.insert_or_narrow(choice::make_install_version(av1)); + search1.insert_or_narrow(choice::make_install_version(bv3)); + search1.insert_or_narrow(choice::make_install_version(cv3)); + search1.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); + + choice_set expected_choices1; + expected_choices1.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); promotion expected1(expected_choices1, 125); dummy_promotion_set::const_iterator found = p.find_highest_promotion_for(search1); @@ -510,9 +511,9 @@ public: // Nothing should match the tier-50 promotion. - imm::set<choice> search2; - search2.insert(choice::make_install_version_from_dep_source(bv3, bv2d1)); - search2.insert(choice::make_install_version(cv2)); + choice_set search2; + search2.insert_or_narrow(choice::make_install_version_from_dep_source(bv3, bv2d1)); + search2.insert_or_narrow(choice::make_install_version(cv2)); CPPUNIT_ASSERT(p.end() == p.find_highest_promotion_for(search2)); CPPUNIT_ASSERT(p.end() == p.find_highest_promotion_containing(search2, choice::make_install_version_from_dep_source(bv3, bv2d1))); @@ -560,34 +561,34 @@ public: // (T30: Install(b v2)) // should be gone. imm::set<promotion> expected; - imm::set<choice> p1_choices; - p1_choices.insert(choice::make_install_version_from_dep_source(av1, av2d1)); + choice_set p1_choices; + p1_choices.insert_or_narrow(choice::make_install_version_from_dep_source(av1, av2d1)); promotion p1(p1_choices, 100); expected.insert(p1); - imm::set<choice> p2_choices; - p2_choices.insert(choice::make_break_soft_dep(bv2d1)); + choice_set p2_choices; + p2_choices.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); promotion p2(p2_choices, 125); expected.insert(p2); - imm::set<choice> p3_choices; - p3_choices.insert(choice::make_install_version(cv3)); - p3_choices.insert(choice::make_break_soft_dep(bv2d1)); + choice_set p3_choices; + p3_choices.insert_or_narrow(choice::make_install_version(cv3)); + p3_choices.insert_or_narrow(choice::make_break_soft_dep(bv2d1)); promotion p3(p3_choices, 500); expected.insert(p3); // Unexpected promotions. These should match nothing. - imm::set<choice> up1_choices; - up1_choices.insert(choice::make_install_version(av1)); - up1_choices.insert(choice::make_install_version(bv2)); + choice_set up1_choices; + up1_choices.insert_or_narrow(choice::make_install_version(av1)); + up1_choices.insert_or_narrow(choice::make_install_version(bv2)); - imm::set<choice> up2_choices; - up2_choices.insert(choice::make_install_version(bv2)); + choice_set up2_choices; + up2_choices.insert_or_narrow(choice::make_install_version(bv2)); - imm::set<choice> up3_choices; - up3_choices.insert(choice::make_install_version_from_dep_source(bv3, bv2d1)); - up3_choices.insert(choice::make_install_version(cv2)); + choice_set up3_choices; + up3_choices.insert_or_narrow(choice::make_install_version_from_dep_source(bv3, bv2d1)); + up3_choices.insert_or_narrow(choice::make_install_version(cv2)); // Check that the new size of the set is correct. CPPUNIT_ASSERT_EQUAL(expected.size(), p.size()); |