60 , pattern_(
Binding(spec).buildMatcher())
66 return pattern_.matches (
Binding(refSpec));
72 pattern_ =
Binding(newSpec).buildMatcher();
78 void setSolution (
TestPOA* p) { solution_ = p; }
79 const TestPOA* getSolution ()
const {
return solution_;}
85 return hash_value (entry.pattern_);
92 const uint MAX_TEST_ENTRIES = 10;
94 std::vector<TestPOA> testEntries(MAX_TEST_ENTRIES);
102 REQUIRE (
id < testEntries.size());
104 if (!testEntries[
id].matches(spec))
105 testEntries[
id] =
TestPOA(spec);
107 return testEntries[id];
114 REQUIRE (req < testEntries.size());
115 REQUIRE (prov < testEntries.size());
117 return testEntries[req].solution_ == & testEntries[prov];
124 REQUIRE (req < testEntries.size());
125 return NULL == testEntries[req].solution_;
129 typedef Index<TestPOA> Index;
160 retractProvision (idx);
162 modifyProvision (idx);
169 buildIndex (Index& idx)
171 CHECK (idx.isValid());
172 CHECK (0 == idx.size());
174 idx.addRequest (
_entry (1,
"cat"));
175 idx.addRequest (
_entry (2,
"cat"));
176 idx.addRequest (
_entry (3,
"dog"));
177 CHECK (3 == idx.size());
178 CHECK (3 == idx.request_count());
179 CHECK (0 == idx.provision_count());
181 idx.addProvision (
_entry (4,
"dog"));
182 CHECK (4 == idx.size());
183 CHECK (3 == idx.request_count());
184 CHECK (1 == idx.provision_count());
189 CHECK (idx.isValid());
194 addRequest (Index& idx)
196 CHECK (idx.isValid());
197 uint req_cnt = idx.request_count();
199 idx.addRequest (
_entry (5,
"dog"));
200 idx.addRequest (
_entry (6,
"cat"));
202 CHECK (idx.hasRequest (
_entry (5,
"dog")));
203 CHECK (idx.hasRequest (
_entry (6,
"cat")));
207 CHECK (idx.isValid());
208 CHECK (2 + req_cnt == idx.request_count());
213 addProvision (Index& idx)
215 CHECK (idx.isValid());
216 uint r_cnt = idx.request_count();
217 uint p_cnt = idx.provision_count();
225 idx.addProvision (
_entry (7,
"cat"));
226 CHECK (idx.hasProvision (
_entry (7,
"cat")));
233 CHECK (idx.isValid());
234 CHECK (1 + p_cnt == idx.provision_count());
235 CHECK (0 + r_cnt == idx.request_count());
237 idx.addProvision (
_entry (8,
"dog"));
244 CHECK (idx.isValid());
245 CHECK (2 + p_cnt == idx.provision_count());
246 CHECK (0 + r_cnt == idx.request_count());
251 removeRequest (Index& idx)
253 CHECK (idx.isValid());
254 uint r_cnt = idx.request_count();
255 uint p_cnt = idx.provision_count();
262 CHECK ( idx.hasRequest (
_entry (2,
"cat")));
264 idx.removeRequest (
_entry (2,
"cat"));
266 CHECK (!idx.hasRequest (
_entry (2,
"cat")));
267 CHECK (p_cnt == idx.provision_count());
268 CHECK (r_cnt-1 == idx.request_count());
275 idx.removeRequest (
_entry (2,
"cat"));
276 CHECK (!idx.hasRequest (
_entry (2,
"cat")));
277 CHECK (p_cnt == idx.provision_count());
278 CHECK (r_cnt-1 == idx.request_count());
279 CHECK (idx.isValid());
284 retractProvision (Index& idx)
286 CHECK (idx.isValid());
287 uint r_cnt = idx.request_count();
288 uint p_cnt = idx.provision_count();
294 CHECK ( idx.hasProvision (
_entry (4,
"dog")));
296 idx.removeProvision (
_entry (4,
"dog"));
298 CHECK (!idx.hasProvision (
_entry (4,
"dog")));
299 CHECK (p_cnt-1 == idx.provision_count());
300 CHECK (r_cnt == idx.request_count());
307 CHECK ( idx.hasProvision (
_entry (8,
"dog")));
309 idx.removeProvision (
_entry (8,
"dog"));
311 CHECK (!idx.hasProvision (
_entry (8,
"dog")));
312 CHECK (p_cnt-2 == idx.provision_count());
313 CHECK (r_cnt == idx.request_count());
322 idx.removeProvision (
_entry (8,
"dog"));
323 CHECK (!idx.hasProvision (
_entry (8,
"dog")));
324 CHECK (p_cnt-2 == idx.provision_count());
325 CHECK (r_cnt == idx.request_count());
326 CHECK (idx.isValid());
331 modifyRequest (Index& idx)
333 CHECK (idx.isValid());
334 uint r_cnt = idx.request_count();
335 uint p_cnt = idx.provision_count();
343 CHECK ( idx.hasRequest (
_entry (5,
"dog")));
344 _entry (5,
"dog").changeBinding(
"cat");
346 CHECK (!idx.hasRequest (
_entry (5,
"cat")));
348 idx.modifyRequest (dogHash,
_entry (5,
"cat"));
350 CHECK ( idx.hasRequest (
_entry (5,
"cat")));
351 CHECK (p_cnt == idx.provision_count());
352 CHECK (r_cnt == idx.request_count());
361 modifyProvision (Index& idx)
363 CHECK (idx.isValid());
364 uint r_cnt = idx.request_count();
365 uint p_cnt = idx.provision_count();
371 CHECK ( idx.hasProvision (
_entry (7,
"cat")));
372 CHECK (!idx.hasProvision (
_entry (8,
"dog")));
374 idx.modifyProvision (
_entry (7,
"cat"),
_entry (8,
"dog"));
375 CHECK (!idx.hasProvision (
_entry (7,
"cat")));
376 CHECK ( idx.hasProvision (
_entry (8,
"dog")));
377 CHECK (p_cnt == idx.provision_count());
378 CHECK (r_cnt == idx.request_count());
384 idx.addProvision (
_entry (7,
"cat"));
385 idx.addProvision (
_entry (9,
"cat"));
386 CHECK (p_cnt+2 == idx.provision_count());
387 CHECK (idx.hasProvision (
_entry (7,
"cat")));
388 CHECK (idx.hasProvision (
_entry (9,
"cat")));
394 CHECK ( idx.hasProvision (
_entry (7,
"cat")));
395 CHECK (!idx.hasProvision (
_entry (4,
"dog")));
397 idx.modifyProvision (
_entry (7,
"cat"),
_entry (4,
"dog"));
399 CHECK (!idx.hasProvision (
_entry (7,
"cat")));
400 CHECK ( idx.hasProvision (
_entry (4,
"dog")));
408 idx.modifyProvision (
_entry (9,
"cat"),
_entry (7,
"cat"));
409 CHECK (!idx.hasProvision (
_entry (9,
"cat")));
410 CHECK ( idx.hasProvision (
_entry (7,
"cat")));
411 CHECK ( idx.hasProvision (
_entry (4,
"dog")));
417 CHECK (p_cnt+2 == idx.provision_count());
418 CHECK (r_cnt == idx.request_count());
419 CHECK (idx.isValid());
424 clearIndex (Index& idx)
427 CHECK (idx.isValid());
428 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.
Simple 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.