Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gen-node-basic-test.cpp
Go to the documentation of this file.
1 /*
2  GenNodeBasic(Test) - fundamental properties of a generic tree node element
3 
4  Copyright (C) Lumiera.org
5  2015, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
28 #include "lib/test/run.hpp"
29 #include "lib/test/test-helper.hpp"
30 #include "lib/format-cout.hpp"
31 #include "lib/diff/gen-node.hpp"
32 #include "lib/diff/record.hpp"
33 #include "lib/time/timevalue.hpp"
34 #include "lib/util-quant.hpp"
35 #include "lib/util.hpp"
36 
37 #include <string>
38 
39 using util::isnil;
40 using util::contains;
41 using util::isSameObject;
42 using util::almostEqual;
43 using lib::hash::LuidH;
44 using lib::time::FSecs;
45 using lib::time::Time;
48 using std::string;
49 
50 
51 namespace lib {
52 namespace diff{
53 namespace test{
54 
55  using error::LERR_(WRONG_TYPE);
56  using error::LERR_(BOTTOM_VALUE);
57 
58  namespace {//Test fixture....
59 
60  const double PI = 3.14159265358979323846264338328;
61 
62  }//(End)Test fixture
63 
64 
65 
66 
67 
68 
69 
70 
71 
72  /*****************************************************************************/
91  class GenNodeBasic_test : public Test
92  {
93 
94  virtual void
95  run (Arg)
96  {
97  simpleUsage();
98  equalityMatch();
100  symbolReference();
102  }
103 
104 
105  void
107  {
108  // can build from the supported value types
109  GenNode n1(42);
110  CHECK (42 == n1.data.get<int>());
111  CHECK (!n1.isNamed());
112  CHECK (contains (n1.idi.getSym(), "_CHILD_"));
113  CHECK (contains (name(n1), "_CHILD_"));
114 
115  // can optionally be named
116  GenNode n2("π", PI);
117  CHECK (almostEqual (PI, n2.data.get<double>()));
118  CHECK (n2.isNamed());
119  CHECK ("π" == n2.idi.getSym());
120  CHECK ("π" == name(n2));
121 
122  // is a copyable value
123  GenNode n11(n1);
124  CHECK (n1 == n11);
125  CHECK (42 == n11.data.get<int>());
126 
127  // is assignable with compatible payload value
128  n11.data = 24;
129  CHECK (n1 != n11);
130  CHECK (24 == n11.data.get<int>());
131  CHECK (42 == n1.data.get<int>());
132 
133  // is assignable within the same kind of value
134  n1 = n11;
135  CHECK (n1 == n11);
136 
137  // but assignment may not alter payload type
138  VERIFY_ERROR (WRONG_TYPE, n1 = n2 );
139 
140  // can build recursive data structures
141  GenNode n3(Rec({GenNode("type", "spam"), GenNode("ham", "eggs")}));
142  CHECK ("spam" == n3.data.get<Rec>().getType());
143  CHECK ("eggs" == n3.data.get<Rec>().get("ham").data.get<string>());
144  CHECK ("ham" == n3.data.get<Rec>().get("ham").idi.getSym());
145  CHECK (n3.data.get<Rec>().get("ham").isNamed());
146  CHECK (!n3.isNamed());
147 
148  cout << n3 <<endl; // diagnostic spam
149  }
150 
151 
152  void
154  {
155  auto o0 = MakeRec().genNode();
156  auto o1 = MakeRec().genNode("νόμος");
157  auto o2 = MakeRec().type("spam").genNode();
158  auto o3 = MakeRec().attrib("Ψ", int64_t(42), "π", 3.14159265358979323846264338328).genNode("λόγος");
159 
160  CHECK (!o0.isNamed());
161  CHECK (isnil(o0.data.get<Rec>()));
162  CHECK ("NIL" == o0.data.get<Rec>().getType());
163 
164  CHECK (o1.isNamed());
165  CHECK ("νόμος" == o1.idi.getSym());
166  CHECK (isnil(o1.data.get<Rec>()));
167 
168  CHECK (!o2.isNamed());
169  CHECK ("spam" == o2.data.get<Rec>().getType());
170  CHECK (isnil(o2.data.get<Rec>()));
171 
172  CHECK (o3.isNamed());
173  CHECK ("λόγος" == o3.idi.getSym());
174  CHECK ("NIL" == o3.data.get<Rec>().getType());
175  CHECK (GenNode("Ψ", int64_t(42)) == o3.data.get<Rec>().get("Ψ"));
176  CHECK (42L == o3.data.get<Rec>().get("Ψ").data.get<int64_t>());
177  CHECK (almostEqual (PI, o3.data.get<Rec>().get("π").data.get<double>()));
178 
179  LuidH luid;
180  //Demonstration: object builder is based on the mutator mechanism for Records...
181  auto o4 = Rec::Mutator(o2.data.get<Rec>()) // ...use GenNode o2 as starting point
182  .appendChild(GenNode("τ", Time(1,2,3,4))) // a named node with Time value
183  .scope('*' // a char node
184  ,"★" // a string node
185  ,luid // a hash value (LUID)
186  ,TimeSpan(Time::ZERO, FSecs(23,25)) // a time span
187  ,MakeRec().type("ham").scope("eggs").genNode()) // a spam object
188  .genNode("baked beans"); // ---> finish into named node
189 
190  CHECK (o4.isNamed());
191  CHECK ("baked beans" == o4.idi.getSym());
192  CHECK ("spam" == o4.data.get<Rec>().getType()); // this was "inherited" from o2
193 
194  auto scope = o4.data.get<Rec>().scope();
195  CHECK (!isnil(scope));
196  CHECK (GenNode("τ", Time(1,2,3,4)) == *scope);
197  ++scope;
198  CHECK (char('*') == scope->data.get<char>());
199  ++scope;
200  CHECK ("★" == scope->data.get<string>());
201  ++scope;
202  CHECK (luid == scope->data.get<LuidH>());
203  ++scope;
204  CHECK (Time(920,0) == scope->data.get<TimeSpan>().end());
205  ++scope;
206  auto spam = *scope;
207  CHECK (!++scope);
208  CHECK ("ham" == spam.data.get<Rec>().getType());
209  CHECK (spam.contains ("eggs"));
210 
211  // but while o4 was based on o2,
212  // adding all the additional contents didn't mutate o2
213  CHECK (isnil(o2.data.get<Rec>()));
214  }
215 
216 
217 
218  void
220  {
221  GenNode ham = MakeRec().type("spam").attrib("τ", Time(23,42)).genNode("egg bacon sausage and spam");
222 
223  GenNode::ID hamID(ham);
224  CHECK (hamID == ham.idi);
225  CHECK (hamID.getSym() == ham.idi.getSym());
226  CHECK (hamID.getHash() == ham.idi.getHash());
227  CHECK (contains (string(hamID), "spam")); // Lovely spam!
228 
229  Ref ref1("egg bacon sausage and spam"); // empty placeholder
230  Ref ref2(ham);
231 
232  CHECK (ref1.idi == ham.idi);
233  CHECK (ref2.idi == ham.idi);
234 
235  // can stand-in for the original Record...
236  Rec& hamRef = ham.data.get<Rec>();
237  CHECK (isSameObject (hamRef, ref2.data.get<Rec>()));
238  VERIFY_ERROR (BOTTOM_VALUE, ref1.data.get<Rec>());
239 
240  RecRef rr1 = ref1.data.get<RecRef>();
241  RecRef rr2 = ref2.data.get<RecRef>();
242 
243  CHECK ( isnil(rr1));
244  CHECK (!isnil(rr2));
245  Rec& ham_ref = rr2;
246  CHECK (isSameObject(hamRef, ham_ref));
247  CHECK (isSameObject(hamRef, *rr2.get()));
248 
249  // pre-defined special ref-tokens
250  CHECK ("_END_" == name(Ref::END));
251  CHECK ("_THIS_" == name(Ref::THIS));
252  CHECK ("_CHILD_" == name(Ref::CHILD));
253  CHECK ("_ATTRIBS_" == name(Ref::ATTRIBS));
254 
255  CHECK (isnil (Ref::END.data.get<RecRef>()));
256  CHECK (isnil (Ref::THIS.data.get<RecRef>()));
257  CHECK (isnil (Ref::CHILD.data.get<RecRef>()));
258  CHECK (isnil (Ref::ATTRIBS.data.get<RecRef>()));
259  }
260 
261 
262  void
264  {
265  GenNode n = MakeRec()
266  .scope('*' // a char node
267  ,"★" // a string node
268  , PI // a double value
269  ,MakeRec().type("ham")
270  .scope("eggs","spam","spam")
271  .genNode("spam") // a spam object
272  ,TimeSpan(Time::ZERO, FSecs(23,25)) // a time span
273  ,int64_t(42)) // long value
274  .attrib("hasSpam", true) // boolean Attribute
275  .genNode("baked beans"); // build Node from named Record
276 
277 
278  cout << "--spam--"<<endl;
279  for (auto & elm : n)
280  cout << elm <<endl;
281 
282 
283  auto iter = n.begin();
284  CHECK (!isnil (iter));
285  CHECK (1 == iter.level());
286  CHECK ("baked beans" == iter->idi.getSym()); // initially the Record itself is exposed
287  CHECK (Rec::TYPE_NIL == iter->data.get<Rec>().getType());
288 
289  ++iter;
290  CHECK (2 == iter.level()); // delve into the contents,
291  CHECK ("hasSpam" == iter->idi.getSym()); // ...starting with the attribute(s)
292  CHECK (true == iter->data.get<bool>());
293  CHECK ("GenNode-ID(\"hasSpam\")-DataCap|«bool»|true" == string(*iter));
294 
295  ++iter;
296  CHECK (!iter->isNamed()); // contents of the object's scope
297  CHECK ('*' == iter->data.get<char>());
298 
299  ++iter;
300  CHECK (!iter->isNamed());
301  CHECK ("★" == iter->data.get<string>());
302 
303  ++iter;
304  CHECK (!iter->isNamed());
305  CHECK (almostEqual (PI, iter->data.get<double>()));
306 
307  ++iter;
308  CHECK ("spam" == iter->idi.getSym()); // the nested object is first exposed as a whole
309  CHECK ("ham" == iter->data.get<Rec>().getType());
310 
311  ++iter;
312  CHECK (3 == iter.level());
313  CHECK ("eggs" == iter->data.get<string>()); // contents of the nested ("spam") object's scope
314 
315  ++iter;
316  CHECK ("spam" == iter->data.get<string>());
317 
318  ++iter;
319  CHECK ("spam" == iter->data.get<string>());
320  CHECK (3 == iter.level());
321 
322  ++iter;
323  CHECK (2 == iter.level()); // decreasing level indicates we left nested scope
324  CHECK (!iter->isNamed()); // next item in the enclosing scope
325  CHECK ("0:00:00.000≺920ms≻" == string(iter->data.get<TimeSpan>()));
326  ++iter;
327  CHECK (!iter->isNamed());
328  CHECK (42 == iter->data.get<int64_t>());
329  CHECK (2 == iter.level());
330 
331  ++iter; // nothing more on top level beyond the initial Record
332  CHECK (0 == iter.level());
333  CHECK (isnil (iter));
334 
335 
336 
337  // another kind of iteration: shallow child data sequence
338  // note: exposing the DataCap of each child
339  auto child = childData(n);
340  CHECK (!isnil (child));
341  CHECK ('*' == child->get<char>());
342 
343  ++child;
344  CHECK ("★" == child->get<string>());
345 
346  ++child;
347  CHECK (almostEqual (PI, child->get<double>()));
348 
349  ++child;
350  CHECK ("ham" == child->get<Rec>().getType());
351  CHECK ("eggs" == child->get<Rec>().child(0).data.get<string>());
352 
353  ++child;
354  CHECK (TimeSpan(Time::ZERO, FSecs(23,25)) == child->get<TimeSpan>());
355 
356  ++child;
357  CHECK (42 == child->get<int64_t>());
358 
359  ++child;
360  CHECK (isnil (child));
361  }
362 
363 
364  void
366  {
367  int i1 = 64; GenNode ni1(i1);
368  int i2 = 126; GenNode ni2(i2);
369  int64_t l1 = 64; GenNode nl1(l1);
370  int64_t l2 = 126; GenNode nl2(l2);
371  short r1 = 64; GenNode nr1(r1);
372  short r2 = 126; GenNode nr2(r2);
373  double d1 = 64; GenNode nd1(d1);
374  double d2 = 126; GenNode nd2(d2);
375  char c1 = '@'; GenNode nc1(c1);
376  char c2 = '~'; GenNode nc2(c2);
377  bool b1 = true; GenNode nb1(b1);
378  bool b2 = false; GenNode nb2(b2);
379  string s1 = ""; GenNode ns1(s1);
380  string s2 = "↯"; GenNode ns2(s2);
381 
382  time::Time t1 = randTime(); GenNode nt1(t1);
383  time::Time t2(-t1); GenNode nt2(t2);
384  time::Offset to1(t1); GenNode nto1(to1);
385  time::Offset to2(t2); GenNode nto2(to2);
386  time::Duration td1(to2); GenNode ntd1(td1);
387  time::Duration td2(to2*2); GenNode ntd2(td2);
388  time::TimeSpan ts1(t1, td1); GenNode nts1(ts1);
389  time::TimeSpan ts2(t2, td2); GenNode nts2(ts2);
390  hash::LuidH h1; GenNode nh1(h1);
391  hash::LuidH h2; GenNode nh2(h2);
392 
393  Rec spam1({GenNode("ham", "eggs")}); GenNode rec1(spam1);
394  Rec spam2(MakeRec(spam1).type("spam")); GenNode rec2(spam2);
395 
396  RecRef recRef1(spam1); Ref ref1(rec1);
397  RecRef recRef2(spam2); Ref ref2(rec2);
398  // NOTE: same ID as referee
399  CHECK (ni1 == ni1);
400  CHECK (ni2 == ni2);
401  CHECK (nl1 == nl1);
402  CHECK (nl2 == nl2);
403  CHECK (nr1 == nr1);
404  CHECK (nr2 == nr2);
405  CHECK (nd1 == nd1);
406  CHECK (nd2 == nd2);
407  CHECK (nc1 == nc1);
408  CHECK (nc2 == nc2);
409  CHECK (nb1 == nb1);
410  CHECK (nb2 == nb2);
411  CHECK (ns1 == ns1);
412  CHECK (ns2 == ns2);
413  CHECK (nt1 == nt1 );
414  CHECK (nt2 == nt2 );
415  CHECK (nto1 == nto1);
416  CHECK (nto2 == nto2);
417  CHECK (ntd1 == ntd1);
418  CHECK (ntd2 == ntd2);
419  CHECK (nts1 == nts1);
420  CHECK (nts2 == nts2);
421  CHECK (nh1 == nh1 );
422  CHECK (nh2 == nh2 );
423  CHECK (rec1 == rec1);
424  CHECK (rec2 == rec2);
425  CHECK (ref1 == ref1);
426  CHECK (ref2 == ref2);
427 
428  CHECK (ni1 != ni2); CHECK (ni2 != ni1);
429  CHECK (nl1 != nl2); CHECK (nl2 != nl1);
430  CHECK (nr1 != nr2); CHECK (nr2 != nr1);
431  CHECK (nd1 != nd2); CHECK (nd2 != nd1);
432  CHECK (nc1 != nc2); CHECK (nc2 != nc1);
433  CHECK (nb1 != nb2); CHECK (nb2 != nb1);
434  CHECK (ns1 != ns2); CHECK (ns2 != ns1);
435  CHECK (nt1 != nt2 ); CHECK (nt2 != nt1 );
436  CHECK (nto1 != nto2); CHECK (nto2 != nto1);
437  CHECK (ntd1 != ntd2); CHECK (ntd2 != ntd1);
438  CHECK (nts1 != nts2); CHECK (nts2 != nts1);
439  CHECK (nh1 != nh2 ); CHECK (nh2 != nh1 );
440  CHECK (rec1 != rec2); CHECK (rec2 != rec1);
441  CHECK (ref1 != ref2); CHECK (ref2 != ref1);
442 
443  CHECK (ni1 != ni2); CHECK (ni2 != ni1);
444  CHECK (ni1 != nl1); CHECK (nl1 != ni1);
445  CHECK (ni1 != nl2); CHECK (nl2 != ni1);
446  CHECK (ni1 != nr1); CHECK (nr1 != ni1);
447  CHECK (ni1 != nr2); CHECK (nr2 != ni1);
448  CHECK (ni1 != nd1); CHECK (nd1 != ni1);
449  CHECK (ni1 != nd2); CHECK (nd2 != ni1);
450  CHECK (ni1 != nc1); CHECK (nc1 != ni1);
451  CHECK (ni1 != nc2); CHECK (nc2 != ni1);
452  CHECK (ni1 != nb1); CHECK (nb1 != ni1);
453  CHECK (ni1 != nb2); CHECK (nb2 != ni1);
454  CHECK (ni1 != ns1); CHECK (ns1 != ni1);
455  CHECK (ni1 != ns2); CHECK (ns2 != ni1);
456  CHECK (ni1 != nt1 ); CHECK (nt1 != ni1);
457  CHECK (ni1 != nt2 ); CHECK (nt2 != ni1);
458  CHECK (ni1 != nto1); CHECK (nto1 != ni1);
459  CHECK (ni1 != nto2); CHECK (nto2 != ni1);
460  CHECK (ni1 != ntd1); CHECK (ntd1 != ni1);
461  CHECK (ni1 != ntd2); CHECK (ntd2 != ni1);
462  CHECK (ni1 != nts1); CHECK (nts1 != ni1);
463  CHECK (ni1 != nts2); CHECK (nts2 != ni1);
464  CHECK (ni1 != nh1 ); CHECK (nh1 != ni1);
465  CHECK (ni1 != nh2 ); CHECK (nh2 != ni1);
466  CHECK (ni1 != rec1); CHECK (rec1 != ni1);
467  CHECK (ni1 != rec2); CHECK (rec2 != ni1);
468  CHECK (ni1 != ref1); CHECK (ref1 != ni1);
469  CHECK (ni1 != ref2); CHECK (ref2 != ni1);
470 
471  CHECK (ni2 != nl1); CHECK (nl1 != ni2);
472  CHECK (ni2 != nl2); CHECK (nl2 != ni2);
473  CHECK (ni2 != nr1); CHECK (nr1 != ni2);
474  CHECK (ni2 != nr2); CHECK (nr2 != ni2);
475  CHECK (ni2 != nd1); CHECK (nd1 != ni2);
476  CHECK (ni2 != nd2); CHECK (nd2 != ni2);
477  CHECK (ni2 != nc1); CHECK (nc1 != ni2);
478  CHECK (ni2 != nc2); CHECK (nc2 != ni2);
479  CHECK (ni2 != nb1); CHECK (nb1 != ni2);
480  CHECK (ni2 != nb2); CHECK (nb2 != ni2);
481  CHECK (ni2 != ns1); CHECK (ns1 != ni2);
482  CHECK (ni2 != ns2); CHECK (ns2 != ni2);
483  CHECK (ni2 != nt1 ); CHECK (nt1 != ni2);
484  CHECK (ni2 != nt2 ); CHECK (nt2 != ni2);
485  CHECK (ni2 != nto1); CHECK (nto1 != ni2);
486  CHECK (ni2 != nto2); CHECK (nto2 != ni2);
487  CHECK (ni2 != ntd1); CHECK (ntd1 != ni2);
488  CHECK (ni2 != ntd2); CHECK (ntd2 != ni2);
489  CHECK (ni2 != nts1); CHECK (nts1 != ni2);
490  CHECK (ni2 != nts2); CHECK (nts2 != ni2);
491  CHECK (ni2 != nh1 ); CHECK (nh1 != ni2);
492  CHECK (ni2 != nh2 ); CHECK (nh2 != ni2);
493  CHECK (ni2 != rec1); CHECK (rec1 != ni2);
494  CHECK (ni2 != rec2); CHECK (rec2 != ni2);
495  CHECK (ni2 != ref1); CHECK (ref1 != ni2);
496  CHECK (ni2 != ref2); CHECK (ref2 != ni2);
497 
498  CHECK (nl1 != nl2); CHECK (nl2 != nl1);
499  CHECK (nl1 != nr1); CHECK (nr1 != nl1);
500  CHECK (nl1 != nr2); CHECK (nr2 != nl1);
501  CHECK (nl1 != nd1); CHECK (nd1 != nl1);
502  CHECK (nl1 != nd2); CHECK (nd2 != nl1);
503  CHECK (nl1 != nc1); CHECK (nc1 != nl1);
504  CHECK (nl1 != nc2); CHECK (nc2 != nl1);
505  CHECK (nl1 != nb1); CHECK (nb1 != nl1);
506  CHECK (nl1 != nb2); CHECK (nb2 != nl1);
507  CHECK (nl1 != ns1); CHECK (ns1 != nl1);
508  CHECK (nl1 != ns2); CHECK (ns2 != nl1);
509  CHECK (nl1 != nt1 ); CHECK (nt1 != nl1);
510  CHECK (nl1 != nt2 ); CHECK (nt2 != nl1);
511  CHECK (nl1 != nto1); CHECK (nto1 != nl1);
512  CHECK (nl1 != nto2); CHECK (nto2 != nl1);
513  CHECK (nl1 != ntd1); CHECK (ntd1 != nl1);
514  CHECK (nl1 != ntd2); CHECK (ntd2 != nl1);
515  CHECK (nl1 != nts1); CHECK (nts1 != nl1);
516  CHECK (nl1 != nts2); CHECK (nts2 != nl1);
517  CHECK (nl1 != nh1 ); CHECK (nh1 != nl1);
518  CHECK (nl1 != nh2 ); CHECK (nh2 != nl1);
519  CHECK (nl1 != rec1); CHECK (rec1 != nl1);
520  CHECK (nl1 != rec2); CHECK (rec2 != nl1);
521  CHECK (nl1 != ref1); CHECK (ref1 != nl1);
522  CHECK (nl1 != ref2); CHECK (ref2 != nl1);
523 
524  CHECK (nl2 != nr1); CHECK (nr1 != nl2);
525  CHECK (nl2 != nr2); CHECK (nr2 != nl2);
526  CHECK (nl2 != nd1); CHECK (nd1 != nl2);
527  CHECK (nl2 != nd2); CHECK (nd2 != nl2);
528  CHECK (nl2 != nc1); CHECK (nc1 != nl2);
529  CHECK (nl2 != nc2); CHECK (nc2 != nl2);
530  CHECK (nl2 != nb1); CHECK (nb1 != nl2);
531  CHECK (nl2 != nb2); CHECK (nb2 != nl2);
532  CHECK (nl2 != ns1); CHECK (ns1 != nl2);
533  CHECK (nl2 != ns2); CHECK (ns2 != nl2);
534  CHECK (nl2 != nt1 ); CHECK (nt1 != nl2);
535  CHECK (nl2 != nt2 ); CHECK (nt2 != nl2);
536  CHECK (nl2 != nto1); CHECK (nto1 != nl2);
537  CHECK (nl2 != nto2); CHECK (nto2 != nl2);
538  CHECK (nl2 != ntd1); CHECK (ntd1 != nl2);
539  CHECK (nl2 != ntd2); CHECK (ntd2 != nl2);
540  CHECK (nl2 != nts1); CHECK (nts1 != nl2);
541  CHECK (nl2 != nts2); CHECK (nts2 != nl2);
542  CHECK (nl2 != nh1 ); CHECK (nh1 != nl2);
543  CHECK (nl2 != nh2 ); CHECK (nh2 != nl2);
544  CHECK (nl2 != rec1); CHECK (rec1 != nl2);
545  CHECK (nl2 != rec2); CHECK (rec2 != nl2);
546  CHECK (nl2 != ref1); CHECK (ref1 != nl2);
547  CHECK (nl2 != ref2); CHECK (ref2 != nl2);
548 
549  CHECK (nr1 != nr2); CHECK (nr2 != nr1);
550  CHECK (nr1 != nd1); CHECK (nd1 != nr1);
551  CHECK (nr1 != nd2); CHECK (nd2 != nr1);
552  CHECK (nr1 != nc1); CHECK (nc1 != nr1);
553  CHECK (nr1 != nc2); CHECK (nc2 != nr1);
554  CHECK (nr1 != nb1); CHECK (nb1 != nr1);
555  CHECK (nr1 != nb2); CHECK (nb2 != nr1);
556  CHECK (nr1 != ns1); CHECK (ns1 != nr1);
557  CHECK (nr1 != ns2); CHECK (ns2 != nr1);
558  CHECK (nr1 != nt1 ); CHECK (nt1 != nr1);
559  CHECK (nr1 != nt2 ); CHECK (nt2 != nr1);
560  CHECK (nr1 != nto1); CHECK (nto1 != nr1);
561  CHECK (nr1 != nto2); CHECK (nto2 != nr1);
562  CHECK (nr1 != ntd1); CHECK (ntd1 != nr1);
563  CHECK (nr1 != ntd2); CHECK (ntd2 != nr1);
564  CHECK (nr1 != nts1); CHECK (nts1 != nr1);
565  CHECK (nr1 != nts2); CHECK (nts2 != nr1);
566  CHECK (nr1 != nh1 ); CHECK (nh1 != nr1);
567  CHECK (nr1 != nh2 ); CHECK (nh2 != nr1);
568  CHECK (nr1 != rec1); CHECK (rec1 != nr1);
569  CHECK (nr1 != rec2); CHECK (rec2 != nr1);
570  CHECK (nr1 != ref1); CHECK (ref1 != nr1);
571  CHECK (nr1 != ref2); CHECK (ref2 != nr1);
572 
573  CHECK (nr2 != nd1); CHECK (nd1 != nr2);
574  CHECK (nr2 != nd2); CHECK (nd2 != nr2);
575  CHECK (nr2 != nc1); CHECK (nc1 != nr2);
576  CHECK (nr2 != nc2); CHECK (nc2 != nr2);
577  CHECK (nr2 != nb1); CHECK (nb1 != nr2);
578  CHECK (nr2 != nb2); CHECK (nb2 != nr2);
579  CHECK (nr2 != ns1); CHECK (ns1 != nr2);
580  CHECK (nr2 != ns2); CHECK (ns2 != nr2);
581  CHECK (nr2 != nt1 ); CHECK (nt1 != nr2);
582  CHECK (nr2 != nt2 ); CHECK (nt2 != nr2);
583  CHECK (nr2 != nto1); CHECK (nto1 != nr2);
584  CHECK (nr2 != nto2); CHECK (nto2 != nr2);
585  CHECK (nr2 != ntd1); CHECK (ntd1 != nr2);
586  CHECK (nr2 != ntd2); CHECK (ntd2 != nr2);
587  CHECK (nr2 != nts1); CHECK (nts1 != nr2);
588  CHECK (nr2 != nts2); CHECK (nts2 != nr2);
589  CHECK (nr2 != nh1 ); CHECK (nh1 != nr2);
590  CHECK (nr2 != nh2 ); CHECK (nh2 != nr2);
591  CHECK (nr2 != rec1); CHECK (rec1 != nr2);
592  CHECK (nr2 != rec2); CHECK (rec2 != nr2);
593  CHECK (nr2 != ref1); CHECK (ref1 != nr2);
594  CHECK (nr2 != ref2); CHECK (ref2 != nr2);
595 
596  CHECK (nd1 != nd2); CHECK (nd2 != nd1);
597  CHECK (nd1 != nc1); CHECK (nc1 != nd1);
598  CHECK (nd1 != nc2); CHECK (nc2 != nd1);
599  CHECK (nd1 != nb1); CHECK (nb1 != nd1);
600  CHECK (nd1 != nb2); CHECK (nb2 != nd1);
601  CHECK (nd1 != ns1); CHECK (ns1 != nd1);
602  CHECK (nd1 != ns2); CHECK (ns2 != nd1);
603  CHECK (nd1 != nt1 ); CHECK (nt1 != nd1);
604  CHECK (nd1 != nt2 ); CHECK (nt2 != nd1);
605  CHECK (nd1 != nto1); CHECK (nto1 != nd1);
606  CHECK (nd1 != nto2); CHECK (nto2 != nd1);
607  CHECK (nd1 != ntd1); CHECK (ntd1 != nd1);
608  CHECK (nd1 != ntd2); CHECK (ntd2 != nd1);
609  CHECK (nd1 != nts1); CHECK (nts1 != nd1);
610  CHECK (nd1 != nts2); CHECK (nts2 != nd1);
611  CHECK (nd1 != nh1 ); CHECK (nh1 != nd1);
612  CHECK (nd1 != nh2 ); CHECK (nh2 != nd1);
613  CHECK (nd1 != rec1); CHECK (rec1 != nd1);
614  CHECK (nd1 != rec2); CHECK (rec2 != nd1);
615  CHECK (nd1 != ref1); CHECK (ref1 != nd1);
616  CHECK (nd1 != ref2); CHECK (ref2 != nd1);
617 
618  CHECK (nd2 != nc1); CHECK (nc1 != nd2);
619  CHECK (nd2 != nc2); CHECK (nc2 != nd2);
620  CHECK (nd2 != nb1); CHECK (nb1 != nd2);
621  CHECK (nd2 != nb2); CHECK (nb2 != nd2);
622  CHECK (nd2 != ns1); CHECK (ns1 != nd2);
623  CHECK (nd2 != ns2); CHECK (ns2 != nd2);
624  CHECK (nd2 != nt1 ); CHECK (nt1 != nd2);
625  CHECK (nd2 != nt2 ); CHECK (nt2 != nd2);
626  CHECK (nd2 != nto1); CHECK (nto1 != nd2);
627  CHECK (nd2 != nto2); CHECK (nto2 != nd2);
628  CHECK (nd2 != ntd1); CHECK (ntd1 != nd2);
629  CHECK (nd2 != ntd2); CHECK (ntd2 != nd2);
630  CHECK (nd2 != nts1); CHECK (nts1 != nd2);
631  CHECK (nd2 != nts2); CHECK (nts2 != nd2);
632  CHECK (nd2 != nh1 ); CHECK (nh1 != nd2);
633  CHECK (nd2 != nh2 ); CHECK (nh2 != nd2);
634  CHECK (nd2 != rec1); CHECK (rec1 != nd2);
635  CHECK (nd2 != rec2); CHECK (rec2 != nd2);
636  CHECK (nd2 != ref1); CHECK (ref1 != nd2);
637  CHECK (nd2 != ref2); CHECK (ref2 != nd2);
638 
639  CHECK (nc1 != nc2); CHECK (nc2 != nc1);
640  CHECK (nc1 != nb1); CHECK (nb1 != nc1);
641  CHECK (nc1 != nb2); CHECK (nb2 != nc1);
642  CHECK (nc1 != ns1); CHECK (ns1 != nc1);
643  CHECK (nc1 != ns2); CHECK (ns2 != nc1);
644  CHECK (nc1 != nt1 ); CHECK (nt1 != nc1);
645  CHECK (nc1 != nt2 ); CHECK (nt2 != nc1);
646  CHECK (nc1 != nto1); CHECK (nto1 != nc1);
647  CHECK (nc1 != nto2); CHECK (nto2 != nc1);
648  CHECK (nc1 != ntd1); CHECK (ntd1 != nc1);
649  CHECK (nc1 != ntd2); CHECK (ntd2 != nc1);
650  CHECK (nc1 != nts1); CHECK (nts1 != nc1);
651  CHECK (nc1 != nts2); CHECK (nts2 != nc1);
652  CHECK (nc1 != nh1 ); CHECK (nh1 != nc1);
653  CHECK (nc1 != nh2 ); CHECK (nh2 != nc1);
654  CHECK (nc1 != rec1); CHECK (rec1 != nc1);
655  CHECK (nc1 != rec2); CHECK (rec2 != nc1);
656  CHECK (nc1 != ref1); CHECK (ref1 != nc1);
657  CHECK (nc1 != ref2); CHECK (ref2 != nc1);
658 
659  CHECK (nc2 != nb1); CHECK (nb1 != nc2);
660  CHECK (nc2 != nb2); CHECK (nb2 != nc2);
661  CHECK (nc2 != ns1); CHECK (ns1 != nc2);
662  CHECK (nc2 != ns2); CHECK (ns2 != nc2);
663  CHECK (nc2 != nt1 ); CHECK (nt1 != nc2);
664  CHECK (nc2 != nt2 ); CHECK (nt2 != nc2);
665  CHECK (nc2 != nto1); CHECK (nto1 != nc2);
666  CHECK (nc2 != nto2); CHECK (nto2 != nc2);
667  CHECK (nc2 != ntd1); CHECK (ntd1 != nc2);
668  CHECK (nc2 != ntd2); CHECK (ntd2 != nc2);
669  CHECK (nc2 != nts1); CHECK (nts1 != nc2);
670  CHECK (nc2 != nts2); CHECK (nts2 != nc2);
671  CHECK (nc2 != nh1 ); CHECK (nh1 != nc2);
672  CHECK (nc2 != nh2 ); CHECK (nh2 != nc2);
673  CHECK (nc2 != rec1); CHECK (rec1 != nc2);
674  CHECK (nc2 != rec2); CHECK (rec2 != nc2);
675  CHECK (nc2 != ref1); CHECK (ref1 != nc2);
676  CHECK (nc2 != ref2); CHECK (ref2 != nc2);
677 
678  CHECK (nb1 != nb2); CHECK (nb2 != nb1);
679  CHECK (nb1 != ns1); CHECK (ns1 != nb1);
680  CHECK (nb1 != ns2); CHECK (ns2 != nb1);
681  CHECK (nb1 != nt1 ); CHECK (nt1 != nb1);
682  CHECK (nb1 != nt2 ); CHECK (nt2 != nb1);
683  CHECK (nb1 != nto1); CHECK (nto1 != nb1);
684  CHECK (nb1 != nto2); CHECK (nto2 != nb1);
685  CHECK (nb1 != ntd1); CHECK (ntd1 != nb1);
686  CHECK (nb1 != ntd2); CHECK (ntd2 != nb1);
687  CHECK (nb1 != nts1); CHECK (nts1 != nb1);
688  CHECK (nb1 != nts2); CHECK (nts2 != nb1);
689  CHECK (nb1 != nh1 ); CHECK (nh1 != nb1);
690  CHECK (nb1 != nh2 ); CHECK (nh2 != nb1);
691  CHECK (nb1 != rec1); CHECK (rec1 != nb1);
692  CHECK (nb1 != rec2); CHECK (rec2 != nb1);
693  CHECK (nb1 != ref1); CHECK (ref1 != nb1);
694  CHECK (nb1 != ref2); CHECK (ref2 != nb1);
695 
696  CHECK (nb2 != ns1); CHECK (ns1 != nb2);
697  CHECK (nb2 != ns2); CHECK (ns2 != nb2);
698  CHECK (nb2 != nt1 ); CHECK (nt1 != nb2);
699  CHECK (nb2 != nt2 ); CHECK (nt2 != nb2);
700  CHECK (nb2 != nto1); CHECK (nto1 != nb2);
701  CHECK (nb2 != nto2); CHECK (nto2 != nb2);
702  CHECK (nb2 != ntd1); CHECK (ntd1 != nb2);
703  CHECK (nb2 != ntd2); CHECK (ntd2 != nb2);
704  CHECK (nb2 != nts1); CHECK (nts1 != nb2);
705  CHECK (nb2 != nts2); CHECK (nts2 != nb2);
706  CHECK (nb2 != nh1 ); CHECK (nh1 != nb2);
707  CHECK (nb2 != nh2 ); CHECK (nh2 != nb2);
708  CHECK (nb2 != rec1); CHECK (rec1 != nb2);
709  CHECK (nb2 != rec2); CHECK (rec2 != nb2);
710  CHECK (nb2 != ref1); CHECK (ref1 != nb2);
711  CHECK (nb2 != ref2); CHECK (ref2 != nb2);
712 
713  CHECK (ns1 != nt2 ); CHECK (nt2 != ns1);
714  CHECK (ns1 != nto1); CHECK (nto1 != ns1);
715  CHECK (ns1 != nto2); CHECK (nto2 != ns1);
716  CHECK (ns1 != ntd1); CHECK (ntd1 != ns1);
717  CHECK (ns1 != ntd2); CHECK (ntd2 != ns1);
718  CHECK (ns1 != nts1); CHECK (nts1 != ns1);
719  CHECK (ns1 != nts2); CHECK (nts2 != ns1);
720  CHECK (ns1 != nh1 ); CHECK (nh1 != ns1);
721  CHECK (ns1 != nh2 ); CHECK (nh2 != ns1);
722  CHECK (ns1 != rec1); CHECK (rec1 != ns1);
723  CHECK (ns1 != rec2); CHECK (rec2 != ns1);
724  CHECK (ns1 != ref1); CHECK (ref1 != ns1);
725  CHECK (ns1 != ref2); CHECK (ref2 != ns1);
726 
727  CHECK (ns2 != nt1 ); CHECK (nt1 != ns2);
728  CHECK (ns2 != nt2 ); CHECK (nt2 != ns2);
729  CHECK (ns2 != nto1); CHECK (nto1 != ns2);
730  CHECK (ns2 != nto2); CHECK (nto2 != ns2);
731  CHECK (ns2 != ntd1); CHECK (ntd1 != ns2);
732  CHECK (ns2 != ntd2); CHECK (ntd2 != ns2);
733  CHECK (ns2 != nts1); CHECK (nts1 != ns2);
734  CHECK (ns2 != nts2); CHECK (nts2 != ns2);
735  CHECK (ns2 != nh1 ); CHECK (nh1 != ns2);
736  CHECK (ns2 != nh2 ); CHECK (nh2 != ns2);
737  CHECK (ns2 != rec1); CHECK (rec1 != ns2);
738  CHECK (ns2 != rec2); CHECK (rec2 != ns2);
739  CHECK (ns2 != ref1); CHECK (ref1 != ns2);
740  CHECK (ns2 != ref2); CHECK (ref2 != ns2);
741 
742  CHECK (nt1 != nt2 ); CHECK (nt2 != nt1);
743  CHECK (nt1 != nto1); CHECK (nto1 != nt1);
744  CHECK (nt1 != nto2); CHECK (nto2 != nt1);
745  CHECK (nt1 != ntd1); CHECK (ntd1 != nt1);
746  CHECK (nt1 != ntd2); CHECK (ntd2 != nt1);
747  CHECK (nt1 != nts1); CHECK (nts1 != nt1);
748  CHECK (nt1 != nts2); CHECK (nts2 != nt1);
749  CHECK (nt1 != nh1 ); CHECK (nh1 != nt1);
750  CHECK (nt1 != nh2 ); CHECK (nh2 != nt1);
751  CHECK (nt1 != rec1); CHECK (rec1 != nt1);
752  CHECK (nt1 != rec2); CHECK (rec2 != nt1);
753  CHECK (nt1 != ref1); CHECK (ref1 != nt1);
754  CHECK (nt1 != ref2); CHECK (ref2 != nt1);
755 
756  CHECK (nt2 != nto1); CHECK (nto1 != nt2);
757  CHECK (nt2 != nto2); CHECK (nto2 != nt2);
758  CHECK (nt2 != ntd1); CHECK (ntd1 != nt2);
759  CHECK (nt2 != ntd2); CHECK (ntd2 != nt2);
760  CHECK (nt2 != nts1); CHECK (nts1 != nt2);
761  CHECK (nt2 != nts2); CHECK (nts2 != nt2);
762  CHECK (nt2 != nh1 ); CHECK (nh1 != nt2);
763  CHECK (nt2 != nh2 ); CHECK (nh2 != nt2);
764  CHECK (nt2 != rec1); CHECK (rec1 != nt2);
765  CHECK (nt2 != rec2); CHECK (rec2 != nt2);
766  CHECK (nt2 != ref1); CHECK (ref1 != nt2);
767  CHECK (nt2 != ref2); CHECK (ref2 != nt2);
768 
769  CHECK (nto1 != nto2); CHECK (nto2 != nto1);
770  CHECK (nto1 != ntd1); CHECK (ntd1 != nto1);
771  CHECK (nto1 != ntd2); CHECK (ntd2 != nto1);
772  CHECK (nto1 != nts1); CHECK (nts1 != nto1);
773  CHECK (nto1 != nts2); CHECK (nts2 != nto1);
774  CHECK (nto1 != nh1 ); CHECK (nh1 != nto1);
775  CHECK (nto1 != nh2 ); CHECK (nh2 != nto1);
776  CHECK (nto1 != rec1); CHECK (rec1 != nto1);
777  CHECK (nto1 != rec2); CHECK (rec2 != nto1);
778  CHECK (nto1 != ref1); CHECK (ref1 != nto1);
779  CHECK (nto1 != ref2); CHECK (ref2 != nto1);
780 
781  CHECK (nto2 != ntd1); CHECK (ntd1 != nto2);
782  CHECK (nto2 != ntd2); CHECK (ntd2 != nto2);
783  CHECK (nto2 != nts1); CHECK (nts1 != nto2);
784  CHECK (nto2 != nts2); CHECK (nts2 != nto2);
785  CHECK (nto2 != nh1 ); CHECK (nh1 != nto2);
786  CHECK (nto2 != nh2 ); CHECK (nh2 != nto2);
787  CHECK (nto2 != rec1); CHECK (rec1 != nto2);
788  CHECK (nto2 != rec2); CHECK (rec2 != nto2);
789  CHECK (nto2 != ref1); CHECK (ref1 != nto2);
790  CHECK (nto2 != ref2); CHECK (ref2 != nto2);
791 
792  CHECK (ntd1 != ntd2); CHECK (ntd2 != ntd1);
793  CHECK (ntd1 != nts1); CHECK (nts1 != ntd1);
794  CHECK (ntd1 != nts2); CHECK (nts2 != ntd1);
795  CHECK (ntd1 != nh1 ); CHECK (nh1 != ntd1);
796  CHECK (ntd1 != nh2 ); CHECK (nh2 != ntd1);
797  CHECK (ntd1 != rec1); CHECK (rec1 != ntd1);
798  CHECK (ntd1 != rec2); CHECK (rec2 != ntd1);
799  CHECK (ntd1 != ref1); CHECK (ref1 != ntd1);
800  CHECK (ntd1 != ref2); CHECK (ref2 != ntd1);
801 
802  CHECK (ntd2 != nts1); CHECK (nts1 != ntd2);
803  CHECK (ntd2 != nts2); CHECK (nts2 != ntd2);
804  CHECK (ntd2 != nh1 ); CHECK (nh1 != ntd2);
805  CHECK (ntd2 != nh2 ); CHECK (nh2 != ntd2);
806  CHECK (ntd2 != rec1); CHECK (rec1 != ntd2);
807  CHECK (ntd2 != rec2); CHECK (rec2 != ntd2);
808  CHECK (ntd2 != ref1); CHECK (ref1 != ntd2);
809  CHECK (ntd2 != ref2); CHECK (ref2 != ntd2);
810 
811  CHECK (nts1 != nts2); CHECK (nts2 != nts1);
812  CHECK (nts1 != nh1 ); CHECK (nh1 != nts1);
813  CHECK (nts1 != nh2 ); CHECK (nh2 != nts1);
814  CHECK (nts1 != rec1); CHECK (rec1 != nts1);
815  CHECK (nts1 != rec2); CHECK (rec2 != nts1);
816  CHECK (nts1 != ref1); CHECK (ref1 != nts1);
817  CHECK (nts1 != ref2); CHECK (ref2 != nts1);
818 
819  CHECK (nts2 != nh1 ); CHECK (nh1 != nts2);
820  CHECK (nts2 != nh2 ); CHECK (nh2 != nts2);
821  CHECK (nts2 != rec1); CHECK (rec1 != nts2);
822  CHECK (nts2 != rec2); CHECK (rec2 != nts2);
823  CHECK (nts2 != ref1); CHECK (ref1 != nts2);
824  CHECK (nts2 != ref2); CHECK (ref2 != nts2);
825 
826  CHECK (nh1 != nh2 ); CHECK (nh2 != nh1);
827  CHECK (nh1 != rec1); CHECK (rec1 != nh1);
828  CHECK (nh1 != rec2); CHECK (rec2 != nh1);
829  CHECK (nh1 != ref1); CHECK (ref1 != nh1);
830  CHECK (nh1 != ref2); CHECK (ref2 != nh1);
831 
832  CHECK (nh2 != rec1); CHECK (rec1 != nh2);
833  CHECK (nh2 != rec2); CHECK (rec2 != nh2);
834  CHECK (nh2 != ref1); CHECK (ref1 != nh2);
835  CHECK (nh2 != ref2); CHECK (ref2 != nh2);
836 
837  CHECK (rec1 != rec2); CHECK (rec2 != rec1);
838  CHECK (ref1 != ref2); CHECK (ref2 != ref1);
839 
840  // NOTE: special handling for record references…
841  CHECK (rec1 == ref1); CHECK (ref1 == rec1);
842  CHECK (rec1 != ref2); CHECK (ref2 != rec1);
843 
844  CHECK (rec2 != ref1); CHECK (ref1 != rec2);
845  CHECK (rec2 == ref2); CHECK (ref2 == rec2);
846 
847 
848 
849  /* ----- equivalence match ----- */
850 
851  // equivalence as object // equivalence on ID match // contained value equality
852  CHECK (ni1 .matches(ni1 )); CHECK (ni1 .matches(ni1 .idi)); CHECK (ni1 .matches(i1 ));
853  CHECK (ni2 .matches(ni2 )); CHECK (ni2 .matches(ni2 .idi)); CHECK (ni2 .matches(i2 ));
854  CHECK (nl1 .matches(nl1 )); CHECK (nl1 .matches(nl1 .idi)); CHECK (nl1 .matches(l1 ));
855  CHECK (nl2 .matches(nl2 )); CHECK (nl2 .matches(nl2 .idi)); CHECK (nl2 .matches(l2 ));
856  CHECK (nr1 .matches(nr1 )); CHECK (nr1 .matches(nr1 .idi)); CHECK (nr1 .matches(r1 ));
857  CHECK (nr2 .matches(nr2 )); CHECK (nr2 .matches(nr2 .idi)); CHECK (nr2 .matches(r2 ));
858  CHECK (nd1 .matches(nd1 )); CHECK (nd1 .matches(nd1 .idi)); CHECK (nd1 .matches(d1 ));
859  CHECK (nd2 .matches(nd2 )); CHECK (nd2 .matches(nd2 .idi)); CHECK (nd2 .matches(d2 ));
860  CHECK (nc1 .matches(nc1 )); CHECK (nc1 .matches(nc1 .idi)); CHECK (nc1 .matches(c1 ));
861  CHECK (nc2 .matches(nc2 )); CHECK (nc2 .matches(nc2 .idi)); CHECK (nc2 .matches(c2 ));
862  CHECK (nb1 .matches(nb1 )); CHECK (nb1 .matches(nb1 .idi)); CHECK (nb1 .matches(b1 ));
863  CHECK (nb2 .matches(nb2 )); CHECK (nb2 .matches(nb2 .idi)); CHECK (nb2 .matches(b2 ));
864  CHECK (ns1 .matches(ns1 )); CHECK (ns1 .matches(ns1 .idi)); CHECK (ns1 .matches(s1 ));
865  CHECK (ns2 .matches(ns2 )); CHECK (ns2 .matches(ns2 .idi)); CHECK (ns2 .matches(s2 ));
866  CHECK (nt1 .matches(nt1 )); CHECK (nt1 .matches(nt1 .idi)); CHECK (nt1 .matches(t1 ));
867  CHECK (nt2 .matches(nt2 )); CHECK (nt2 .matches(nt2 .idi)); CHECK (nt2 .matches(t2 ));
868  CHECK (nto1.matches(nto1)); CHECK (nto1.matches(nto1.idi)); CHECK (nto1.matches(to1));
869  CHECK (nto2.matches(nto2)); CHECK (nto2.matches(nto2.idi)); CHECK (nto2.matches(to2));
870  CHECK (ntd1.matches(ntd1)); CHECK (ntd1.matches(ntd1.idi)); CHECK (ntd1.matches(td1));
871  CHECK (ntd2.matches(ntd2)); CHECK (ntd2.matches(ntd2.idi)); CHECK (ntd2.matches(td2));
872  CHECK (nts1.matches(nts1)); CHECK (nts1.matches(nts1.idi)); CHECK (nts1.matches(ts1));
873  CHECK (nts2.matches(nts2)); CHECK (nts2.matches(nts2.idi)); CHECK (nts2.matches(ts2));
874  CHECK (nh1 .matches(nh1 )); CHECK (nh1 .matches(nh1 .idi)); CHECK (nh1 .matches(h1 ));
875  CHECK (nh2 .matches(nh2 )); CHECK (nh2 .matches(nh2 .idi)); CHECK (nh2 .matches(h2 ));
876  CHECK (rec1.matches(rec1)); CHECK (rec1.matches(rec1.idi)); CHECK (rec1.matches(spam1));
877  CHECK (rec2.matches(rec2)); CHECK (rec2.matches(rec2.idi)); CHECK (rec2.matches(spam2));
878  CHECK (ref1.matches(ref1)); CHECK (ref1.matches(ref1.idi)); CHECK (ref1.matches(recRef1));
879  CHECK (ref2.matches(ref2)); CHECK (ref2.matches(ref2.idi)); CHECK (ref2.matches(recRef2));
880 
881  // cross-match on equivalent payload data --------
882  CHECK (nl1.matches(i1)); CHECK (nr1.matches(i1)); CHECK (nd1.matches(i1)); CHECK (nc1.matches(i1));
883  CHECK (ni1.matches(l1)); CHECK (nr1.matches(l1)); CHECK (nd1.matches(l1)); CHECK (nc1.matches(l1));
884  CHECK (ni1.matches(r1)); CHECK (nl1.matches(r1)); CHECK (nd1.matches(r1)); CHECK (nc1.matches(r1));
885  CHECK (ni1.matches(d1)); CHECK (nl1.matches(d1)); CHECK (nr1.matches(d1)); CHECK (nc1.matches(d1));
886  CHECK (ni1.matches(c1)); CHECK (nl1.matches(c1)); CHECK (nr1.matches(c1)); CHECK (nd1.matches(c1));
887 
888  CHECK (nl2.matches(i2)); CHECK (nr2.matches(i2)); CHECK (nd2.matches(i2)); CHECK (nc2.matches(i2));
889  CHECK (ni2.matches(l2)); CHECK (nr2.matches(l2)); CHECK (nd2.matches(l2)); CHECK (nc2.matches(l2));
890  CHECK (ni2.matches(r2)); CHECK (nl2.matches(r2)); CHECK (nd2.matches(r2)); CHECK (nc2.matches(r2));
891  CHECK (ni2.matches(d2)); CHECK (nl2.matches(d2)); CHECK (nr2.matches(d2)); CHECK (nc2.matches(d2));
892  CHECK (ni2.matches(c2)); CHECK (nl2.matches(c2)); CHECK (nr2.matches(c2)); CHECK (nd2.matches(c2));
893 
894  CHECK (nto1.matches(t1 )); CHECK (nts1.matches(t1 ));
895  CHECK (nt1.matches(to1)); CHECK (nts1.matches(to1));
896  CHECK (nt1.matches(ts1)); CHECK (nto1.matches(ts1));
897 
898  CHECK (nto2.matches(t2 )); CHECK (nts2.matches(t2 ));
899  CHECK (nt2.matches(to2)); CHECK (nts2.matches(to2));
900  CHECK (nt2.matches(ts2)); CHECK (nto2.matches(ts2));
901 
902  CHECK (ns1.matches(""));
903  CHECK (ns2.matches("↯"));
904  CHECK (nc1.matches("@"));
905  CHECK (nc2.matches("~"));
906 
907  // match due to references sharing the target's ID
908  CHECK (rec1.matches(ref1.idi));
909  CHECK (ref1.matches(rec1.idi));
910  CHECK (rec2.matches(ref2.idi));
911  CHECK (ref2.matches(rec2.idi));
912 
913  // some negative cases...
914  CHECK (!ni1.matches(i2)); CHECK (!ni2.matches(i1));
915  CHECK (!ni1.matches(l2)); CHECK (!ni2.matches(l1));
916  CHECK (!ni1.matches(r2)); CHECK (!ni2.matches(r1));
917  CHECK (!ni1.matches(d2)); CHECK (!ni2.matches(d1));
918  CHECK (!ni1.matches(c2)); CHECK (!ni2.matches(c1));
919 
920  CHECK (!nd1.matches(i2)); CHECK (!nd2.matches(i1));
921  CHECK (!nd1.matches(l2)); CHECK (!nd2.matches(l1));
922  CHECK (!nd1.matches(r2)); CHECK (!nd2.matches(r1));
923  CHECK (!nd1.matches(d2)); CHECK (!nd2.matches(d1));
924  CHECK (!nd1.matches(c2)); CHECK (!nd2.matches(c1));
925 
926  // string match is literal
927  CHECK (!ns1.matches(" "));
928  CHECK (!ns2.matches("↯ "));
929 
930  GenNode copy(ni1);
931  CHECK (copy == ni1);
932 
933  copy.data = 2*i1;
934  CHECK (copy != ni1);
935  CHECK (copy.idi == ni1.idi);
936  CHECK (not copy.data.matchData(ni1.data));
937 
938  // NOTE: "match" operation is shallow on records
939  CHECK (copy.matches(ni1)); CHECK (ni1.matches(copy));
940  }
941  };
942 
943 
945  LAUNCHER (GenNodeBasic_test, "unit common");
946 
947 
948 
949 }}} // namespace lib::diff::test
Access child(size_t idx) const
Definition: record.hpp:253
Rec::Mutator MakeRec
Definition: gen-node.hpp:135
Record< GenNode > Rec
Definition: gen-node.hpp:133
bool almostEqual(double d1, double d2, unsigned int ulp=2)
epsilon comparison of doubles.
Definition: util-quant.hpp:143
Automatically use custom string conversion in C++ stream output.
Constructor for a specially crafted 'ref GenNode'.
Definition: gen-node.hpp:732
string getType() const
Definition: record.hpp:225
bool isNamed() const
Definition: gen-node.hpp:322
int data
Definition: test-priqueue.c:84
Definition: run.hpp:49
Mutator & scope(X const &initialiser, ARGS &&...args)
Definition: record.hpp:572
static const Ref CHILD
symbolic ID ref "_CHILD_"
Definition: gen-node.hpp:756
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify a statement indeed raises an exception.
Implementation namespace for support and library code.
string const & getSym() const
Definition: entry-id.hpp:165
Lumiera's internal time value datatype.
Definition: timevalue.hpp:226
bool isSameObject(A const &a, B const &b)
compare plain object identity, bypassing any custom comparison operators.
Definition: util.hpp:337
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
Definition: util.hpp:205
std::vector< string > & Arg
Definition: run.hpp:54
Special collection to represent object-like data.
static const Ref END
symbolic ID ref "_END_"
Definition: gen-node.hpp:754
LAUNCHER(DiffComplexApplication_test,"unit common")
Register this test class...
boost::rational< long > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:205
#define LERR_(_NAME_)
Definition: error.hpp:58
bool matches(Binding const &b1, Binding const &b2)
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
wrapped record reference.
Definition: record.hpp:611
Utilities for quantisation (grid alignment) and comparisons.
Generic building block for tree shaped (meta)data structures.
A collection of frequently used helper functions to support unit testing.
bool isnil(lib::time::Duration const &dur)
Definition: timevalue.hpp:642
bool matches(GenNode const &o) const
Definition: gen-node.hpp:337
friend class Mutator
Definition: record.hpp:298
Mutator & type(string const &typeID)
Definition: record.hpp:449
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor...
static const Ref ATTRIBS
symbolic ID ref "_ATTRIBS_"
Definition: gen-node.hpp:757
Offset measures a distance in time.
Definition: timevalue.hpp:283
Access get(string key) const
Definition: record.hpp:243
Duration is the internal Lumiera time metric.
Definition: timevalue.hpp:380
static const string TYPE_NIL
Definition: record.hpp:155
A time interval anchored at a specific point in time.
Definition: timevalue.hpp:467
lib::time::Time randTime()
create a random but not insane Time value
a family of time value like entities and their relationships.
object-like record of data.
Definition: record.hpp:143
static const Ref THIS
symbolic ID ref "_THIS_"
Definition: gen-node.hpp:755
LuidH const & getHash() const
Definition: entry-id.hpp:171
Mutator & attrib(string const &key, X &&initialiser, ARGS &&...args)
Definition: record.hpp:563
Time end() const
Definition: timevalue.hpp:518
generic data element node within a tree
Definition: gen-node.hpp:213