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:
Fischlurch 2016-03-19 16:47:40 +01:00
parent a106a0e090
commit df8ca071a8
3 changed files with 50 additions and 17 deletions

View file

@ -86,12 +86,21 @@
Coll& collection; Coll& collection;
SEL isApplicable;
MAT matches; MAT matches;
CTR construct; CTR construct;
SEL isApplicable;
ASS assign; ASS assign;
MUT openSub; 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 === */ /* === content manipulation API === */
@ -305,6 +314,7 @@
struct CollectionBindingBuilder struct CollectionBindingBuilder
: CollectionBinding<COLL,MAT,CTR,SEL,ASS,MUT> : CollectionBinding<COLL,MAT,CTR,SEL,ASS,MUT>
{ {
using CollectionBinding<COLL,MAT,CTR,SEL,ASS,MUT>::CollectionBinding;
template<class FUN> template<class FUN>
CollectionBindingBuilder<COLL, FUN ,CTR,SEL,ASS,MUT> CollectionBindingBuilder<COLL, FUN ,CTR,SEL,ASS,MUT>
@ -393,13 +403,13 @@
static bool static bool
default_contentMatch (GenNode const& spec, Elm const& elm) default_contentMatch (GenNode const& spec, Elm const& elm)
{ {
return spec.matches(elm); //return spec.matches(elm);
} }
static Elm static Elm
default_construct_from_payload (GenNode const& spec) default_construct_from_payload (GenNode const& spec)
{ {
return spec.data.get<Elm>(); //return spec.data.get<Elm>();
} }
static bool static bool
@ -423,23 +433,23 @@
using FallbackBindingConfiguration using FallbackBindingConfiguration
= CollectionBindingBuilder<Coll = CollectionBindingBuilder<Coll
,decltype(default_contentMatch) ,decltype(&default_contentMatch)
,decltype(default_construct_from_payload) ,decltype(&default_construct_from_payload)
,decltype(disable_selector) ,decltype(&disable_selector)
,decltype(disable_assignment) ,decltype(&disable_assignment)
,decltype(disable_childMutation) ,decltype(&disable_childMutation)
>; >;
static FallbackBindingConfiguration static FallbackBindingConfiguration
attachTo (Coll& coll) attachTo (Coll& coll)
{ {
return { coll return FallbackBindingConfiguration{ coll
, disable_selector , default_contentMatch
, default_contentMatch , default_construct_from_payload
, default_construct_from_payload , disable_selector
, disable_assignment , disable_assignment
, disable_childMutation , disable_childMutation
}; };
} }
}; };

View file

@ -351,7 +351,7 @@ namespace diff{
Builder<Collection<BIN>> Builder<Collection<BIN>>
attach (BIN&& collectionBindingSetup) 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. /** set up a diagnostic layer, binding to TestMutationTarget.

View file

@ -273,10 +273,33 @@ namespace test{
} }
/** @test map mutation primitives onto a STL collection managed locally. */
void void
mutateCollection() 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));
} }