source: tests/list/dlist-insert-remove.cfa @ 6091b88a

arm-ehjacob/cs343-translationnew-astnew-ast-unique-expr
Last change on this file since 6091b88a was 6091b88a, checked in by Michael Brooks <mlbrooks@…>, 18 months ago

intrusive doubly linked list initial

  • Property mode set to 100644
File size: 35.9 KB
Line 
1#include <containers/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        DLISTED_MGD_EXPL_IN(fred, mine)
22        DLISTED_MGD_EXPL_IN(fred, yours)
23};
24
25DLISTED_MGD_EXPL_OUT(fred, mine)
26DLISTED_MGD_EXPL_OUT(fred, yours)
27
28void ?{}(fred &this, float adatum) {
29        (this.adatum){adatum};
30}
31
32// a mary belongs to just one doubly-linked list: hers
33struct mary {
34        float anotherdatum;
35        DLISTED_MGD_IMPL_IN(mary)
36};
37
38DLISTED_MGD_IMPL_OUT(mary)
39
40void ?{}(mary &this, float anotherdatum) {
41        (this.anotherdatum){anotherdatum};
42}
43
44////////////////////////////////////////////////////////////
45//
46// Section 3
47//
48// Test helpers to traverse and print lists.
49//
50// These consume framework-provided accessor functions and
51// do not modify their parameter lists.
52//
53////////////////////////////////////////////////////////////
54
55void printMyFredsFwd(fred &f) {
56        while (&f != 0p) {
57                sout | f.adatum;
58                &f = &f`in_mine`next;
59        }
60}
61
62void printMyFredsRev(fred &f) {
63        while (&f != 0p) {
64                sout | f.adatum;
65                &f = &f`in_mine`prev;
66        }
67}
68
69void printMyFreddies(fred &f1, fred &f2, int isBefore) {
70        if (isBefore) {
71                sout | "==== fred by MINE before ";
72        } else {
73                sout | "==== fred by MINE after ";
74        }
75        printMyFredsFwd(f1);    sout | '-';
76        printMyFredsRev(f1);    sout | '-';
77        printMyFredsFwd(f2);    sout | '-';
78        printMyFredsRev(f2);    sout | '-';
79}
80
81void printYourFredsFwd(fred &f) {
82        while (&f != 0p) {
83                sout | f.adatum;
84                &f = &f`in_yours`next;
85        }
86}
87
88void printYourFredsRev(fred &f) {
89        while (&f != 0p) {
90                sout | f.adatum;
91                &f = &f`in_yours`prev;
92        }
93}
94
95void printYourFreddies(fred &f1, fred &f2, int isBefore) {
96        if (isBefore) {
97                sout | "==== fred by YOURS before ";
98        } else {
99                sout | "==== fred by YOURS after ";
100        }
101        printYourFredsFwd(f1);  sout | '-';
102        printYourFredsRev(f1);  sout | '-';
103        printYourFredsFwd(f2);  sout | '-';
104        printYourFredsRev(f2);  sout | '-';
105}
106
107void printMariesFwd(mary &m) {
108        while (&m != 0p) {
109                sout | m.anotherdatum;
110                &m = &m`next;
111        }
112}
113
114void printMariesRev(mary &m) {
115        while (&m != 0p) {
116                sout | m.anotherdatum;
117                &m = &m`prev;
118        }
119}
120
121void printMariatheotokos(mary &m1, mary &m2, int isBefore) {
122        if (isBefore) {
123                sout | "==== mary before ";
124        } else {
125                sout | "==== mary after ";
126        }
127        printMariesFwd(m1);     sout | '-';
128        printMariesRev(m1);     sout | '-';
129        printMariesFwd(m2);     sout | '-';
130        printMariesRev(m2);     sout | '-';
131}
132
133////////////////////////////////////////////////////////////
134//
135// Section 4a.i
136//
137// Test cases of insert_after on headless list
138//
139// Example of call-side user code
140//
141////////////////////////////////////////////////////////////
142
143// All three tests exercise the case of merging two singleton lists into (their respective
144// positions in) one common list of two elements.
145
146// Note that the factoring of sect 4 (vs 3 and 5) keeps section 4 free of strings and IO,
147// and so keeps its assembly easy to inspect.
148
149// Throughout all the 4s, all the print functions called from these tests print:
150//  - from list position #1 moving forward  (a)
151//  - from list position #1 moving backward (b)
152//  - from list position #2 moving forward  (c)
153//  - from list position #2 moving backward (d)
154// The expected-output comments are in form a;b;c;d where a::=num,num,num
155
156void test__insertafter_singleton_on_singleton__fred_mine () {
157        fred f1 = {3.14};
158        fred f2 = {0.5};
159
160        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
161        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
162
163        insert_after(f1`in_mine, f2);
164
165        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
166        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
167}
168
169void test__insertafter_singleton_on_singleton__fred_yours () {
170        fred f1 = {3.14};
171        fred f2 = {0.5};
172
173        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
174        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
175
176        insert_after(f1`in_yours, f2);
177
178        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
179        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
180}
181
182void test__insertafter_singleton_on_singleton__mary () {
183        mary m1 = {3.14};
184        mary m2 = {0.5};
185
186        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
187
188        insert_after(m1, m2);
189
190        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
191}
192
193////////////////////////////////////////////////////////////
194//
195// Section 4a.ii
196//
197// Test cases of insert_before on headless list
198//
199// Example of call-side user code
200//
201////////////////////////////////////////////////////////////
202
203void test__insertbefore_singleton_on_singleton__fred_mine () {
204        fred f1 = {3.14};
205        fred f2 = {0.5};
206
207        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
208        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
209
210        insert_before(f2`in_mine, f1);
211
212        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
213        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
214}
215
216void test__insertbefore_singleton_on_singleton__fred_yours () {
217        fred f1 = {3.14};
218        fred f2 = {0.5};
219
220        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
221        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
222
223        insert_before(f2`in_yours, f1);
224
225        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
226        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
227}
228
229void test__insertbefore_singleton_on_singleton__mary () {
230        mary m1 = {3.14};
231        mary m2 = {0.5};
232
233        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
234
235        insert_before(m2, m1);
236
237        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
238}
239
240////////////////////////////////////////////////////////////
241//
242// Section 4b.i
243//
244// Test cases of insert_first (necessarily headed list)
245//
246// Example of call-side user code
247//
248////////////////////////////////////////////////////////////
249
250// All three tests exercise the case of creating an empty container and
251// adding two items to it.
252
253void test__insertfirst_two_on_empty__fred_mine() {
254
255        fred f1 = {3.14};
256        fred f2 = {0.5};
257
258        dlist(fred_in_mine, fred) lf;
259
260        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
261        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
262
263        insert_first(lf, f2);
264        insert_first(lf, f1);
265
266        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
267        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
268}
269
270void test__insertfirst_two_on_empty__fred_yours() {
271
272        fred f1 = {3.14};
273        fred f2 = {0.5};
274
275        dlist(fred_in_yours, fred) lf;
276
277        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
278        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
279
280        insert_first(lf, f2);
281        insert_first(lf, f1);
282
283        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
284        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
285}
286
287void test__insertfirst_two_on_empty__mary() {
288
289        mary m1 = {3.14};
290        mary m2 = {0.5};
291
292        dlist(mary, mary) lm;
293
294        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
295
296        insert_first(lm, m2);
297        insert_first(lm, m1);
298
299        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
300}
301
302////////////////////////////////////////////////////////////
303//
304// Section 4b.ii
305//
306// Test cases of insert_last (necessarily headed list)
307//
308// Example of call-side user code
309//
310////////////////////////////////////////////////////////////
311
312void test__insertlast_two_on_empty__fred_mine() {
313
314        fred f1 = {3.14};
315        fred f2 = {0.5};
316
317        dlist(fred_in_mine, fred) lf;
318
319        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
320        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
321
322        insert_last(lf, f1);
323        insert_last(lf, f2);
324
325        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
326        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
327}
328
329void test__insertlast_two_on_empty__fred_yours() {
330
331        fred f1 = {3.14};
332        fred f2 = {0.5};
333
334        dlist(fred_in_yours, fred) lf;
335
336        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
337        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
338
339        insert_last(lf, f1);
340        insert_last(lf, f2);
341
342        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
343        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
344}
345
346void test__insertlast_two_on_empty__mary() {
347
348        mary m1 = {3.14};
349        mary m2 = {0.5};
350
351        dlist(mary, mary) lm;
352
353        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
354
355        insert_last(lm, m1);
356        insert_last(lm, m2);
357
358        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
359}
360
361////////////////////////////////////////////////////////////
362//
363// Section 4c.i
364//
365// Test cases of insert_after on headed list
366//
367// Example of call-side user code
368//
369////////////////////////////////////////////////////////////
370
371void test__insertafter_after_last__fred_mine() {
372
373        fred f1 = {3.14};
374        fred f2 = {0.5};
375
376        dlist(fred_in_mine, fred) lf;
377
378        assert(& lf`first == 0p);
379        assert(& lf`last == 0p);
380
381        insert_first(lf, f1);
382
383        assert(& lf`first == & f1);
384        assert(& lf`last == & f1);
385
386        insert_after(f1`in_mine, f2);
387
388        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
389        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
390
391        assert(& lf`first == & f1);
392        assert(& lf`last == & f2);
393}
394
395void test__insertafter_after_last__fred_yours() {
396
397        fred f1 = {3.14};
398        fred f2 = {0.5};
399
400        dlist(fred_in_yours, fred) lf;
401
402        assert(& lf`first == 0p);
403        assert(& lf`last == 0p);
404
405        insert_first(lf, f1);
406
407        assert(& lf`first == & f1);
408        assert(& lf`last == & f1);
409
410        insert_after(f1`in_yours, f2);
411
412        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
413        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
414
415        assert(& lf`first == & f1);
416        assert(& lf`last == & f2);
417}
418
419void test__insertafter_after_last__mary() {
420
421        mary m1 = {3.14};
422        mary m2 = {0.5};
423
424        dlist(mary, mary) lm;
425
426        assert(& lm`first == 0p);
427        assert(& lm`last == 0p);
428
429        insert_first(lm, m1);
430
431        assert(& lm`first == & m1);
432        assert(& lm`last == & m1);
433
434        insert_after(m1, m2);
435
436        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
437
438        assert(& lm`first == & m1);
439        assert(& lm`last == & m2);
440}
441
442////////////////////////////////////////////////////////////
443//
444// Section 4c.ii
445//
446// Test cases of insert_before on headed list
447//
448// Example of call-side user code
449//
450////////////////////////////////////////////////////////////
451
452void test__insertbefore_before_first__fred_mine() {
453
454        fred f1 = {3.14};
455        fred f2 = {0.5};
456
457        dlist(fred_in_mine, fred) lf;
458
459        assert(& lf`first == 0p);
460        assert(& lf`last == 0p);
461
462        insert_last(lf, f2);
463
464        assert(& lf`first == & f2);
465        assert(& lf`last == & f2);
466
467        insert_before(f2`in_mine, f1);
468
469        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
470        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
471
472        assert(& lf`first == & f1);
473        assert(& lf`last == & f2);
474}
475
476void test__insertbefore_before_first__fred_yours() {
477
478        fred f1 = {3.14};
479        fred f2 = {0.5};
480
481        dlist(fred_in_yours, fred) lf;
482
483        assert(& lf`first == 0p);
484        assert(& lf`last == 0p);
485
486        insert_last(lf, f2);
487
488        assert(& lf`first == & f2);
489        assert(& lf`last == & f2);
490
491        insert_before(f2`in_yours, f1);
492
493        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
494        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
495
496        assert(& lf`first == & f1);
497        assert(& lf`last == & f2);
498}
499
500void test__insertbefore_before_first__mary() {
501
502        mary m1 = {3.14};
503        mary m2 = {0.5};
504
505        dlist(mary, mary) lm;
506
507        assert(& lm`first == 0p);
508        assert(& lm`last == 0p);
509
510        insert_last(lm, m2);
511
512        assert(& lm`first == & m2);
513        assert(& lm`last == & m2);
514
515        insert_before(m2, m1);
516
517        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
518
519        assert(& lm`first == & m1);
520        assert(& lm`last == & m2);
521}
522
523////////////////////////////////////////////////////////////
524//
525// Section 4d.i
526//
527// Test cases of remove, from middle of headless list
528//
529// Example of call-side user code
530//
531////////////////////////////////////////////////////////////
532
533// These tests, in the fred cases, set up the my/your lists initially identical,
534// act on one list, and expect the other unaffected.
535
536void test__remove_mid__fred_mine() {
537
538        fred f1 = {1.7};
539        fred f2 = {2.7};
540        fred f3 = {3.7};
541
542        insert_after(f1`in_mine, f2);
543        insert_after(f2`in_mine, f3);
544
545        insert_after(f1`in_yours, f2);
546        insert_after(f2`in_yours, f3);
547
548        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
549        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
550
551        remove(f2`in_mine);
552
553        printMyFreddies(f1, f3, 0);     // 1.7, 3.7;       1.7;  3.7;  3.7, 1.7      (modified)
554        printYourFreddies(f1, f3, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
555
556        // observe f2 is now solo in mine; in yours, it was just traversed
557        printMyFreddies(f2, *0p, 0);    // 2.7; 2.7; ;
558
559        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
560        assert(f2.$links_mine.next.is_terminator == false);
561        assert(f2.$links_mine.prev.is_terminator == false);
562}
563
564void test__remove_mid__fred_yours() {
565
566        fred f1 = {1.7};
567        fred f2 = {2.7};
568        fred f3 = {3.7};
569
570        insert_after(f1`in_mine, f2);
571        insert_after(f2`in_mine, f3);
572
573        insert_after(f1`in_yours, f2);
574        insert_after(f2`in_yours, f3);
575
576        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
577        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
578
579        remove(f2`in_yours);
580
581        printMyFreddies(f1, f3, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
582        printYourFreddies(f1, f3, 0);   // 1.7, 3.7;       1.7;  3.7;  3.7, 1.7      (modified)
583
584        // observe f2 is now solo in yours; in mine, it was just traversed
585        printYourFreddies(f2, *0p, 0);    // 2.7; 2.7; ;
586
587        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
588        assert(f2.$links_yours.next.is_terminator == false);
589        assert(f2.$links_yours.prev.is_terminator == false);
590}
591
592void test__remove_mid__mary() {
593
594        mary m1 = {1.7};
595        mary m2 = {2.7};
596        mary m3 = {3.7};
597
598        insert_after(m1, m2);
599        insert_after(m2, m3);
600
601        printMariatheotokos(m1, m3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
602
603        remove(m2);
604
605        printMariatheotokos(m1, m3, 0);     // 1.7, 3.7;  1.7;  3.7;  3.7, 1.7 (modified)
606
607        // observe m2 is now solo
608        printMariatheotokos(m2, *0p, 0);    // 2.7; 2.7; ;
609
610        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
611        assert(m2.$links.next.is_terminator == false);
612        assert(m2.$links.prev.is_terminator == false);
613}
614
615////////////////////////////////////////////////////////////
616//
617// Section 4d.ii
618//
619// Test cases of remove, from first position of headless list
620//
621// Example of call-side user code
622//
623////////////////////////////////////////////////////////////
624
625// TODO: validate headless semantic: remove of a neighbourless element is valid and no-op
626
627void test__remove_at_first__fred_mine() {
628
629        fred f1 = {1.7};
630        fred f2 = {2.7};
631        fred f3 = {3.7};
632
633        insert_after(f1`in_mine, f2);
634        insert_after(f2`in_mine, f3);
635
636        insert_after(f1`in_yours, f2);
637        insert_after(f2`in_yours, f3);
638
639        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
640        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
641
642        remove(f1`in_mine);
643
644        printMyFreddies(f2, f3, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
645        printYourFreddies(f1, f3, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
646
647        // observe f1 is now solo in mine; in yours, it was just traversed
648        printMyFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
649
650        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
651        assert(f1.$links_mine.next.is_terminator == false);
652        assert(f1.$links_mine.prev.is_terminator == false);
653}
654
655void test__remove_at_first__fred_yours() {
656
657        fred f1 = {1.7};
658        fred f2 = {2.7};
659        fred f3 = {3.7};
660
661        insert_after(f1`in_mine, f2);
662        insert_after(f2`in_mine, f3);
663
664        insert_after(f1`in_yours, f2);
665        insert_after(f2`in_yours, f3);
666
667        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
668        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
669
670        remove(f1`in_yours);
671
672        printMyFreddies(f1, f3, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
673        printYourFreddies(f2, f3, 0);   // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
674
675        // observe f1 is now solo in yours; in mine, it was just traversed
676        printYourFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
677
678        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
679        assert(f1.$links_yours.next.is_terminator == false);
680        assert(f1.$links_yours.prev.is_terminator == false);
681}
682
683void test__remove_at_first__mary() {
684
685        mary m1 = {1.7};
686        mary m2 = {2.7};
687        mary m3 = {3.7};
688
689        insert_after(m1, m2);
690        insert_after(m2, m3);
691
692        printMariatheotokos(m1, m3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
693
694        remove(m1);
695
696        printMariatheotokos(m2, m3, 0);     // 2.7, 3.7;  2.7;  3.7;  3.7, 2.7 (modified)
697
698        // observe m2 is now solo
699        printMariatheotokos(m1, *0p, 0);    // 1.7; 1.7; ;
700
701        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
702        assert(m1.$links.next.is_terminator == false);
703        assert(m1.$links.prev.is_terminator == false);
704}
705
706////////////////////////////////////////////////////////////
707//
708// Section 4d.iii
709//
710// Test cases of remove, from last position of headless list
711//
712// Example of call-side user code
713//
714////////////////////////////////////////////////////////////
715
716void test__remove_at_last__fred_mine() {
717
718        fred f1 = {1.7};
719        fred f2 = {2.7};
720        fred f3 = {3.7};
721
722        insert_after(f1`in_mine, f2);
723        insert_after(f2`in_mine, f3);
724
725        insert_after(f1`in_yours, f2);
726        insert_after(f2`in_yours, f3);
727
728        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
729        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
730
731        remove(f3`in_mine);
732
733        printMyFreddies(f1, f2, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
734        printYourFreddies(f1, f3, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
735
736        // observe f3 is now solo in mine; in yours, it was just traversed
737        printMyFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
738
739        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
740        assert(f3.$links_mine.next.is_terminator == false);
741        assert(f3.$links_mine.prev.is_terminator == false);
742}
743
744void test__remove_at_last__fred_yours() {
745
746        fred f1 = {1.7};
747        fred f2 = {2.7};
748        fred f3 = {3.7};
749
750        insert_after(f1`in_mine, f2);
751        insert_after(f2`in_mine, f3);
752
753        insert_after(f1`in_yours, f2);
754        insert_after(f2`in_yours, f3);
755
756        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
757        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
758
759        remove(f3`in_yours);
760
761        printMyFreddies(f1, f3, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
762        printYourFreddies(f1, f2, 0);   // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
763
764        // observe f3 is now solo in yours; in mine, it was just traversed
765        printYourFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
766
767        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
768        assert(f3.$links_yours.next.is_terminator == false);
769        assert(f3.$links_yours.prev.is_terminator == false);
770}
771
772void test__remove_at_last__mary() {
773
774        mary m1 = {1.7};
775        mary m2 = {2.7};
776        mary m3 = {3.7};
777
778        insert_after(m1, m2);
779        insert_after(m2, m3);
780
781        printMariatheotokos(m1, m3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
782
783        remove(m3);
784
785        printMariatheotokos(m1, m2, 0);     // 1.7, 2.7;  1.7;  2.7;  2.7, 1.7 (modified)
786
787        // observe m3 is now solo
788        printMariatheotokos(m3, *0p, 0);    // 3.7; 3.7; ;
789
790        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
791        assert(m1.$links.next.is_terminator == false);
792        assert(m1.$links.prev.is_terminator == false);
793}
794
795////////////////////////////////////////////////////////////
796//
797// Section 4e.i
798//
799// Test cases of remove, from first position of headed list
800//
801// Example of call-side user code
802//
803////////////////////////////////////////////////////////////
804
805void test__remove_at_head__fred_mine() {
806
807        fred f1 = {1.7};
808        fred f2 = {2.7};
809        fred f3 = {3.7};
810
811        dlist(fred_in_mine, fred) flm;
812        insert_last(flm, f1);
813        insert_last(flm, f2);
814        insert_last(flm, f3);
815
816        dlist(fred_in_yours, fred) fly;
817        insert_last(fly, f1);
818        insert_last(fly, f2);
819        insert_last(fly, f3);
820
821        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
822        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
823
824        remove(f1`in_mine);
825
826        printMyFreddies(flm`first, flm`last, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
827        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
828
829        // observe f1 is now solo in mine; in yours, it was just traversed
830        printMyFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
831
832        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
833        assert(f1.$links_mine.next.is_terminator == false);
834        assert(f1.$links_mine.prev.is_terminator == false);
835}
836
837void test__remove_at_head__fred_yours() {
838
839        fred f1 = {1.7};
840        fred f2 = {2.7};
841        fred f3 = {3.7};
842
843        dlist(fred_in_mine, fred) flm;
844        insert_last(flm, f1);
845        insert_last(flm, f2);
846        insert_last(flm, f3);
847
848        dlist(fred_in_yours, fred) fly;
849        insert_last(fly, f1);
850        insert_last(fly, f2);
851        insert_last(fly, f3);
852
853        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
854        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
855
856        remove(f1`in_yours);
857
858        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
859        printYourFreddies(fly`first, fly`last, 0);   // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
860
861        // observe f1 is now solo in yours; in mine, it was just traversed
862        printYourFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
863
864        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
865        assert(f1.$links_yours.next.is_terminator == false);
866        assert(f1.$links_yours.prev.is_terminator == false);
867}
868
869void test__remove_at_head__mary() {
870
871        mary m1 = {1.7};
872        mary m2 = {2.7};
873        mary m3 = {3.7};
874
875        dlist(mary, mary) ml;
876        insert_last(ml, m1);
877        insert_last(ml, m2);
878        insert_last(ml, m3);
879
880        printMariatheotokos(ml`first, ml`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
881
882        remove(m1);
883
884        printMariatheotokos(ml`first, ml`last, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
885
886        // observe m1 is now solo
887        printMariatheotokos(m1, *0p, 0);               // 1.7; 1.7; ;
888
889        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
890        assert(m1.$links.next.is_terminator == false);
891        assert(m1.$links.prev.is_terminator == false);
892}
893
894////////////////////////////////////////////////////////////
895//
896// Section 4e.ii
897//
898// Test cases of remove, from last position of headed list
899//
900// Example of call-side user code
901//
902////////////////////////////////////////////////////////////
903
904void test__remove_at_tail__fred_mine() {
905
906        fred f1 = {1.7};
907        fred f2 = {2.7};
908        fred f3 = {3.7};
909
910        dlist(fred_in_mine, fred) flm;
911        insert_last(flm, f1);
912        insert_last(flm, f2);
913        insert_last(flm, f3);
914
915        dlist(fred_in_yours, fred) fly;
916        insert_last(fly, f1);
917        insert_last(fly, f2);
918        insert_last(fly, f3);
919
920        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
921        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
922
923        remove(f3`in_mine);
924
925        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
926        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
927
928        // observe f3 is now solo in mine; in yours, it was just traversed
929        printMyFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
930
931        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
932        assert(f3.$links_mine.next.is_terminator == false);
933        assert(f3.$links_mine.prev.is_terminator == false);
934}
935
936void test__remove_at_tail__fred_yours() {
937
938        fred f1 = {1.7};
939        fred f2 = {2.7};
940        fred f3 = {3.7};
941
942        dlist(fred_in_mine, fred) flm;
943        insert_last(flm, f1);
944        insert_last(flm, f2);
945        insert_last(flm, f3);
946
947        dlist(fred_in_yours, fred) fly;
948        insert_last(fly, f1);
949        insert_last(fly, f2);
950        insert_last(fly, f3);
951
952        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
953        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
954
955        remove(f3`in_yours);
956
957        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
958        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
959
960        // observe f3 is now solo in yours; in mine, it was just traversed
961        printYourFreddies(f3, *0p, 0);               // 3.7; 3.7; ;
962
963        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
964        assert(f3.$links_yours.next.is_terminator == false);
965        assert(f3.$links_yours.prev.is_terminator == false);
966}
967
968void test__remove_at_tail__mary() {
969
970        mary m1 = {1.7};
971        mary m2 = {2.7};
972        mary m3 = {3.7};
973
974        dlist(mary, mary) ml;
975        insert_last(ml, m1);
976        insert_last(ml, m2);
977        insert_last(ml, m3);
978
979        printMariatheotokos(ml`first, ml`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
980
981        remove(m3);
982
983        printMariatheotokos(ml`first, ml`last, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
984
985        // observe m3 is now solo
986        printMariatheotokos(m3, *0p, 0);               //3.7; 3.7; ;
987
988        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
989        assert(m3.$links.next.is_terminator == false);
990        assert(m3.$links.prev.is_terminator == false);
991}
992
993////////////////////////////////////////////////////////////
994//
995// Section 4e.iii
996//
997// Test cases of remove, of sole element of headed list
998//
999// Example of call-side user code
1000//
1001////////////////////////////////////////////////////////////
1002
1003void test__remove_of_sole__fred_mine() {
1004
1005        fred f = {0.7};
1006
1007        dlist(fred_in_mine, fred) flm;
1008        insert_last(flm, f);
1009
1010        dlist(fred_in_yours, fred) fly;
1011        insert_last(fly, f);
1012
1013        printMyFreddies(flm`first, flm`last, 1);     // 0.7; 0.7; 0.7; 0.7
1014        printYourFreddies(fly`first, fly`last, 1);   // 0.7; 0.7; 0.7; 0.7
1015
1016        remove(f`in_mine);
1017
1018        assert(& flm`first == 0p);
1019        assert(& flm`last  == 0p);
1020
1021        printYourFreddies(fly`first, fly`last, 0);   // 0.7; 0.7; 0.7; 0.7 (unmodified)
1022
1023        // observe f is solo in mine (now unlisted); in yours, it was just traversed
1024        printMyFreddies(f, *0p, 0);    // 0.7; 0.7; ;
1025
1026        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1027        assert(f.$links_mine.next.is_terminator == false);
1028        assert(f.$links_mine.prev.is_terminator == false);
1029
1030        insert_last(flm, f);
1031        printMyFreddies(flm`first, flm`last, 0);     // 0.7; 0.7; 0.7; 0.7
1032}
1033
1034void test__remove_of_sole__fred_yours() {
1035
1036        fred f = {0.7};
1037
1038        dlist(fred_in_mine, fred) flm;
1039        insert_last(flm, f);
1040
1041        dlist(fred_in_yours, fred) fly;
1042        insert_last(fly, f);
1043
1044        printMyFreddies(flm`first, flm`last, 1);     // 0.7; 0.7; 0.7; 0.7
1045        printYourFreddies(fly`first, fly`last, 1);   // 0.7; 0.7; 0.7; 0.7
1046
1047        remove(f`in_yours);
1048
1049        assert(& fly`first == 0p);
1050        assert(& fly`last  == 0p);
1051
1052        printYourFreddies(flm`first, flm`last, 0);   // 0.7; 0.7; 0.7; 0.7 (unmodified)
1053
1054        // observe f is solo in yours (now unlisted); in mine, it was just traversed
1055        printYourFreddies(f, *0p, 0);    // 0.7; 0.7; ;
1056
1057        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1058        assert(f.$links_yours.next.is_terminator == false);
1059        assert(f.$links_yours.prev.is_terminator == false);
1060
1061        insert_last(fly, f);
1062        printYourFreddies(fly`first, fly`last, 0);     // 0.7; 0.7; 0.7; 0.7
1063}
1064
1065void test__remove_of_sole__mary() {
1066
1067        mary m = {0.7};
1068
1069        dlist(mary, mary) ml;
1070        insert_last(ml, m);
1071
1072        printMariatheotokos(ml`first, ml`last, 1);     // 0.7; 0.7; 0.7; 0.7
1073
1074        remove(m);
1075
1076        assert(& ml`first == 0p);
1077        assert(& ml`last  == 0p);
1078
1079        // observe f is solo in mine (now unlisted); in yours, it was just traversed
1080        printMariatheotokos(m, *0p, 0);    // 0.7; 0.7; ;
1081
1082        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1083        assert(m.$links.next.is_terminator == false);
1084        assert(m.$links.prev.is_terminator == false);
1085
1086        insert_last(ml, m);
1087        printMariatheotokos(ml`first, ml`last, 0);     // 0.7; 0.7; 0.7; 0.7
1088}
1089
1090////////////////////////////////////////////////////////////
1091//
1092// Section 5
1093//
1094// Simple driver with the inter-scario printing
1095//
1096////////////////////////////////////////////////////////////
1097
1098int main() {
1099
1100        sout | "~~~~~~~~~~~~~~~~~ Headless List Tests - insert_after ~~~~~~~~~~~~~~~~";
1101        sout | "";
1102
1103        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1104        sout | "Test 1-i:  Modifying Freds on MINE ";
1105        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1106        test__insertafter_singleton_on_singleton__fred_mine();
1107
1108        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1109        sout | "Test 2-i.  Modifying Freds on YOURS";
1110        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1111        test__insertafter_singleton_on_singleton__fred_yours();
1112
1113        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1114        sout | "Test 3-i.  Modifying Maries";
1115        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1116        test__insertafter_singleton_on_singleton__mary();
1117
1118        sout | "";
1119        sout | "~~~~~~~~~~~~~~~~ Headless List Tests - insert_before ~~~~~~~~~~~~~~~~";
1120        sout | "";
1121
1122        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1123        sout | "Test 1-ii:  Modifying Freds on MINE ";
1124        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1125        test__insertbefore_singleton_on_singleton__fred_mine();
1126
1127        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1128        sout | "Test 2-ii.  Modifying Freds on YOURS";
1129        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1130        test__insertbefore_singleton_on_singleton__fred_yours();
1131
1132        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1133        sout | "Test 3-ii.  Modifying Maries";
1134        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1135        test__insertbefore_singleton_on_singleton__mary();
1136
1137        sout | "";
1138        sout | "~~~~~~~~~~~~~~~~~ Headed List Tests - insert_first ~~~~~~~~~~~~~~~~~~";
1139        sout | "";
1140
1141        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1142        sout | "Test 4-i:  Modifying Freds on MINE ";
1143        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1144        test__insertfirst_two_on_empty__fred_mine();
1145
1146        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1147        sout | "Test 5-i:  Modifying Freds on YOURS ";
1148        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1149        test__insertfirst_two_on_empty__fred_yours();
1150
1151        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1152        sout | "Test 6-i.  Modifying Maries";
1153        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1154        test__insertfirst_two_on_empty__mary();
1155
1156        sout | "";
1157        sout | "~~~~~~~~~~~~~~~~~ Headed List Tests - insert_last ~~~~~~~~~~~~~~~~~~~";
1158        sout | "";
1159
1160        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1161        sout | "Test 4-ii:  Modifying Freds on MINE ";
1162        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1163        test__insertlast_two_on_empty__fred_mine();
1164
1165        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1166        sout | "Test 5-ii:  Modifying Freds on YOURS ";
1167        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1168        test__insertlast_two_on_empty__fred_yours();
1169
1170        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1171        sout | "Test 6-ii.  Modifying Maries";
1172        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1173        test__insertlast_two_on_empty__mary();
1174
1175        sout | "";
1176        sout | "~~~~~~~~~~~ Element ops on Headed List Tests: after, last ~~~~~~~~~~~";
1177        sout | "";
1178
1179        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1180        sout | "Test 7-i.  Modifying Freds on MINE";
1181        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1182        test__insertafter_after_last__fred_mine();
1183
1184        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1185        sout | "Test 8-i.  Modifying Freds on YOURS";
1186        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1187        test__insertafter_after_last__fred_yours();
1188
1189        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~";
1190        sout | "Test 9-i.  Modifying Maries";
1191        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~";
1192        test__insertafter_after_last__mary();
1193
1194        sout | "";
1195        sout | "~~~~~~~~~~ Element ops on Headed List Tests: before, first ~~~~~~~~~~";
1196        sout | "";
1197
1198        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1199        sout | "Test 7-ii.  Modifying Freds on MINE";
1200        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1201        test__insertbefore_before_first__fred_mine();
1202
1203        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1204        sout | "Test 8-ii.  Modifying Freds on YOURS";
1205        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1206        test__insertbefore_before_first__fred_yours();
1207
1208        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1209        sout | "Test 9-ii.  Modifying Maries";
1210        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1211        test__insertbefore_before_first__mary();
1212
1213        sout | "";
1214        sout | "~~~~~~~~~~ Element removal tests on Headless List: mid ~~~~~~~~~~";
1215        sout | "";
1216
1217        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1218        sout | "Test 10-i.  Modifying Freds on MINE";
1219        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1220        test__remove_mid__fred_mine();
1221
1222        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1223        sout | "Test 11-i.  Modifying Freds on YOURS";
1224        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1225        test__remove_mid__fred_yours();
1226
1227        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1228        sout | "Test 12-i.  Modifying Maries";
1229        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1230        test__remove_mid__mary();
1231
1232        sout | "";
1233        sout | "~~~~~~~~~~ Element removal tests on Headless List: at first ~~~~~~~~~~";
1234        sout | "";
1235
1236        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1237        sout | "Test 10-ii.  Modifying Freds on MINE";
1238        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1239        test__remove_at_first__fred_mine();
1240
1241        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1242        sout | "Test 11-ii.  Modifying Freds on YOURS";
1243        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1244        test__remove_at_first__fred_yours();
1245
1246        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1247        sout | "Test 12-ii.  Modifying Maries";
1248        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1249        test__remove_at_first__mary();
1250
1251        sout | "";
1252        sout | "~~~~~~~~~~ Element removal tests on Headless List: at last ~~~~~~~~~~";
1253        sout | "";
1254
1255        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1256        sout | "Test 10-iii.  Modifying Freds on MINE";
1257        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1258        test__remove_at_last__fred_mine();
1259
1260        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1261        sout | "Test 11-iii.  Modifying Freds on YOURS";
1262        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1263        test__remove_at_last__fred_yours();
1264
1265        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1266        sout | "Test 12-iii.  Modifying Maries";
1267        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1268        test__remove_at_last__mary();
1269
1270        sout | "";
1271        sout | "~~~~~~~~~~ Element removal tests on Headed List: at first ~~~~~~~~~~";
1272        sout | "";
1273
1274        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1275        sout | "Test 13-i.  Modifying Freds on MINE";
1276        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1277        test__remove_at_head__fred_mine();
1278
1279        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1280        sout | "Test 14-i.  Modifying Freds on YOURS";
1281        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1282        test__remove_at_head__fred_yours();
1283
1284        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1285        sout | "Test 15-i.  Modifying Maries";
1286        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1287        test__remove_at_head__mary();
1288
1289        sout | "";
1290        sout | "~~~~~~~~~~ Element removal tests on Headed List: at last ~~~~~~~~~~";
1291        sout | "";
1292
1293        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1294        sout | "Test 13-ii.  Modifying Freds on MINE";
1295        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1296        test__remove_at_tail__fred_mine();
1297
1298        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1299        sout | "Test 14-ii.  Modifying Freds on YOURS";
1300        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1301        test__remove_at_tail__fred_yours();
1302
1303        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1304        sout | "Test 15-ii.  Modifying Maries";
1305        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1306        test__remove_at_tail__mary();
1307
1308        sout | "";
1309        sout | "~~~~~~~~~~ Element removal tests on Headed List: of sole ~~~~~~~~~~";
1310        sout | "";
1311
1312        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1313        sout | "Test 13-iii.  Modifying Freds on MINE";
1314        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1315        test__remove_of_sole__fred_mine();
1316
1317        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1318        sout | "Test 14-iii.  Modifying Freds on YOURS";
1319        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1320        test__remove_of_sole__fred_yours();
1321
1322        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1323        sout | "Test 15-iii.  Modifying Maries";
1324        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1325        test__remove_of_sole__mary();
1326
1327        return 0;
1328}
Note: See TracBrowser for help on using the repository browser.