source: tests/list/dlist-insert-remove.cfa @ 1f11818

Last change on this file since 1f11818 was 55b060d, checked in by Peter A. Buhr <pabuhr@…>, 15 months ago

rename directories containers to collections

  • Property mode set to 100644
File size: 49.5 KB
Line 
1#include <collections/list.hfa>
2#include <fstream.hfa>
3#include <assert.h>
4
5// Section 1:  replaced by above include list.hfa
6
7
8////////////////////////////////////////////////////////////
9//
10// Section 2
11//
12// Structure definitions
13//
14// Example of declaration-side user code
15//
16////////////////////////////////////////////////////////////
17
18// a fred belongs to two doubly-linked lists: mine and yours
19struct fred {
20        float adatum;
21        inline struct mine { inline dlink(fred); };
22        inline struct yours { inline dlink(fred); };
23};
24P9_EMBEDDED(fred, fred.mine)
25P9_EMBEDDED(fred, fred.yours)
26P9_EMBEDDED(fred.mine, dlink(fred))
27P9_EMBEDDED(fred.yours, dlink(fred))
28
29
30void ?{}(fred &this, float adatum) {
31        (this.adatum){adatum};
32}
33
34// a mary belongs to just one doubly-linked list: hers
35struct mary {
36        float anotherdatum;
37        inline dlink(mary);
38};
39
40P9_EMBEDDED(mary, dlink(mary))
41
42void ?{}(mary &this, float anotherdatum) {
43        (this.anotherdatum){anotherdatum};
44}
45
46////////////////////////////////////////////////////////////
47//
48// Section 3
49//
50// Test helpers to traverse and print lists.
51//
52// These consume framework-provided accessor functions and
53// do not modify their parameter lists.
54//
55////////////////////////////////////////////////////////////
56
57void printMyFredsFwd(fred & f) {
58    with( DLINK_VIA( fred, fred.mine ) )
59        do {
60                sout | f.adatum;
61        } while (f`moveNext);
62}
63
64void printMyFredsRev(fred & f) {
65    with( DLINK_VIA( fred, fred.mine ) )
66        do {
67                sout | f.adatum;
68        } while (f`movePrev);
69}
70
71
72void printMyFreddies(fred &f1, fred &f2, int isBefore) {
73        if (isBefore) {
74                sout | "==== fred by MINE before ";
75        } else {
76                sout | "==== fred by MINE after ";
77        }
78        if (&f1) {
79                printMyFredsFwd(f1);    sout | '-';
80                printMyFredsRev(f1);    sout | '-';
81        } else {
82                sout | '-'; sout | '-';
83        }
84        if (&f2) {
85                printMyFredsFwd(f2);    sout | '-';
86                printMyFredsRev(f2);    sout | '-';
87        } else {
88                sout | '-'; sout | '-';
89        }
90}
91
92void printYourFredsFwd(fred & f) {
93    with( DLINK_VIA( fred, fred.yours ) )
94        do {
95                sout | f.adatum;
96        } while (f`moveNext);
97}
98
99void printYourFredsRev(fred & f) {
100    with( DLINK_VIA( fred, fred.yours ) )
101        do {
102                sout | f.adatum;
103        } while (f`movePrev);
104}
105
106void printYourFreddies(fred &f1, fred &f2, int isBefore) {
107        if (isBefore) {
108                sout | "==== fred by YOURS before ";
109        } else {
110                sout | "==== fred by YOURS after ";
111        }
112        if (&f1) {
113                printYourFredsFwd(f1);  sout | '-';
114                printYourFredsRev(f1);  sout | '-';
115        } else {
116                sout | '-'; sout | '-';
117        }
118        if (&f2) {
119                printYourFredsFwd(f2);  sout | '-';
120                printYourFredsRev(f2);  sout | '-';
121        } else {
122                sout | '-'; sout | '-';
123        }
124}
125
126void printMariesFwd(mary &m) {
127        do {
128                sout | m.anotherdatum;
129        } while (m`moveNext);
130}
131
132void printMariesRev(mary &m) {
133        do {
134                sout | m.anotherdatum;
135        } while (m`movePrev);
136}
137
138void printMariatheotokos(mary &m1, mary &m2, int isBefore) {
139        if (isBefore) {
140                sout | "==== mary before ";
141        } else {
142                sout | "==== mary after ";
143        }
144        if (&m1) {
145                printMariesFwd(m1);     sout | '-';
146                printMariesRev(m1);     sout | '-';
147        } else {
148                sout | '-'; sout | '-';
149        }
150        if (&m2) {
151                printMariesFwd(m2);     sout | '-';
152                printMariesRev(m2);     sout | '-';
153        } else {
154                sout | '-'; sout | '-';
155        }
156}
157
158////////////////////////////////////////////////////////////
159//
160// Section 4a.i
161//
162// Test cases of insert_after on headless list
163//
164// Example of call-side user code
165//
166////////////////////////////////////////////////////////////
167
168// All three tests exercise the case of merging two singleton lists into (their respective
169// positions in) one common list of two elements.
170
171// Note that the factoring of sect 4 (vs 3 and 5) keeps section 4 free of strings and IO,
172// and so keeps its assembly easy to inspect.
173
174// Throughout all the 4s, all the print functions called from these tests print:
175//  - from list position #1 moving forward  (a)
176//  - from list position #1 moving backward (b)
177//  - from list position #2 moving forward  (c)
178//  - from list position #2 moving backward (d)
179// The expected-output comments are in form a;b;c;d where a::=num,num,num
180#if 0
181void test__insertafter_singleton_on_singleton__fred_mine () {
182        fred f1 = {3.14};
183        fred f2 = {0.5};
184
185        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
186        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
187
188        diref(fred, fred.mine) f1_mine = f1`from;
189        insert_after(f1_mine, f2);
190
191        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
192        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
193}
194
195void test__insertafter_singleton_on_singleton__fred_yours () {
196        fred f1 = {3.14};
197        fred f2 = {0.5};
198
199        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
200        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
201
202        diref(fred, fred.yours) f1_yours = f1`from;
203        insert_after(f1_yours, f2);
204
205        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
206        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
207}
208
209void test__insertafter_singleton_on_singleton__mary () {
210        mary m1 = {3.14};
211        mary m2 = {0.5};
212
213        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
214
215        insert_after(m1, m2);
216
217        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
218}
219
220////////////////////////////////////////////////////////////
221//
222// Section 4a.ii
223//
224// Test cases of insert_before on headless list
225//
226// Example of call-side user code
227//
228////////////////////////////////////////////////////////////
229
230void test__insertbefore_singleton_on_singleton__fred_mine () {
231        fred f1 = {3.14};
232        fred f2 = {0.5};
233
234        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
235        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
236
237        diref(fred, fred.mine) f2_mine = f2`from;
238        insert_before(f2_mine, f1);
239
240        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
241        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
242}
243
244void test__insertbefore_singleton_on_singleton__fred_yours () {
245        fred f1 = {3.14};
246        fred f2 = {0.5};
247
248        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
249        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
250
251        diref(fred, fred.yours) f2_yours = f2`from;
252        insert_before(f2_yours, f1);
253
254        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
255        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
256}
257
258void test__insertbefore_singleton_on_singleton__mary () {
259        mary m1 = {3.14};
260        mary m2 = {0.5};
261
262        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
263
264        insert_before(m2, m1);
265
266        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
267}
268#endif
269////////////////////////////////////////////////////////////
270//
271// Section 4b.i
272//
273// Test cases of insert_first (necessarily headed list)
274//
275// Example of call-side user code
276//
277////////////////////////////////////////////////////////////
278
279// All three tests exercise the case of creating an empty container and
280// adding two items to it.
281void test__insertfirst_two_on_empty__fred_mine() {
282
283        fred f1 = {3.14};
284        fred f2 = {0.5};
285
286        dlist(fred, fred.mine) lf;
287
288        verify(validate(lf));
289
290        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
291        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
292
293        insert_first(lf, f2);
294        insert_first(lf, f1);
295
296        verify(validate(lf));
297
298        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
299        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
300}
301
302void test__insertfirst_two_on_empty__fred_yours() {
303
304        fred f1 = {3.14};
305        fred f2 = {0.5};
306
307        dlist(fred, fred.yours) lf;
308
309        verify(validate(lf));
310
311        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
312        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
313
314        insert_first(lf, f2);
315        insert_first(lf, f1);
316
317        verify(validate(lf));
318
319        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
320        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
321}
322void test__insertfirst_two_on_empty__mary() {
323
324        mary m1 = {3.14};
325        mary m2 = {0.5};
326
327        dlist(mary) lm;
328
329        verify(validate(lm));
330        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
331
332        insert_first(lm, m2);
333        insert_first(lm, m1);
334
335        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
336        verify(validate(lm));
337}
338
339////////////////////////////////////////////////////////////
340//
341// Section 4b.ii
342//
343// Test cases of insert_last (necessarily headed list)
344//
345// Example of call-side user code
346//
347////////////////////////////////////////////////////////////
348
349void test__insertlast_two_on_empty__fred_mine() {
350
351        fred f1 = {3.14};
352        fred f2 = {0.5};
353
354        dlist(fred, fred.mine) lf;
355
356        verify(validate(lf));
357
358        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
359        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
360
361        insert_last(lf, f1);
362        insert_last(lf, f2);
363
364        verify(validate(lf));
365
366        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
367        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
368}
369
370void test__insertlast_two_on_empty__fred_yours() {
371
372        fred f1 = {3.14};
373        fred f2 = {0.5};
374
375        dlist(fred, fred.yours) lf;
376
377        verify(validate(lf));
378
379        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
380        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
381
382        insert_last(lf, f1);
383        insert_last(lf, f2);
384
385        verify(validate(lf));
386
387        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
388        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
389}
390
391void test__insertlast_two_on_empty__mary() {
392
393        mary m1 = {3.14};
394        mary m2 = {0.5};
395
396        dlist(mary) lm;
397
398        verify(validate(lm));
399        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
400
401        insert_last(lm, m1);
402        insert_last(lm, m2);
403
404        verify(validate(lm));
405        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
406}
407
408////////////////////////////////////////////////////////////
409//
410// Section 4c.i
411//
412// Test cases of insert_after on headed list
413//
414// Example of call-side user code
415//
416////////////////////////////////////////////////////////////
417
418void test__insertafter_after_last__fred_mine() {
419
420        fred f1 = {3.14};
421        fred f2 = {0.5};
422
423        dlist(fred, fred.mine) lf;
424
425        assert( & lf`first == 0p );
426        assert( & lf`last == 0p );
427
428        insert_first(lf, f1);
429
430        assert( & lf`first == & f1 );
431        assert( & lf`last  == & f1 );
432
433        verify(validate(lf));
434
435        with ( DLINK_VIA(fred, fred.mine) ) insert_after(f1, f2);
436
437        verify(validate(lf));
438
439        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
440        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
441
442        assert( & lf`first == & f1 );
443        assert( & lf`last  == & f2 );
444}
445
446void test__insertafter_after_last__fred_yours() {
447
448        fred f1 = {3.14};
449        fred f2 = {0.5};
450
451        dlist(fred, fred.yours) lf;
452
453        assert( & lf`first == 0p );
454        assert( & lf`last == 0p );
455
456        insert_first(lf, f1);
457
458        assert( & lf`first == & f1 );
459        assert( & lf`last  == & f1 );
460
461        verify(validate(lf));
462
463    with ( DLINK_VIA(fred, fred.yours) ) insert_after(f1, f2);
464
465        verify(validate(lf));
466
467        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
468        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
469
470        assert( & lf`first == & f1 );
471        assert( & lf`last  == & f2 );
472}
473
474void test__insertafter_after_last__mary() {
475
476        mary m1 = {3.14};
477        mary m2 = {0.5};
478
479        dlist(mary) lm;
480
481        assert( & lm`first == 0p );
482        assert( & lm`last == 0p );
483
484        insert_first(lm, m1);
485
486        assert( & lm`first == & m1 );
487        assert( & lm`last  == & m1 );
488
489        verify(validate(lm));
490
491        insert_after(m1, m2);
492
493        verify(validate(lm));
494
495        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
496
497        assert( & lm`first == & m1 );
498        assert( & lm`last  == & m2 );
499}
500
501////////////////////////////////////////////////////////////
502//
503// Section 4c.ii
504//
505// Test cases of insert_before on headed list
506//
507// Example of call-side user code
508//
509////////////////////////////////////////////////////////////
510
511void test__insertbefore_before_first__fred_mine() {
512
513        fred f1 = {3.14};
514        fred f2 = {0.5};
515
516        dlist(fred, fred.mine) lf;
517
518        assert( & lf`first == 0p );
519        assert( & lf`last == 0p );
520
521        insert_last(lf, f2);
522
523        assert( & lf`first == & f2 );
524        assert( & lf`last  == & f2 );
525
526        verify(validate(lf));
527
528        with ( DLINK_VIA(fred, fred.mine) ) insert_before(f2, f1);
529
530        verify(validate(lf));
531
532        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
533        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
534
535        assert( & lf`first == & f1 );
536        assert( & lf`last  == & f2 );
537}
538
539void test__insertbefore_before_first__fred_yours() {
540
541        fred f1 = {3.14};
542        fred f2 = {0.5};
543
544        dlist(fred, fred.yours) lf;
545
546        assert( & lf`first == 0p );
547        assert( & lf`last == 0p );
548
549        insert_last(lf, f2);
550
551        assert( & lf`first == & f2 );
552        assert( & lf`last  == & f2 );
553
554        verify(validate(lf));
555
556        with ( DLINK_VIA(fred, fred.yours) )insert_before(f2, f1);
557
558        verify(validate(lf));
559
560        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
561        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
562
563        assert( & lf`first == & f1 );
564        assert( & lf`last  == & f2 );
565}
566
567void test__insertbefore_before_first__mary() {
568
569        mary m1 = {3.14};
570        mary m2 = {0.5};
571
572        dlist(mary) lm;
573
574        assert( & lm`first == 0p );
575        assert( & lm`last == 0p );
576
577        insert_last(lm, m2);
578
579        assert( & lm`first == & m2 );
580        assert( & lm`last  == & m2 );
581
582        verify(validate(lm));
583
584        insert_before(m2, m1);
585
586        verify(validate(lm));
587
588        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
589
590        assert( & lm`first == & m1 );
591        assert( & lm`last  == & m2 );
592}
593#if 0
594
595////////////////////////////////////////////////////////////
596//
597// Section 4d.i
598//
599// Test cases of remove, from middle of headless list
600//
601// Example of call-side user code
602//
603////////////////////////////////////////////////////////////
604
605// These tests, in the fred cases, set up the my/your lists initially identical,
606// act on one list, and expect the other unaffected.
607
608void test__remove_mid__fred_mine() {
609
610        fred f1 = {1.7};
611        fred f2 = {2.7};
612        fred f3 = {3.7};
613
614        insert_after(f1`in_mine, f2);
615        insert_after(f2`in_mine, f3);
616
617        insert_after(f1`in_yours, f2);
618        insert_after(f2`in_yours, f3);
619
620        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
621        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
622
623        remove(f2`in_mine);
624
625        printMyFreddies(f1, f3, 0);     // 1.7, 3.7;       1.7;  3.7;  3.7, 1.7      (modified)
626        printYourFreddies(f1, f3, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
627
628        // observe f2 is now solo in mine; in yours, it was just traversed
629        printMyFreddies(f2, *0p, 0);    // 2.7; 2.7; ;
630
631        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
632        assert(f2.$links_mine.next.is_terminator == false);
633        assert(f2.$links_mine.prev.is_terminator == false);
634}
635
636void test__remove_mid__fred_yours() {
637
638        fred f1 = {1.7};
639        fred f2 = {2.7};
640        fred f3 = {3.7};
641
642        insert_after(f1`in_mine, f2);
643        insert_after(f2`in_mine, f3);
644
645        insert_after(f1`in_yours, f2);
646        insert_after(f2`in_yours, f3);
647
648        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
649        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
650
651        remove(f2`in_yours);
652
653        printMyFreddies(f1, f3, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
654        printYourFreddies(f1, f3, 0);   // 1.7, 3.7;       1.7;  3.7;  3.7, 1.7      (modified)
655
656        // observe f2 is now solo in yours; in mine, it was just traversed
657        printYourFreddies(f2, *0p, 0);    // 2.7; 2.7; ;
658
659        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
660        assert(f2.$links_yours.next.is_terminator == false);
661        assert(f2.$links_yours.prev.is_terminator == false);
662}
663
664void test__remove_mid__mary() {
665
666        mary m1 = {1.7};
667        mary m2 = {2.7};
668        mary m3 = {3.7};
669
670        insert_after(m1, m2);
671        insert_after(m2, m3);
672
673        printMariatheotokos(m1, m3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
674
675        remove(m2);
676
677        printMariatheotokos(m1, m3, 0);     // 1.7, 3.7;  1.7;  3.7;  3.7, 1.7 (modified)
678
679        // observe m2 is now solo
680        printMariatheotokos(m2, *0p, 0);    // 2.7; 2.7; ;
681
682        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
683        assert(m2.$links.next.is_terminator == false);
684        assert(m2.$links.prev.is_terminator == false);
685}
686
687////////////////////////////////////////////////////////////
688//
689// Section 4d.ii
690//
691// Test cases of remove, from first position of headless list
692//
693// Example of call-side user code
694//
695////////////////////////////////////////////////////////////
696
697// TODO: validate headless semantic: remove of a neighbourless element is valid and no-op
698
699void test__remove_at_first__fred_mine() {
700
701        fred f1 = {1.7};
702        fred f2 = {2.7};
703        fred f3 = {3.7};
704
705        insert_after(f1`in_mine, f2);
706        insert_after(f2`in_mine, f3);
707
708        insert_after(f1`in_yours, f2);
709        insert_after(f2`in_yours, f3);
710
711        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
712        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
713
714        remove(f1`in_mine);
715
716        printMyFreddies(f2, f3, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
717        printYourFreddies(f1, f3, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
718
719        // observe f1 is now solo in mine; in yours, it was just traversed
720        printMyFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
721
722        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
723        assert(f1.$links_mine.next.is_terminator == false);
724        assert(f1.$links_mine.prev.is_terminator == false);
725}
726
727void test__remove_at_first__fred_yours() {
728
729        fred f1 = {1.7};
730        fred f2 = {2.7};
731        fred f3 = {3.7};
732
733        insert_after(f1`in_mine, f2);
734        insert_after(f2`in_mine, f3);
735
736        insert_after(f1`in_yours, f2);
737        insert_after(f2`in_yours, f3);
738
739        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
740        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
741
742        remove(f1`in_yours);
743
744        printMyFreddies(f1, f3, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
745        printYourFreddies(f2, f3, 0);   // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
746
747        // observe f1 is now solo in yours; in mine, it was just traversed
748        printYourFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
749
750        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
751        assert(f1.$links_yours.next.is_terminator == false);
752        assert(f1.$links_yours.prev.is_terminator == false);
753}
754
755void test__remove_at_first__mary() {
756
757        mary m1 = {1.7};
758        mary m2 = {2.7};
759        mary m3 = {3.7};
760
761        insert_after(m1, m2);
762        insert_after(m2, m3);
763
764        printMariatheotokos(m1, m3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
765
766        remove(m1);
767
768        printMariatheotokos(m2, m3, 0);     // 2.7, 3.7;  2.7;  3.7;  3.7, 2.7 (modified)
769
770        // observe m2 is now solo
771        printMariatheotokos(m1, *0p, 0);    // 1.7; 1.7; ;
772
773        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
774        assert(m1.$links.next.is_terminator == false);
775        assert(m1.$links.prev.is_terminator == false);
776}
777
778////////////////////////////////////////////////////////////
779//
780// Section 4d.iii
781//
782// Test cases of remove, from last position of headless list
783//
784// Example of call-side user code
785//
786////////////////////////////////////////////////////////////
787
788void test__remove_at_last__fred_mine() {
789
790        fred f1 = {1.7};
791        fred f2 = {2.7};
792        fred f3 = {3.7};
793
794        insert_after(f1`in_mine, f2);
795        insert_after(f2`in_mine, f3);
796
797        insert_after(f1`in_yours, f2);
798        insert_after(f2`in_yours, f3);
799
800        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
801        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
802
803        remove(f3`in_mine);
804
805        printMyFreddies(f1, f2, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
806        printYourFreddies(f1, f3, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
807
808        // observe f3 is now solo in mine; in yours, it was just traversed
809        printMyFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
810
811        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
812        assert(f3.$links_mine.next.is_terminator == false);
813        assert(f3.$links_mine.prev.is_terminator == false);
814}
815
816void test__remove_at_last__fred_yours() {
817
818        fred f1 = {1.7};
819        fred f2 = {2.7};
820        fred f3 = {3.7};
821
822        insert_after(f1`in_mine, f2);
823        insert_after(f2`in_mine, f3);
824
825        insert_after(f1`in_yours, f2);
826        insert_after(f2`in_yours, f3);
827
828        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
829        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
830
831        remove(f3`in_yours);
832
833        printMyFreddies(f1, f3, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
834        printYourFreddies(f1, f2, 0);   // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
835
836        // observe f3 is now solo in yours; in mine, it was just traversed
837        printYourFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
838
839        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
840        assert(f3.$links_yours.next.is_terminator == false);
841        assert(f3.$links_yours.prev.is_terminator == false);
842}
843
844void test__remove_at_last__mary() {
845
846        mary m1 = {1.7};
847        mary m2 = {2.7};
848        mary m3 = {3.7};
849
850        insert_after(m1, m2);
851        insert_after(m2, m3);
852
853        printMariatheotokos(m1, m3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
854
855        remove(m3);
856
857        printMariatheotokos(m1, m2, 0);     // 1.7, 2.7;  1.7;  2.7;  2.7, 1.7 (modified)
858
859        // observe m3 is now solo
860        printMariatheotokos(m3, *0p, 0);    // 3.7; 3.7; ;
861
862        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
863        assert(m1.$links.next.is_terminator == false);
864        assert(m1.$links.prev.is_terminator == false);
865}
866
867////////////////////////////////////////////////////////////
868//
869// Section 4e.i
870//
871// Test cases of remove, from first position of headed list
872//
873// Example of call-side user code
874//
875////////////////////////////////////////////////////////////
876#endif
877void test__remove_at_head__fred_mine() {
878
879        fred f1 = {1.7};
880        fred f2 = {2.7};
881        fred f3 = {3.7};
882
883        dlist(fred, fred.mine) flm;
884        insert_last(flm, f1);
885        insert_last(flm, f2);
886        insert_last(flm, f3);
887
888        dlist(fred, fred.yours) fly;
889        insert_last(fly, f1);
890        insert_last(fly, f2);
891        insert_last(fly, f3);
892
893        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
894        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
895
896        verify(validate(fly));
897        verify(validate(flm));
898
899        with( DLINK_VIA(fred, fred.mine) ) remove(f1);
900
901        verify(validate(fly));
902        verify(validate(flm));
903
904        printMyFreddies(flm`first, flm`last, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
905        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
906
907        // observe f1 is now solo in mine; in yours, it was just traversed
908        printMyFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
909
910        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
911        // assert(f1.$links_mine.next.is_terminator == false);
912        // assert(f1.$links_mine.prev.is_terminator == false);
913}
914
915
916void test__remove_at_head__fred_yours() {
917
918        fred f1 = {1.7};
919        fred f2 = {2.7};
920        fred f3 = {3.7};
921
922        dlist(fred, fred.mine) flm;
923        insert_last(flm, f1);
924        insert_last(flm, f2);
925        insert_last(flm, f3);
926
927        dlist(fred, fred.yours) fly;
928        insert_last(fly, f1);
929        insert_last(fly, f2);
930        insert_last(fly, f3);
931
932        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
933        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
934
935        verify(validate(fly));
936        verify(validate(flm));
937
938        with( DLINK_VIA(fred, fred.yours) ) remove(f1);
939
940        verify(validate(fly));
941        verify(validate(flm));
942
943        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
944        printYourFreddies(fly`first, fly`last, 0);   // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
945
946        // observe f1 is now solo in yours; in mine, it was just traversed
947        printYourFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
948
949        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
950        // assert(f1.$links_yours.next.is_terminator == false);
951        // assert(f1.$links_yours.prev.is_terminator == false);
952}
953
954void test__remove_at_head__mary() {
955
956        mary m1 = {1.7};
957        mary m2 = {2.7};
958        mary m3 = {3.7};
959
960        dlist(mary) ml;
961        insert_last(ml, m1);
962        insert_last(ml, m2);
963        insert_last(ml, m3);
964
965        printMariatheotokos(ml`first, ml`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
966
967        verify(validate(ml));
968
969        remove(m1);
970
971        verify(validate(ml));
972
973        printMariatheotokos(ml`first, ml`last, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
974
975        // observe m1 is now solo
976        printMariatheotokos(m1, *0p, 0);               // 1.7; 1.7; ;
977
978        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
979        // assert(m1.$links.next.is_terminator == false);
980        // assert(m1.$links.prev.is_terminator == false);
981}
982
983////////////////////////////////////////////////////////////
984//
985// Section 4e.ii
986//
987// Test cases of remove, from last position of headed list
988//
989// Example of call-side user code
990//
991////////////////////////////////////////////////////////////
992
993void test__remove_at_tail__fred_mine() {
994
995        fred f1 = {1.7};
996        fred f2 = {2.7};
997        fred f3 = {3.7};
998
999        dlist(fred, fred.mine) flm;
1000        insert_last(flm, f1);
1001        insert_last(flm, f2);
1002        insert_last(flm, f3);
1003
1004        dlist(fred, fred.yours) fly;
1005        insert_last(fly, f1);
1006        insert_last(fly, f2);
1007        insert_last(fly, f3);
1008
1009        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1010        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1011
1012        verify(validate(fly));
1013        verify(validate(flm));
1014
1015        with( DLINK_VIA(fred, fred.mine) ) remove(f3);
1016
1017        verify(validate(fly));
1018        verify(validate(flm));
1019
1020        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
1021        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
1022
1023        // observe f3 is now solo in mine; in yours, it was just traversed
1024        printMyFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
1025
1026        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1027        // assert(f3.$links_mine.next.is_terminator == false);
1028        // assert(f3.$links_mine.prev.is_terminator == false);
1029}
1030
1031void test__remove_at_tail__fred_yours() {
1032
1033        fred f1 = {1.7};
1034        fred f2 = {2.7};
1035        fred f3 = {3.7};
1036
1037        dlist(fred, fred.mine) flm;
1038        insert_last(flm, f1);
1039        insert_last(flm, f2);
1040        insert_last(flm, f3);
1041
1042        dlist(fred, fred.yours) fly;
1043        insert_last(fly, f1);
1044        insert_last(fly, f2);
1045        insert_last(fly, f3);
1046
1047        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1048        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1049
1050        verify(validate(fly));
1051        verify(validate(flm));
1052
1053        with( DLINK_VIA(fred, fred.yours) ) remove(f3);
1054
1055        verify(validate(fly));
1056        verify(validate(flm));
1057
1058        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
1059        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
1060
1061        // observe f3 is now solo in yours; in mine, it was just traversed
1062        printYourFreddies(f3, *0p, 0);               // 3.7; 3.7; ;
1063
1064        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1065        // assert(f3.$links_yours.next.is_terminator == false);
1066        // assert(f3.$links_yours.prev.is_terminator == false);
1067}
1068
1069void test__remove_at_tail__mary() {
1070
1071        mary m1 = {1.7};
1072        mary m2 = {2.7};
1073        mary m3 = {3.7};
1074
1075        dlist(mary) ml;
1076        insert_last(ml, m1);
1077        insert_last(ml, m2);
1078        insert_last(ml, m3);
1079
1080        printMariatheotokos(ml`first, ml`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1081
1082        verify(validate(ml));
1083
1084        remove(m3);
1085
1086        verify(validate(ml));
1087
1088        printMariatheotokos(ml`first, ml`last, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
1089
1090        // observe m3 is now solo
1091        printMariatheotokos(m3, *0p, 0);               //3.7; 3.7; ;
1092
1093        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1094        // assert(m3.$links.next.is_terminator == false);
1095        // assert(m3.$links.prev.is_terminator == false);
1096}
1097
1098////////////////////////////////////////////////////////////
1099//
1100// Section 4e.iii
1101//
1102// Test cases of remove, of sole element of headed list
1103//
1104// Example of call-side user code
1105//
1106////////////////////////////////////////////////////////////
1107
1108void test__remove_of_sole__fred_mine() {
1109
1110        fred f = {0.7};
1111
1112        dlist(fred, fred.mine) flm;
1113        insert_last(flm, f);
1114
1115        dlist(fred, fred.yours) fly;
1116        insert_last(fly, f);
1117
1118        printMyFreddies(flm`first, flm`last, 1);     // 0.7; 0.7; 0.7; 0.7
1119        printYourFreddies(fly`first, fly`last, 1);   // 0.7; 0.7; 0.7; 0.7
1120
1121        verify(validate(fly));
1122        verify(validate(flm));
1123
1124        with( DLINK_VIA(fred, fred.mine) ) remove(f);
1125
1126        verify(validate(fly));
1127        verify(validate(flm));
1128
1129        assert( & flm`first == 0p );
1130        assert( & flm`last == 0p );
1131
1132        printYourFreddies(fly`first, fly`last, 0);   // 0.7; 0.7; 0.7; 0.7 (unmodified)
1133
1134        // observe f is solo in mine (now unlisted); in yours, it was just traversed
1135        printMyFreddies(f, *0p, 0);    // 0.7; 0.7; ;
1136
1137        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1138        // assert(f.$links_mine.next.is_terminator == false);
1139        // assert(f.$links_mine.prev.is_terminator == false);
1140
1141        insert_last(flm, f);
1142        verify(validate(fly));
1143        verify(validate(flm));
1144        printMyFreddies(flm`first, flm`last, 0);     // 0.7; 0.7; 0.7; 0.7
1145}
1146
1147void test__remove_of_sole__fred_yours() {
1148
1149        fred f = {0.7};
1150
1151        dlist(fred, fred.mine) flm;
1152        insert_last(flm, f);
1153
1154        dlist(fred, fred.yours) fly;
1155        insert_last(fly, f);
1156
1157        printMyFreddies(flm`first, flm`last, 1);     // 0.7; 0.7; 0.7; 0.7
1158        printYourFreddies(fly`first, fly`last, 1);   // 0.7; 0.7; 0.7; 0.7
1159
1160        verify(validate(fly));
1161        verify(validate(flm));
1162
1163        with( DLINK_VIA(fred, fred.yours) ) remove(f);
1164
1165        verify(validate(fly));
1166        verify(validate(flm));
1167
1168        assert( & fly`first == 0p );
1169        assert( & fly`last == 0p );
1170
1171        printYourFreddies(flm`first, flm`last, 0);   // 0.7; 0.7; 0.7; 0.7 (unmodified)
1172
1173        // observe f is solo in yours (now unlisted); in mine, it was just traversed
1174        printYourFreddies(f, *0p, 0);    // 0.7; 0.7; ;
1175
1176        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1177        // assert(f.$links_yours.next.is_terminator == false);
1178        // assert(f.$links_yours.prev.is_terminator == false);
1179
1180        insert_last(fly, f);
1181        verify(validate(fly));
1182        verify(validate(flm));
1183        printYourFreddies(fly`first, fly`last, 0);     // 0.7; 0.7; 0.7; 0.7
1184}
1185
1186void test__remove_of_sole__mary() {
1187
1188        mary m = {0.7};
1189
1190        dlist(mary) ml;
1191        insert_last(ml, m);
1192
1193        printMariatheotokos(ml`first, ml`last, 1);     // 0.7; 0.7; 0.7; 0.7
1194
1195        verify(validate(ml));
1196
1197        remove(m);
1198
1199        verify(validate(ml));
1200
1201        assert( & ml`first == 0p );
1202        assert( & ml`last == 0p );
1203
1204        // observe f is solo in mine (now unlisted); in yours, it was just traversed
1205        printMariatheotokos(m, *0p, 0);    // 0.7; 0.7; ;
1206
1207        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1208        // assert(m.$links.next.is_terminator == false);
1209        // assert(m.$links.prev.is_terminator == false);
1210
1211        insert_last(ml, m);
1212        verify(validate(ml));
1213        printMariatheotokos(ml`first, ml`last, 0);     // 0.7; 0.7; 0.7; 0.7
1214}
1215
1216////////////////////////////////////////////////////////////
1217//
1218// Section 4f
1219//
1220// Test cases of pop_first, pop_last
1221//
1222// Example of call-side user code
1223//
1224////////////////////////////////////////////////////////////
1225
1226// These cases assume element removal at first-last is correct
1227
1228void test__pop_first__fred_mine() {
1229
1230        fred f1 = {1.7};
1231        fred f2 = {2.7};
1232        fred f3 = {3.7};
1233
1234        dlist(fred, fred.mine) flm;
1235        insert_last(flm, f1);
1236        insert_last(flm, f2);
1237        insert_last(flm, f3);
1238
1239        dlist(fred, fred.yours) fly;
1240        insert_last(fly, f1);
1241        insert_last(fly, f2);
1242        insert_last(fly, f3);
1243
1244        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1245        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1246
1247        verify(validate(fly));
1248        verify(validate(flm));
1249
1250        fred & popped = try_pop_front(flm);
1251
1252        verify(validate(fly));
1253        verify(validate(flm));
1254
1255        printMyFreddies(flm`first, flm`last, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
1256        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
1257
1258        // observe f1 is now solo in mine; in yours, it was just traversed
1259        printMyFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
1260
1261        assert( &popped == & f1 );
1262}
1263
1264void test__pop_first__fred_yours() {
1265
1266        fred f1 = {1.7};
1267        fred f2 = {2.7};
1268        fred f3 = {3.7};
1269
1270        dlist(fred, fred.mine) flm;
1271        insert_last(flm, f1);
1272        insert_last(flm, f2);
1273        insert_last(flm, f3);
1274
1275        dlist(fred, fred.yours) fly;
1276        insert_last(fly, f1);
1277        insert_last(fly, f2);
1278        insert_last(fly, f3);
1279
1280        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1281        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1282
1283        verify(validate(fly));
1284        verify(validate(flm));
1285
1286        fred & popped = try_pop_front(fly);
1287
1288        verify(validate(fly));
1289        verify(validate(flm));
1290
1291        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
1292        printYourFreddies(fly`first, fly`last, 0);   // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
1293
1294        // observe f1 is now solo in yours; in mine, it was just traversed
1295        printYourFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
1296
1297        assert( &popped == &f1 );
1298}
1299
1300void test__pop_first__maries() {
1301
1302        mary m1 = {1.7};
1303        mary m2 = {2.7};
1304        mary m3 = {3.7};
1305
1306        dlist(mary) ml;
1307        insert_last(ml, m1);
1308        insert_last(ml, m2);
1309        insert_last(ml, m3);
1310
1311        printMariatheotokos(ml`first, ml`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1312
1313        verify(validate(ml));
1314
1315        mary & popped = try_pop_front(ml);
1316
1317        verify(validate(ml));
1318
1319        printMariatheotokos(ml`first, ml`last, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
1320
1321        // observe m1 is now solo
1322        printMariatheotokos(m1, *0p, 0);               // 1.7; 1.7; ;
1323
1324        assert( &popped == &m1 );
1325}
1326
1327void test__pop_last__fred_mine() {
1328
1329        fred f1 = {1.7};
1330        fred f2 = {2.7};
1331        fred f3 = {3.7};
1332
1333        dlist(fred, fred.mine) flm;
1334        insert_last(flm, f1);
1335        insert_last(flm, f2);
1336        insert_last(flm, f3);
1337
1338        dlist(fred, fred.yours) fly;
1339        insert_last(fly, f1);
1340        insert_last(fly, f2);
1341        insert_last(fly, f3);
1342
1343        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1344        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1345
1346        verify(validate(fly));
1347        verify(validate(flm));
1348
1349        fred & popped = try_pop_back(flm);
1350
1351        verify(validate(fly));
1352        verify(validate(flm));
1353
1354        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
1355        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
1356
1357        // observe f3 is now solo in mine; in yours, it was just traversed
1358        printMyFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
1359
1360        assert( &popped == & f3 );
1361}
1362
1363void test__pop_last__fred_yours() {
1364
1365        fred f1 = {1.7};
1366        fred f2 = {2.7};
1367        fred f3 = {3.7};
1368
1369        dlist(fred, fred.mine) flm;
1370        insert_last(flm, f1);
1371        insert_last(flm, f2);
1372        insert_last(flm, f3);
1373
1374        dlist(fred, fred.yours) fly;
1375        insert_last(fly, f1);
1376        insert_last(fly, f2);
1377        insert_last(fly, f3);
1378
1379        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1380        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1381
1382        verify(validate(fly));
1383        verify(validate(flm));
1384
1385        fred & popped = try_pop_back(fly);
1386
1387        verify(validate(fly));
1388        verify(validate(flm));
1389
1390        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
1391        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
1392
1393        // observe f3 is now solo in yours; in mine, it was just traversed
1394        printYourFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
1395
1396        assert( &popped == & f3 );
1397}
1398
1399void test__pop_last__maries() {
1400
1401        mary m1 = {1.7};
1402        mary m2 = {2.7};
1403        mary m3 = {3.7};
1404
1405        dlist(mary) ml;
1406        insert_last(ml, m1);
1407        insert_last(ml, m2);
1408        insert_last(ml, m3);
1409
1410        printMariatheotokos(ml`first, ml`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1411
1412        verify(validate(ml));
1413
1414        mary & popped = try_pop_back(ml);
1415
1416        verify(validate(ml));
1417
1418        printMariatheotokos(ml`first, ml`last, 0);     // 1.7, 1.7;       1.7;  2.7;  2.7, 1.7      (modified)
1419
1420        // observe m1 is now solo
1421        printMariatheotokos(m3, *0p, 0);               // 3.7; 3.7; ;
1422
1423        assert( &popped == &m3 );
1424}
1425
1426////////////////////////////////////////////////////////////
1427//
1428// Section 4g
1429//
1430// Test cases of `isEmpty, `hasPrev, `hasNext,
1431// try_pop_front, try_pop_back, modifications via `elems
1432//
1433// Example of call-side user code
1434//
1435////////////////////////////////////////////////////////////
1436
1437void test__accessor_cases__mary() {
1438
1439        mary m1 = {1.7};
1440        mary m2 = {2.7};
1441        mary m3 = {3.7};
1442
1443        dlist(mary) ml;                 assert( ml`isEmpty);
1444
1445        insert_last(ml, m1);    assert(!ml`isEmpty);
1446        insert_last(ml, m2);    assert(!ml`isEmpty);
1447        insert_last(ml, m3);    assert(!ml`isEmpty);
1448
1449        mary & m1prev = m1`prev;
1450        mary & m1next = m1`next;
1451        mary & m2prev = m2`prev;
1452        mary & m2next = m2`next;
1453        mary & m3prev = m3`prev;
1454        mary & m3next = m3`next;
1455
1456        assert (&m1prev == 0p);
1457        assert (&m1next == &m2);
1458        assert (&m2prev == &m1);
1459        assert (&m2next == &m3);
1460        assert (&m3prev == &m2);
1461        assert (&m3next == 0p);
1462
1463        assert(!m1`hasPrev);
1464        assert( m1`hasNext);
1465        assert( m2`hasPrev);
1466        assert( m2`hasNext);
1467        assert( m3`hasPrev);
1468        assert(!m3`hasNext);
1469
1470        printf("accessor_cases done\n");
1471}
1472
1473void test__try_pop__mary() {
1474
1475        mary m1 = {1.7};
1476        mary m2 = {2.7};
1477        mary m3 = {3.7};
1478
1479        dlist(mary) ml;
1480
1481        mary &m1r = *0p;
1482        mary &m2r = *0p;
1483        mary &m3r = *0p;
1484        mary &mxr = *0p;
1485
1486        // queue, back to front
1487
1488        assert( ml`isEmpty);
1489
1490        insert_last(ml, m1);
1491        insert_last(ml, m2);
1492        insert_last(ml, m3);
1493
1494        &m1r = & try_pop_front(ml);     assert(!ml`isEmpty);
1495        &m2r = & try_pop_front(ml);     assert(!ml`isEmpty);
1496        &m3r = & try_pop_front(ml);     assert( ml`isEmpty);
1497        &mxr = & try_pop_front(ml);     assert( ml`isEmpty);
1498
1499        assert( &m1r == &m1 );
1500        assert( &m2r == &m2 );
1501        assert( &m3r == &m3 );
1502        assert( &mxr == 0p  );
1503
1504        &m1r = 0p;
1505        &m2r = 0p;
1506        &m3r = 0p;
1507
1508        // queue, front to back
1509
1510        assert( ml`isEmpty);
1511
1512        insert_first(ml, m1);
1513        insert_first(ml, m2);
1514        insert_first(ml, m3);
1515
1516        &m1r = & try_pop_back(ml);      assert(!ml`isEmpty);
1517        &m2r = & try_pop_back(ml);      assert(!ml`isEmpty);
1518        &m3r = & try_pop_back(ml);      assert( ml`isEmpty);
1519        &mxr = & try_pop_back(ml);      assert( ml`isEmpty);
1520
1521        assert( &m1r == &m1 );
1522        assert( &m2r == &m2 );
1523        assert( &m3r == &m3 );
1524        assert( &mxr == 0p  );
1525
1526        &m1r = 0p;
1527        &m2r = 0p;
1528        &m3r = 0p;
1529
1530        // stack at front
1531
1532        assert( ml`isEmpty);
1533
1534        insert_first(ml, m1);
1535        insert_first(ml, m2);
1536        insert_first(ml, m3);
1537
1538        &m3r = & try_pop_front(ml);     assert(!ml`isEmpty);
1539        &m2r = & try_pop_front(ml);     assert(!ml`isEmpty);
1540        &m1r = & try_pop_front(ml);     assert( ml`isEmpty);
1541        &mxr = & try_pop_front(ml);     assert( ml`isEmpty);
1542
1543        assert( &m1r == &m1 );
1544        assert( &m2r == &m2 );
1545        assert( &m3r == &m3 );
1546        assert( &mxr == 0p  );
1547
1548        &m1r = 0p;
1549        &m2r = 0p;
1550        &m3r = 0p;
1551
1552        // stack at back
1553
1554        assert( ml`isEmpty);
1555
1556        insert_last(ml, m1);
1557        insert_last(ml, m2);
1558        insert_last(ml, m3);
1559
1560        &m3r = & try_pop_back(ml);      assert(!ml`isEmpty);
1561        &m2r = & try_pop_back(ml);      assert(!ml`isEmpty);
1562        &m1r = & try_pop_back(ml);      assert( ml`isEmpty);
1563        &mxr = & try_pop_back(ml);      assert( ml`isEmpty);
1564
1565        assert( &m1r == &m1 );
1566        assert( &m2r == &m2 );
1567        assert( &m3r == &m3 );
1568        assert( &mxr == 0p  );
1569
1570        &m1r = 0p;
1571        &m2r = 0p;
1572        &m3r = 0p;
1573
1574        printf("try_pop cases done\n");
1575}
1576
1577void test__origin_mutation__mary() {
1578
1579        mary m1 = {1.7};
1580
1581        dlist(mary) ml;
1582        mary & mlorigin = ml`elems;
1583
1584        // insert before the origin
1585
1586        insert_before( ml`elems, m1 );
1587        assert( ! ml`isEmpty );
1588
1589        mary & mlfirst = ml`first;
1590        mary & mllast = ml`last;
1591
1592        assert( &m1 == & mlfirst );
1593        assert( &m1 == & mllast );
1594
1595        // moveNext after last goes back to origin, &vv
1596
1597        bool canMoveNext = mllast`moveNext;
1598        bool canMovePrev = mlfirst`movePrev;
1599
1600        assert( ! canMoveNext );
1601        assert( ! canMovePrev );
1602
1603        assert( &mlorigin == & mlfirst );
1604        assert( &mlorigin == & mllast );
1605
1606        printf("origin_mutation cases done\n");
1607}
1608
1609void test__isListed_cases__mary() {
1610
1611        mary m1 = {1.7};        assert(! m1`isListed);
1612        mary m2 = {2.7};        assert(! m2`isListed);
1613        mary m3 = {3.7};        assert(! m3`isListed);
1614
1615        dlist(mary) ml;
1616
1617        insert_last(ml, m1);    assert(  m1`isListed);  assert(! m2`isListed);
1618        insert_last(ml, m2);    assert(  m2`isListed);  assert(! m3`isListed);
1619        insert_last(ml, m3);    assert(  m3`isListed);
1620
1621        remove( m1 );           assert(! m1`isListed);  assert(  m2`isListed);
1622        remove( m2 );           assert(! m2`isListed);  assert(  m3`isListed);
1623        remove( m3 );           assert(! m3`isListed);
1624
1625        printf("isListed cases done\n");
1626}
1627
1628////////////////////////////////////////////////////////////
1629//
1630// Section 5
1631//
1632// Simple driver with the inter-scario printing
1633//
1634////////////////////////////////////////////////////////////
1635
1636int main() {
1637#if 0
1638        sout | "~~~~~~~~~~~~~~~~~ Headless List Tests - insert_after ~~~~~~~~~~~~~~~~";
1639        sout | "";
1640
1641        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1642        sout | "Test 1-i:  Modifying Freds on MINE ";
1643        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1644        test__insertafter_singleton_on_singleton__fred_mine();
1645
1646        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1647        sout | "Test 2-i.  Modifying Freds on YOURS";
1648        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1649        test__insertafter_singleton_on_singleton__fred_yours();
1650
1651        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1652        sout | "Test 3-i.  Modifying Maries";
1653        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1654        test__insertafter_singleton_on_singleton__mary();
1655
1656        sout | "";
1657        sout | "~~~~~~~~~~~~~~~~ Headless List Tests - insert_before ~~~~~~~~~~~~~~~~";
1658        sout | "";
1659
1660        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1661        sout | "Test 1-ii:  Modifying Freds on MINE ";
1662        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1663        test__insertbefore_singleton_on_singleton__fred_mine();
1664
1665        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1666        sout | "Test 2-ii.  Modifying Freds on YOURS";
1667        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1668        test__insertbefore_singleton_on_singleton__fred_yours();
1669
1670        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1671        sout | "Test 3-ii.  Modifying Maries";
1672        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1673        test__insertbefore_singleton_on_singleton__mary();
1674#endif
1675        sout | "";
1676        sout | "~~~~~~~~~~~~~~~~~ Headed List Tests - insert_first ~~~~~~~~~~~~~~~~~~";
1677        sout | "";
1678
1679        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1680        sout | "Test 4-i:  Modifying Freds on MINE ";
1681        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1682        test__insertfirst_two_on_empty__fred_mine();
1683
1684        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1685        sout | "Test 5-i:  Modifying Freds on YOURS ";
1686        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1687        test__insertfirst_two_on_empty__fred_yours();
1688
1689        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1690        sout | "Test 6-i.  Modifying Maries";
1691        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1692        test__insertfirst_two_on_empty__mary();
1693
1694        sout | "";
1695        sout | "~~~~~~~~~~~~~~~~~ Headed List Tests - insert_last ~~~~~~~~~~~~~~~~~~~";
1696        sout | "";
1697
1698        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1699        sout | "Test 4-ii:  Modifying Freds on MINE ";
1700        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1701        test__insertlast_two_on_empty__fred_mine();
1702
1703        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1704        sout | "Test 5-ii:  Modifying Freds on YOURS ";
1705        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1706        test__insertlast_two_on_empty__fred_yours();
1707
1708        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1709        sout | "Test 6-ii.  Modifying Maries";
1710        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1711        test__insertlast_two_on_empty__mary();
1712
1713        sout | "";
1714        sout | "~~~~~~~~~~~ Element ops on Headed List Tests: after, last ~~~~~~~~~~~";
1715        sout | "";
1716
1717        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1718        sout | "Test 7-i.  Modifying Freds on MINE";
1719        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1720        test__insertafter_after_last__fred_mine();
1721
1722        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1723        sout | "Test 8-i.  Modifying Freds on YOURS";
1724        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1725        test__insertafter_after_last__fred_yours();
1726
1727        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~";
1728        sout | "Test 9-i.  Modifying Maries";
1729        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~";
1730        test__insertafter_after_last__mary();
1731
1732        sout | "";
1733        sout | "~~~~~~~~~~ Element ops on Headed List Tests: before, first ~~~~~~~~~~";
1734        sout | "";
1735
1736        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1737        sout | "Test 7-ii.  Modifying Freds on MINE";
1738        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1739        test__insertbefore_before_first__fred_mine();
1740
1741        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1742        sout | "Test 8-ii.  Modifying Freds on YOURS";
1743        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1744        test__insertbefore_before_first__fred_yours();
1745
1746        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1747        sout | "Test 9-ii.  Modifying Maries";
1748        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1749        test__insertbefore_before_first__mary();
1750#if 0
1751
1752        sout | "";
1753        sout | "~~~~~~~~~~ Element removal tests on Headless List: mid ~~~~~~~~~~";
1754        sout | "";
1755
1756        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1757        sout | "Test 10-i.  Modifying Freds on MINE";
1758        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1759        test__remove_mid__fred_mine();
1760
1761        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1762        sout | "Test 11-i.  Modifying Freds on YOURS";
1763        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1764        test__remove_mid__fred_yours();
1765
1766        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1767        sout | "Test 12-i.  Modifying Maries";
1768        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1769        test__remove_mid__mary();
1770
1771        sout | "";
1772        sout | "~~~~~~~~~~ Element removal tests on Headless List: at first ~~~~~~~~~~";
1773        sout | "";
1774
1775        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1776        sout | "Test 10-ii.  Modifying Freds on MINE";
1777        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1778        test__remove_at_first__fred_mine();
1779
1780        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1781        sout | "Test 11-ii.  Modifying Freds on YOURS";
1782        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1783        test__remove_at_first__fred_yours();
1784
1785        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1786        sout | "Test 12-ii.  Modifying Maries";
1787        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1788        test__remove_at_first__mary();
1789
1790        sout | "";
1791        sout | "~~~~~~~~~~ Element removal tests on Headless List: at last ~~~~~~~~~~";
1792        sout | "";
1793
1794        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1795        sout | "Test 10-iii.  Modifying Freds on MINE";
1796        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1797        test__remove_at_last__fred_mine();
1798
1799        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1800        sout | "Test 11-iii.  Modifying Freds on YOURS";
1801        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1802        test__remove_at_last__fred_yours();
1803
1804        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1805        sout | "Test 12-iii.  Modifying Maries";
1806        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1807        test__remove_at_last__mary();
1808#endif
1809        sout | "";
1810        sout | "~~~~~~~~~~ Element removal tests on Headed List: at first ~~~~~~~~~~";
1811        sout | "";
1812
1813        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1814        sout | "Test 13-i.  Modifying Freds on MINE";
1815        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1816        test__remove_at_head__fred_mine();
1817
1818        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1819        sout | "Test 14-i.  Modifying Freds on YOURS";
1820        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1821        test__remove_at_head__fred_yours();
1822
1823        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1824        sout | "Test 15-i.  Modifying Maries";
1825        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1826        test__remove_at_head__mary();
1827
1828        sout | "";
1829        sout | "~~~~~~~~~~ Element removal tests on Headed List: at last ~~~~~~~~~~";
1830        sout | "";
1831
1832        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1833        sout | "Test 13-ii.  Modifying Freds on MINE";
1834        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1835        test__remove_at_tail__fred_mine();
1836
1837        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1838        sout | "Test 14-ii.  Modifying Freds on YOURS";
1839        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1840        test__remove_at_tail__fred_yours();
1841
1842        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1843        sout | "Test 15-ii.  Modifying Maries";
1844        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1845        test__remove_at_tail__mary();
1846
1847        sout | "";
1848        sout | "~~~~~~~~~~ Element removal tests on Headed List: of sole ~~~~~~~~~~";
1849        sout | "";
1850
1851        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1852        sout | "Test 13-iii.  Modifying Freds on MINE";
1853        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1854        test__remove_of_sole__fred_mine();
1855
1856        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1857        sout | "Test 14-iii.  Modifying Freds on YOURS";
1858        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1859        test__remove_of_sole__fred_yours();
1860
1861        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1862        sout | "Test 15-iii.  Modifying Maries";
1863        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1864        test__remove_of_sole__mary();
1865
1866        sout | "";
1867        sout | "~~~~~~~~~~ End removal tests on Headed List: First ~~~~~~~~~~";
1868        sout | "";
1869
1870        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1871        sout | "Test 16-i.  Modifying Freds on MINE";
1872        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1873        test__pop_first__fred_mine();
1874
1875        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1876        sout | "Test 16-ii.  Modifying Freds on YOURS";
1877        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1878        test__pop_first__fred_yours();
1879
1880        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1881        sout | "Test 16-iii.  Modifying Maries";
1882        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1883        test__pop_first__maries();
1884
1885        sout | "";
1886        sout | "~~~~~~~~~~ End removal tests on Headed List: Last ~~~~~~~~~~";
1887        sout | "";
1888
1889        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1890        sout | "Test 17-i.  Modifying Freds on MINE";
1891        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1892        test__pop_last__fred_mine();
1893
1894        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1895        sout | "Test 17-ii.  Modifying Freds on YOURS";
1896        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1897        test__pop_last__fred_yours();
1898
1899        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1900        sout | "Test 17-iii.  Modifying Maries";
1901        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1902        test__pop_last__maries();
1903
1904        sout | "";
1905        sout | "~~~~~~~~~~~~~~~~~~~ Ease-of-access cases ~~~~~~~~~~~~~~~~~~";
1906        sout | "";
1907
1908        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1909        sout | "Test 18-i.  Modifying Freds on MINE";
1910        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1911        sout | "Not implmented";
1912
1913        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1914        sout | "Test 18-ii.  Modifying Freds on YOURS";
1915        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1916        sout | "Not implmented";
1917
1918        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1919        sout | "Test 18-iii.  Modifying Maries";
1920        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1921
1922        test__accessor_cases__mary();
1923        test__try_pop__mary();
1924        test__origin_mutation__mary();
1925        test__isListed_cases__mary();
1926
1927        return 0;
1928}
Note: See TracBrowser for help on using the repository browser.