aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2013-05-23 23:01:48 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2013-05-23 23:02:08 +0100
commit9689c7a0e13774792f9076b2930ebb1d901eec06 (patch)
treedc9b3d0141e2d0f14a91aa46f6e57c3f3d4e7452
parent4663dbe5248be2a9ee2d0e5986c1e01f5006d02e (diff)
downloadpaludis-9689c7a0e13774792f9076b2930ebb1d901eec06.tar.gz
paludis-9689c7a0e13774792f9076b2930ebb1d901eec06.tar.xz
Convert to fancy new visitors
-rw-r--r--paludis/resolver/resolver_test.cc49
1 files changed, 11 insertions, 38 deletions
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 7616fb8..5439626 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011, 2013 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -425,49 +425,22 @@ ResolverTestCase::DecisionChecks::check_unable_msg(const QualifiedPackageName &
return check_generic_msg("unable " + stringify(q), r);
}
-namespace
-{
- struct DecisionStringifier
- {
- std::string visit(const NothingNoChangeDecision &) const
- {
- return "NothingNoChangeDecision";
- }
-
- std::string visit(const UnableToMakeDecision & d) const
- {
- return "UnableToMakeDecision(" + stringify(d.resolvent()) + ")";
- }
-
- std::string visit(const ChangesToMakeDecision & d) const
- {
- return "ChangesToMakeDecision(" + stringify(*d.origin_id()) + ")";
- }
-
- std::string visit(const ExistingNoChangeDecision &) const
- {
- return "ExistingNoChangeDecision";
- }
-
- std::string visit(const BreakDecision &) const
- {
- return "BreakDecision";
- }
-
- std::string visit(const RemoveDecision & d) const
- {
- return "RemoveDecision(" + join(indirect_iterator(d.ids()->begin()), indirect_iterator(d.ids()->end()), ", ") + ")";
- }
- };
-}
-
std::string
ResolverTestCase::DecisionChecks::check_generic_msg(const std::string & q, const std::shared_ptr<const Decision> & r)
{
if (! r)
return "Expected " + stringify(q) + " but got finished";
else
- return "Expected " + stringify(q) + " but got " + r->accept_returning<std::string>(DecisionStringifier());
+ return "Expected " + stringify(q) + " but got " + r->make_accept_returning(
+ [&] (const NothingNoChangeDecision &) { return std::string{ "NothingNoChangeDecision" }; },
+ [&] (const UnableToMakeDecision & d) { return "UnableToMakeDecision(" + stringify(d.resolvent()) + ")"; },
+ [&] (const ChangesToMakeDecision & d) { return "ChangesToMakeDecision(" + stringify(*d.origin_id()) + ")"; },
+ [&] (const ExistingNoChangeDecision &) { return "ExistingNoChangeDecision"; },
+ [&] (const BreakDecision &) { return "BreakDecision"; },
+ [&] (const RemoveDecision & d) {
+ return "RemoveDecision(" + join(indirect_iterator(d.ids()->begin()), indirect_iterator(d.ids()->end()), ", ") + ")";
+ }
+ );
}
const std::shared_ptr<FakePackageID>