51 , pattern_(
Binding(spec).buildMatcher())
57 return pattern_.matches (
Binding(refSpec));
63 pattern_ =
Binding(newSpec).buildMatcher();
69 void setSolution (
TestPOA* p) { solution_ = p; }
70 const TestPOA* getSolution ()
const {
return solution_;}
76 return hash_value (entry.pattern_);
83 const uint MAX_TEST_ENTRIES = 10;
85 std::vector<TestPOA> testEntries(MAX_TEST_ENTRIES);
93 REQUIRE (
id < testEntries.size());
95 if (!testEntries[
id].matches(spec))
96 testEntries[
id] =
TestPOA(spec);
98 return testEntries[id];
105 REQUIRE (req < testEntries.size());
106 REQUIRE (prov < testEntries.size());
108 return testEntries[req].solution_ == & testEntries[prov];
115 REQUIRE (req < testEntries.size());
116 return NULL == testEntries[req].solution_;
120 typedef Index<TestPOA> Index;
151 retractProvision (idx);
153 modifyProvision (idx);
160 buildIndex (Index& idx)
162 CHECK (idx.isValid());
163 CHECK (0 == idx.size());
165 idx.addRequest (
_entry (1,
"cat"));
166 idx.addRequest (
_entry (2,
"cat"));
167 idx.addRequest (
_entry (3,
"dog"));
168 CHECK (3 == idx.size());
169 CHECK (3 == idx.request_count());
170 CHECK (0 == idx.provision_count());
172 idx.addProvision (
_entry (4,
"dog"));
173 CHECK (4 == idx.size());
174 CHECK (3 == idx.request_count());
175 CHECK (1 == idx.provision_count());
180 CHECK (idx.isValid());
185 addRequest (Index& idx)
187 CHECK (idx.isValid());
188 uint req_cnt = idx.request_count();
190 idx.addRequest (
_entry (5,
"dog"));
191 idx.addRequest (
_entry (6,
"cat"));
193 CHECK (idx.hasRequest (
_entry (5,
"dog")));
194 CHECK (idx.hasRequest (
_entry (6,
"cat")));
198 CHECK (idx.isValid());
199 CHECK (2 + req_cnt == idx.request_count());
204 addProvision (Index& idx)
206 CHECK (idx.isValid());
207 uint r_cnt = idx.request_count();
208 uint p_cnt = idx.provision_count();
216 idx.addProvision (
_entry (7,
"cat"));
217 CHECK (idx.hasProvision (
_entry (7,
"cat")));
224 CHECK (idx.isValid());
225 CHECK (1 + p_cnt == idx.provision_count());
226 CHECK (0 + r_cnt == idx.request_count());
228 idx.addProvision (
_entry (8,
"dog"));
235 CHECK (idx.isValid());
236 CHECK (2 + p_cnt == idx.provision_count());
237 CHECK (0 + r_cnt == idx.request_count());
242 removeRequest (Index& idx)
244 CHECK (idx.isValid());
245 uint r_cnt = idx.request_count();
246 uint p_cnt = idx.provision_count();
253 CHECK ( idx.hasRequest (
_entry (2,
"cat")));
255 idx.removeRequest (
_entry (2,
"cat"));
257 CHECK (!idx.hasRequest (
_entry (2,
"cat")));
258 CHECK (p_cnt == idx.provision_count());
259 CHECK (r_cnt-1 == idx.request_count());
266 idx.removeRequest (
_entry (2,
"cat"));
267 CHECK (!idx.hasRequest (
_entry (2,
"cat")));
268 CHECK (p_cnt == idx.provision_count());
269 CHECK (r_cnt-1 == idx.request_count());
270 CHECK (idx.isValid());
275 retractProvision (Index& idx)
277 CHECK (idx.isValid());
278 uint r_cnt = idx.request_count();
279 uint p_cnt = idx.provision_count();
285 CHECK ( idx.hasProvision (
_entry (4,
"dog")));
287 idx.removeProvision (
_entry (4,
"dog"));
289 CHECK (!idx.hasProvision (
_entry (4,
"dog")));
290 CHECK (p_cnt-1 == idx.provision_count());
291 CHECK (r_cnt == idx.request_count());
298 CHECK ( idx.hasProvision (
_entry (8,
"dog")));
300 idx.removeProvision (
_entry (8,
"dog"));
302 CHECK (!idx.hasProvision (
_entry (8,
"dog")));
303 CHECK (p_cnt-2 == idx.provision_count());
304 CHECK (r_cnt == idx.request_count());
313 idx.removeProvision (
_entry (8,
"dog"));
314 CHECK (!idx.hasProvision (
_entry (8,
"dog")));
315 CHECK (p_cnt-2 == idx.provision_count());
316 CHECK (r_cnt == idx.request_count());
317 CHECK (idx.isValid());
322 modifyRequest (Index& idx)
324 CHECK (idx.isValid());
325 uint r_cnt = idx.request_count();
326 uint p_cnt = idx.provision_count();
334 CHECK ( idx.hasRequest (
_entry (5,
"dog")));
335 _entry (5,
"dog").changeBinding(
"cat");
337 CHECK (!idx.hasRequest (
_entry (5,
"cat")));
339 idx.modifyRequest (dogHash,
_entry (5,
"cat"));
341 CHECK ( idx.hasRequest (
_entry (5,
"cat")));
342 CHECK (p_cnt == idx.provision_count());
343 CHECK (r_cnt == idx.request_count());
352 modifyProvision (Index& idx)
354 CHECK (idx.isValid());
355 uint r_cnt = idx.request_count();
356 uint p_cnt = idx.provision_count();
362 CHECK ( idx.hasProvision (
_entry (7,
"cat")));
363 CHECK (!idx.hasProvision (
_entry (8,
"dog")));
365 idx.modifyProvision (
_entry (7,
"cat"),
_entry (8,
"dog"));
366 CHECK (!idx.hasProvision (
_entry (7,
"cat")));
367 CHECK ( idx.hasProvision (
_entry (8,
"dog")));
368 CHECK (p_cnt == idx.provision_count());
369 CHECK (r_cnt == idx.request_count());
375 idx.addProvision (
_entry (7,
"cat"));
376 idx.addProvision (
_entry (9,
"cat"));
377 CHECK (p_cnt+2 == idx.provision_count());
378 CHECK (idx.hasProvision (
_entry (7,
"cat")));
379 CHECK (idx.hasProvision (
_entry (9,
"cat")));
385 CHECK ( idx.hasProvision (
_entry (7,
"cat")));
386 CHECK (!idx.hasProvision (
_entry (4,
"dog")));
388 idx.modifyProvision (
_entry (7,
"cat"),
_entry (4,
"dog"));
390 CHECK (!idx.hasProvision (
_entry (7,
"cat")));
391 CHECK ( idx.hasProvision (
_entry (4,
"dog")));
399 idx.modifyProvision (
_entry (9,
"cat"),
_entry (7,
"cat"));
400 CHECK (!idx.hasProvision (
_entry (9,
"cat")));
401 CHECK ( idx.hasProvision (
_entry (7,
"cat")));
402 CHECK ( idx.hasProvision (
_entry (4,
"dog")));
408 CHECK (p_cnt+2 == idx.provision_count());
409 CHECK (r_cnt == idx.request_count());
410 CHECK (idx.isValid());
415 clearIndex (Index& idx)
418 CHECK (idx.isValid());
419 CHECK (0 == idx.size());
bool _hasSolution(uint req, uint prov)
check if the given request got the denoted solution
Conjunction of predicates to be matched against a collaboration partner for establishing an Advice co...
TestPOA & _entry(uint id, Literal spec)
convenience shortcut for writing testcases inline
Functor object for matching against another Binding.
bool _hasDefault(uint req)
check if the given request holds a default solution
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
inline string literal This is a marker type to indicate that
Implementation datastructure for use by the Advice system.
Simplistic test class runner.
Test dummy record, representing either a provision or an request.
Hash value types and utilities.
size_t HashVal
a STL compatible hash value
Lumiera public interface.