source: tests/list/dlist-insert-remove-2.cfa @ 8d1ad36

arm-ehenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 8d1ad36 was 8d1ad36, checked in by Michael Brooks <mlbrooks@…>, 19 months ago

Adding linked-list convenience functions and testing a corner case.

New API: isEmpty, hasPrev, `hasNext, try_pop_front, try_pop_back

Corner case: modifications near `elems (inserting in all n+1 interator states)

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