first outline of test and aggregate initialisation problem
- the test will use some really private data types, valid only within the scope of the test function. - invoking the builder for real got me into problems with the aggregate initialisation I'd used. Maybe it's the function pointers? Anyway, working around that by definint a telescope ctor
This commit is contained in:
parent
a106a0e090
commit
df8ca071a8
3 changed files with 50 additions and 17 deletions
|
|
@ -86,12 +86,21 @@
|
|||
|
||||
Coll& collection;
|
||||
|
||||
SEL isApplicable;
|
||||
MAT matches;
|
||||
CTR construct;
|
||||
SEL isApplicable;
|
||||
ASS assign;
|
||||
MUT openSub;
|
||||
|
||||
CollectionBinding(Coll& coll, MAT m, CTR c, SEL s, ASS a, MUT u)
|
||||
: collection(coll)
|
||||
, matches(m)
|
||||
, construct(c)
|
||||
, isApplicable(s)
|
||||
, assign(a)
|
||||
, openSub(u)
|
||||
{ }
|
||||
|
||||
|
||||
/* === content manipulation API === */
|
||||
|
||||
|
|
@ -305,6 +314,7 @@
|
|||
struct CollectionBindingBuilder
|
||||
: CollectionBinding<COLL,MAT,CTR,SEL,ASS,MUT>
|
||||
{
|
||||
using CollectionBinding<COLL,MAT,CTR,SEL,ASS,MUT>::CollectionBinding;
|
||||
|
||||
template<class FUN>
|
||||
CollectionBindingBuilder<COLL, FUN ,CTR,SEL,ASS,MUT>
|
||||
|
|
@ -393,13 +403,13 @@
|
|||
static bool
|
||||
default_contentMatch (GenNode const& spec, Elm const& elm)
|
||||
{
|
||||
return spec.matches(elm);
|
||||
//return spec.matches(elm);
|
||||
}
|
||||
|
||||
static Elm
|
||||
default_construct_from_payload (GenNode const& spec)
|
||||
{
|
||||
return spec.data.get<Elm>();
|
||||
//return spec.data.get<Elm>();
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -423,23 +433,23 @@
|
|||
|
||||
using FallbackBindingConfiguration
|
||||
= CollectionBindingBuilder<Coll
|
||||
,decltype(default_contentMatch)
|
||||
,decltype(default_construct_from_payload)
|
||||
,decltype(disable_selector)
|
||||
,decltype(disable_assignment)
|
||||
,decltype(disable_childMutation)
|
||||
,decltype(&default_contentMatch)
|
||||
,decltype(&default_construct_from_payload)
|
||||
,decltype(&disable_selector)
|
||||
,decltype(&disable_assignment)
|
||||
,decltype(&disable_childMutation)
|
||||
>;
|
||||
|
||||
static FallbackBindingConfiguration
|
||||
attachTo (Coll& coll)
|
||||
{
|
||||
return { coll
|
||||
, disable_selector
|
||||
, default_contentMatch
|
||||
, default_construct_from_payload
|
||||
, disable_assignment
|
||||
, disable_childMutation
|
||||
};
|
||||
return FallbackBindingConfiguration{ coll
|
||||
, default_contentMatch
|
||||
, default_construct_from_payload
|
||||
, disable_selector
|
||||
, disable_assignment
|
||||
, disable_childMutation
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ namespace diff{
|
|||
Builder<Collection<BIN>>
|
||||
attach (BIN&& collectionBindingSetup)
|
||||
{
|
||||
return Collection<BIN> (std::forward<BIN>(collectionBindingSetup));
|
||||
return Collection<BIN> (std::forward<BIN>(collectionBindingSetup), *this);
|
||||
}
|
||||
|
||||
/** set up a diagnostic layer, binding to TestMutationTarget.
|
||||
|
|
|
|||
|
|
@ -273,10 +273,33 @@ namespace test{
|
|||
}
|
||||
|
||||
|
||||
/** @test map mutation primitives onto a STL collection managed locally. */
|
||||
void
|
||||
mutateCollection()
|
||||
{
|
||||
TODO ("define how to map the mutation primitives onto a generic collection");
|
||||
MARK_TEST_FUN;
|
||||
|
||||
// some private data structures
|
||||
struct Data
|
||||
{
|
||||
string key;
|
||||
string val;
|
||||
|
||||
operator string() const { return _Fmt{"≺%s∫%s≻"} % key % val; }
|
||||
bool operator== (Data const& o) const { return key==o.key and val==o.val; }
|
||||
bool operator!= (Data const& o) const { return not (*this == o); }
|
||||
};
|
||||
|
||||
using VecD = std::vector<Data>;
|
||||
using MapD = std::map<string, VecD>;
|
||||
|
||||
VecD target;
|
||||
|
||||
// now set up a binding to these opaque private structures...
|
||||
auto mutator =
|
||||
TreeMutator::build()
|
||||
.attach (collection(target));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue