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