source: tests/list/dlist-insert-remove.cfa @ 4d741e9

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

Strengthened test and fixed a bug on dlist.

The test acceptance criteria are now stricter with white- and black-box checks added. New white-box checking, borrowed from alarm's linked-list verify ensures that headed lists reach last when traversed starting from first, and vice-versa. New black-box checking ensures the link from an ending element to the head sentinel is intact.

The bug was that element insertion at an end of a headed list broke the new black-box criterion. The new white-box criterion was never violated in the current test cases, but early work at integrating this list with the alarm system exercised such a break.

Both checks behind the new test criteria are packaged as a verify routine for user code to invoke.

  • Property mode set to 100644
File size: 37.3 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        verify(validate(lf));
261
262        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
263        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
264
265        insert_first(lf, f2);
266        insert_first(lf, f1);
267
268        verify(validate(lf));
269
270        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
271        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
272}
273
274void test__insertfirst_two_on_empty__fred_yours() {
275
276        fred f1 = {3.14};
277        fred f2 = {0.5};
278
279        dlist(fred_in_yours, fred) lf;
280
281        verify(validate(lf));
282
283        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
284        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
285
286        insert_first(lf, f2);
287        insert_first(lf, f1);
288
289        verify(validate(lf));
290
291        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
292        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
293}
294
295void test__insertfirst_two_on_empty__mary() {
296
297        mary m1 = {3.14};
298        mary m2 = {0.5};
299
300        dlist(mary, mary) lm;
301
302        verify(validate(lm));
303        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
304
305        insert_first(lm, m2);
306        insert_first(lm, m1);
307
308        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
309        verify(validate(lm));
310}
311
312////////////////////////////////////////////////////////////
313//
314// Section 4b.ii
315//
316// Test cases of insert_last (necessarily headed list)
317//
318// Example of call-side user code
319//
320////////////////////////////////////////////////////////////
321
322void test__insertlast_two_on_empty__fred_mine() {
323
324        fred f1 = {3.14};
325        fred f2 = {0.5};
326
327        dlist(fred_in_mine, fred) lf;
328
329        verify(validate(lf));
330
331        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
332        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
333
334        insert_last(lf, f1);
335        insert_last(lf, f2);
336
337        verify(validate(lf));
338
339        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
340        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
341}
342
343void test__insertlast_two_on_empty__fred_yours() {
344
345        fred f1 = {3.14};
346        fred f2 = {0.5};
347
348        dlist(fred_in_yours, fred) lf;
349
350        verify(validate(lf));
351
352        printMyFreddies(f1, f2, 1);     // 3.14; 3.14; 0.5; 0.5
353        printYourFreddies(f1, f2, 1);   // 3.14; 3.14; 0.5; 0.5
354
355        insert_last(lf, f1);
356        insert_last(lf, f2);
357
358        verify(validate(lf));
359
360        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
361        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
362}
363
364void test__insertlast_two_on_empty__mary() {
365
366        mary m1 = {3.14};
367        mary m2 = {0.5};
368
369        dlist(mary, mary) lm;
370
371        verify(validate(lm));
372        printMariatheotokos(m1, m2, 1); // 3.14; 3.14; 0.5; 0.5
373
374        insert_last(lm, m1);
375        insert_last(lm, m2);
376
377        verify(validate(lm));
378        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
379}
380
381////////////////////////////////////////////////////////////
382//
383// Section 4c.i
384//
385// Test cases of insert_after on headed list
386//
387// Example of call-side user code
388//
389////////////////////////////////////////////////////////////
390
391void test__insertafter_after_last__fred_mine() {
392
393        fred f1 = {3.14};
394        fred f2 = {0.5};
395
396        dlist(fred_in_mine, fred) lf;
397
398        assert(& lf`first == 0p);
399        assert(& lf`last == 0p);
400
401        insert_first(lf, f1);
402
403        assert(& lf`first == & f1);
404        assert(& lf`last == & f1);
405
406        verify(validate(lf));
407
408        insert_after(f1`in_mine, f2);
409
410        verify(validate(lf));
411
412        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
413        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
414
415        assert(& lf`first == & f1);
416        assert(& lf`last == & f2);
417}
418
419void test__insertafter_after_last__fred_yours() {
420
421        fred f1 = {3.14};
422        fred f2 = {0.5};
423
424        dlist(fred_in_yours, fred) lf;
425
426        assert(& lf`first == 0p);
427        assert(& lf`last == 0p);
428
429        insert_first(lf, f1);
430
431        assert(& lf`first == & f1);
432        assert(& lf`last == & f1);
433
434        verify(validate(lf));
435
436        insert_after(f1`in_yours, f2);
437
438        verify(validate(lf));
439
440        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
441        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
442
443        assert(& lf`first == & f1);
444        assert(& lf`last == & f2);
445}
446
447void test__insertafter_after_last__mary() {
448
449        mary m1 = {3.14};
450        mary m2 = {0.5};
451
452        dlist(mary, mary) lm;
453
454        assert(& lm`first == 0p);
455        assert(& lm`last == 0p);
456
457        insert_first(lm, m1);
458
459        assert(& lm`first == & m1);
460        assert(& lm`last == & m1);
461
462        verify(validate(lm));
463
464        insert_after(m1, m2);
465
466        verify(validate(lm));
467
468        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
469
470        assert(& lm`first == & m1);
471        assert(& lm`last == & m2);
472}
473
474////////////////////////////////////////////////////////////
475//
476// Section 4c.ii
477//
478// Test cases of insert_before on headed list
479//
480// Example of call-side user code
481//
482////////////////////////////////////////////////////////////
483
484void test__insertbefore_before_first__fred_mine() {
485
486        fred f1 = {3.14};
487        fred f2 = {0.5};
488
489        dlist(fred_in_mine, fred) lf;
490
491        assert(& lf`first == 0p);
492        assert(& lf`last == 0p);
493
494        insert_last(lf, f2);
495
496        assert(& lf`first == & f2);
497        assert(& lf`last == & f2);
498
499        verify(validate(lf));
500
501        insert_before(f2`in_mine, f1);
502
503        verify(validate(lf));
504
505        printMyFreddies(f1, f2, 0);     // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
506        printYourFreddies(f1, f2, 0);   // 3.14; 3.14; 0.5; 0.5 (unmodified)
507
508        assert(& lf`first == & f1);
509        assert(& lf`last == & f2);
510}
511
512void test__insertbefore_before_first__fred_yours() {
513
514        fred f1 = {3.14};
515        fred f2 = {0.5};
516
517        dlist(fred_in_yours, fred) lf;
518
519        assert(& lf`first == 0p);
520        assert(& lf`last == 0p);
521
522        insert_last(lf, f2);
523
524        assert(& lf`first == & f2);
525        assert(& lf`last == & f2);
526
527        verify(validate(lf));
528
529        insert_before(f2`in_yours, f1);
530
531        verify(validate(lf));
532
533        printMyFreddies(f1, f2, 0);     // 3.14; 3.14; 0.5; 0.5 (unmodified)
534        printYourFreddies(f1, f2, 0);   // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
535
536        assert(& lf`first == & f1);
537        assert(& lf`last == & f2);
538}
539
540void test__insertbefore_before_first__mary() {
541
542        mary m1 = {3.14};
543        mary m2 = {0.5};
544
545        dlist(mary, mary) lm;
546
547        assert(& lm`first == 0p);
548        assert(& lm`last == 0p);
549
550        insert_last(lm, m2);
551
552        assert(& lm`first == & m2);
553        assert(& lm`last == & m2);
554
555        verify(validate(lm));
556
557        insert_before(m2, m1);
558
559        verify(validate(lm));
560
561        printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
562
563        assert(& lm`first == & m1);
564        assert(& lm`last == & m2);
565}
566
567////////////////////////////////////////////////////////////
568//
569// Section 4d.i
570//
571// Test cases of remove, from middle of headless list
572//
573// Example of call-side user code
574//
575////////////////////////////////////////////////////////////
576
577// These tests, in the fred cases, set up the my/your lists initially identical,
578// act on one list, and expect the other unaffected.
579
580void test__remove_mid__fred_mine() {
581
582        fred f1 = {1.7};
583        fred f2 = {2.7};
584        fred f3 = {3.7};
585
586        insert_after(f1`in_mine, f2);
587        insert_after(f2`in_mine, f3);
588
589        insert_after(f1`in_yours, f2);
590        insert_after(f2`in_yours, f3);
591
592        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
593        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
594
595        remove(f2`in_mine);
596
597        printMyFreddies(f1, f3, 0);     // 1.7, 3.7;       1.7;  3.7;  3.7, 1.7      (modified)
598        printYourFreddies(f1, f3, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
599
600        // observe f2 is now solo in mine; in yours, it was just traversed
601        printMyFreddies(f2, *0p, 0);    // 2.7; 2.7; ;
602
603        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
604        assert(f2.$links_mine.next.is_terminator == false);
605        assert(f2.$links_mine.prev.is_terminator == false);
606}
607
608void test__remove_mid__fred_yours() {
609
610        fred f1 = {1.7};
611        fred f2 = {2.7};
612        fred f3 = {3.7};
613
614        insert_after(f1`in_mine, f2);
615        insert_after(f2`in_mine, f3);
616
617        insert_after(f1`in_yours, f2);
618        insert_after(f2`in_yours, f3);
619
620        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
621        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
622
623        remove(f2`in_yours);
624
625        printMyFreddies(f1, f3, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
626        printYourFreddies(f1, f3, 0);   // 1.7, 3.7;       1.7;  3.7;  3.7, 1.7      (modified)
627
628        // observe f2 is now solo in yours; in mine, it was just traversed
629        printYourFreddies(f2, *0p, 0);    // 2.7; 2.7; ;
630
631        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
632        assert(f2.$links_yours.next.is_terminator == false);
633        assert(f2.$links_yours.prev.is_terminator == false);
634}
635
636void test__remove_mid__mary() {
637
638        mary m1 = {1.7};
639        mary m2 = {2.7};
640        mary m3 = {3.7};
641
642        insert_after(m1, m2);
643        insert_after(m2, m3);
644
645        printMariatheotokos(m1, m3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
646
647        remove(m2);
648
649        printMariatheotokos(m1, m3, 0);     // 1.7, 3.7;  1.7;  3.7;  3.7, 1.7 (modified)
650
651        // observe m2 is now solo
652        printMariatheotokos(m2, *0p, 0);    // 2.7; 2.7; ;
653
654        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
655        assert(m2.$links.next.is_terminator == false);
656        assert(m2.$links.prev.is_terminator == false);
657}
658
659////////////////////////////////////////////////////////////
660//
661// Section 4d.ii
662//
663// Test cases of remove, from first position of headless list
664//
665// Example of call-side user code
666//
667////////////////////////////////////////////////////////////
668
669// TODO: validate headless semantic: remove of a neighbourless element is valid and no-op
670
671void test__remove_at_first__fred_mine() {
672
673        fred f1 = {1.7};
674        fred f2 = {2.7};
675        fred f3 = {3.7};
676
677        insert_after(f1`in_mine, f2);
678        insert_after(f2`in_mine, f3);
679
680        insert_after(f1`in_yours, f2);
681        insert_after(f2`in_yours, f3);
682
683        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
684        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
685
686        remove(f1`in_mine);
687
688        printMyFreddies(f2, f3, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
689        printYourFreddies(f1, f3, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
690
691        // observe f1 is now solo in mine; in yours, it was just traversed
692        printMyFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
693
694        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
695        assert(f1.$links_mine.next.is_terminator == false);
696        assert(f1.$links_mine.prev.is_terminator == false);
697}
698
699void test__remove_at_first__fred_yours() {
700
701        fred f1 = {1.7};
702        fred f2 = {2.7};
703        fred f3 = {3.7};
704
705        insert_after(f1`in_mine, f2);
706        insert_after(f2`in_mine, f3);
707
708        insert_after(f1`in_yours, f2);
709        insert_after(f2`in_yours, f3);
710
711        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
712        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
713
714        remove(f1`in_yours);
715
716        printMyFreddies(f1, f3, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
717        printYourFreddies(f2, f3, 0);   // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
718
719        // observe f1 is now solo in yours; in mine, it was just traversed
720        printYourFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
721
722        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
723        assert(f1.$links_yours.next.is_terminator == false);
724        assert(f1.$links_yours.prev.is_terminator == false);
725}
726
727void test__remove_at_first__mary() {
728
729        mary m1 = {1.7};
730        mary m2 = {2.7};
731        mary m3 = {3.7};
732
733        insert_after(m1, m2);
734        insert_after(m2, m3);
735
736        printMariatheotokos(m1, m3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
737
738        remove(m1);
739
740        printMariatheotokos(m2, m3, 0);     // 2.7, 3.7;  2.7;  3.7;  3.7, 2.7 (modified)
741
742        // observe m2 is now solo
743        printMariatheotokos(m1, *0p, 0);    // 1.7; 1.7; ;
744
745        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
746        assert(m1.$links.next.is_terminator == false);
747        assert(m1.$links.prev.is_terminator == false);
748}
749
750////////////////////////////////////////////////////////////
751//
752// Section 4d.iii
753//
754// Test cases of remove, from last position of headless list
755//
756// Example of call-side user code
757//
758////////////////////////////////////////////////////////////
759
760void test__remove_at_last__fred_mine() {
761
762        fred f1 = {1.7};
763        fred f2 = {2.7};
764        fred f3 = {3.7};
765
766        insert_after(f1`in_mine, f2);
767        insert_after(f2`in_mine, f3);
768
769        insert_after(f1`in_yours, f2);
770        insert_after(f2`in_yours, f3);
771
772        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
773        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
774
775        remove(f3`in_mine);
776
777        printMyFreddies(f1, f2, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
778        printYourFreddies(f1, f3, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
779
780        // observe f3 is now solo in mine; in yours, it was just traversed
781        printMyFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
782
783        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
784        assert(f3.$links_mine.next.is_terminator == false);
785        assert(f3.$links_mine.prev.is_terminator == false);
786}
787
788void test__remove_at_last__fred_yours() {
789
790        fred f1 = {1.7};
791        fred f2 = {2.7};
792        fred f3 = {3.7};
793
794        insert_after(f1`in_mine, f2);
795        insert_after(f2`in_mine, f3);
796
797        insert_after(f1`in_yours, f2);
798        insert_after(f2`in_yours, f3);
799
800        printMyFreddies(f1, f3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
801        printYourFreddies(f1, f3, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
802
803        remove(f3`in_yours);
804
805        printMyFreddies(f1, f3, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
806        printYourFreddies(f1, f2, 0);   // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
807
808        // observe f3 is now solo in yours; in mine, it was just traversed
809        printYourFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
810
811        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
812        assert(f3.$links_yours.next.is_terminator == false);
813        assert(f3.$links_yours.prev.is_terminator == false);
814}
815
816void test__remove_at_last__mary() {
817
818        mary m1 = {1.7};
819        mary m2 = {2.7};
820        mary m3 = {3.7};
821
822        insert_after(m1, m2);
823        insert_after(m2, m3);
824
825        printMariatheotokos(m1, m3, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
826
827        remove(m3);
828
829        printMariatheotokos(m1, m2, 0);     // 1.7, 2.7;  1.7;  2.7;  2.7, 1.7 (modified)
830
831        // observe m3 is now solo
832        printMariatheotokos(m3, *0p, 0);    // 3.7; 3.7; ;
833
834        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
835        assert(m1.$links.next.is_terminator == false);
836        assert(m1.$links.prev.is_terminator == false);
837}
838
839////////////////////////////////////////////////////////////
840//
841// Section 4e.i
842//
843// Test cases of remove, from first position of headed list
844//
845// Example of call-side user code
846//
847////////////////////////////////////////////////////////////
848
849void test__remove_at_head__fred_mine() {
850
851        fred f1 = {1.7};
852        fred f2 = {2.7};
853        fred f3 = {3.7};
854
855        dlist(fred_in_mine, fred) flm;
856        insert_last(flm, f1);
857        insert_last(flm, f2);
858        insert_last(flm, f3);
859
860        dlist(fred_in_yours, fred) fly;
861        insert_last(fly, f1);
862        insert_last(fly, f2);
863        insert_last(fly, f3);
864
865        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
866        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
867
868        verify(validate(fly));
869        verify(validate(flm));
870
871        remove(f1`in_mine);
872
873        verify(validate(fly));
874        verify(validate(flm));
875
876        printMyFreddies(flm`first, flm`last, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
877        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
878
879        // observe f1 is now solo in mine; in yours, it was just traversed
880        printMyFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
881
882        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
883        assert(f1.$links_mine.next.is_terminator == false);
884        assert(f1.$links_mine.prev.is_terminator == false);
885}
886
887void test__remove_at_head__fred_yours() {
888
889        fred f1 = {1.7};
890        fred f2 = {2.7};
891        fred f3 = {3.7};
892
893        dlist(fred_in_mine, fred) flm;
894        insert_last(flm, f1);
895        insert_last(flm, f2);
896        insert_last(flm, f3);
897
898        dlist(fred_in_yours, fred) fly;
899        insert_last(fly, f1);
900        insert_last(fly, f2);
901        insert_last(fly, f3);
902
903        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
904        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
905
906        verify(validate(fly));
907        verify(validate(flm));
908
909        remove(f1`in_yours);
910
911        verify(validate(fly));
912        verify(validate(flm));
913
914        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
915        printYourFreddies(fly`first, fly`last, 0);   // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
916
917        // observe f1 is now solo in yours; in mine, it was just traversed
918        printYourFreddies(f1, *0p, 0);    // 1.7; 1.7; ;
919
920        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
921        assert(f1.$links_yours.next.is_terminator == false);
922        assert(f1.$links_yours.prev.is_terminator == false);
923}
924
925void test__remove_at_head__mary() {
926
927        mary m1 = {1.7};
928        mary m2 = {2.7};
929        mary m3 = {3.7};
930
931        dlist(mary, mary) ml;
932        insert_last(ml, m1);
933        insert_last(ml, m2);
934        insert_last(ml, m3);
935
936        printMariatheotokos(ml`first, ml`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
937
938        verify(validate(ml));
939
940        remove(m1);
941
942        verify(validate(ml));
943
944        printMariatheotokos(ml`first, ml`last, 0);     // 2.7, 3.7;       2.7;  3.7;  3.7, 2.7      (modified)
945
946        // observe m1 is now solo
947        printMariatheotokos(m1, *0p, 0);               // 1.7; 1.7; ;
948
949        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
950        assert(m1.$links.next.is_terminator == false);
951        assert(m1.$links.prev.is_terminator == false);
952}
953
954////////////////////////////////////////////////////////////
955//
956// Section 4e.ii
957//
958// Test cases of remove, from last position of headed list
959//
960// Example of call-side user code
961//
962////////////////////////////////////////////////////////////
963
964void test__remove_at_tail__fred_mine() {
965
966        fred f1 = {1.7};
967        fred f2 = {2.7};
968        fred f3 = {3.7};
969
970        dlist(fred_in_mine, fred) flm;
971        insert_last(flm, f1);
972        insert_last(flm, f2);
973        insert_last(flm, f3);
974
975        dlist(fred_in_yours, fred) fly;
976        insert_last(fly, f1);
977        insert_last(fly, f2);
978        insert_last(fly, f3);
979
980        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
981        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
982
983        verify(validate(fly));
984        verify(validate(flm));
985
986        remove(f3`in_mine);
987
988        verify(validate(fly));
989        verify(validate(flm));
990
991        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
992        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
993
994        // observe f3 is now solo in mine; in yours, it was just traversed
995        printMyFreddies(f3, *0p, 0);    // 3.7; 3.7; ;
996
997        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
998        assert(f3.$links_mine.next.is_terminator == false);
999        assert(f3.$links_mine.prev.is_terminator == false);
1000}
1001
1002void test__remove_at_tail__fred_yours() {
1003
1004        fred f1 = {1.7};
1005        fred f2 = {2.7};
1006        fred f3 = {3.7};
1007
1008        dlist(fred_in_mine, fred) flm;
1009        insert_last(flm, f1);
1010        insert_last(flm, f2);
1011        insert_last(flm, f3);
1012
1013        dlist(fred_in_yours, fred) fly;
1014        insert_last(fly, f1);
1015        insert_last(fly, f2);
1016        insert_last(fly, f3);
1017
1018        printMyFreddies(flm`first, flm`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1019        printYourFreddies(fly`first, fly`last, 1);   // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1020
1021        verify(validate(fly));
1022        verify(validate(flm));
1023
1024        remove(f3`in_yours);
1025
1026        verify(validate(fly));
1027        verify(validate(flm));
1028
1029        printMyFreddies(flm`first, flm`last, 0);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7 (unmodified)
1030        printYourFreddies(fly`first, fly`last, 0);   // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
1031
1032        // observe f3 is now solo in yours; in mine, it was just traversed
1033        printYourFreddies(f3, *0p, 0);               // 3.7; 3.7; ;
1034
1035        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1036        assert(f3.$links_yours.next.is_terminator == false);
1037        assert(f3.$links_yours.prev.is_terminator == false);
1038}
1039
1040void test__remove_at_tail__mary() {
1041
1042        mary m1 = {1.7};
1043        mary m2 = {2.7};
1044        mary m3 = {3.7};
1045
1046        dlist(mary, mary) ml;
1047        insert_last(ml, m1);
1048        insert_last(ml, m2);
1049        insert_last(ml, m3);
1050
1051        printMariatheotokos(ml`first, ml`last, 1);     // 1.7, 2.7, 3.7;  1.7;  3.7;  3.7, 2.7, 1.7
1052
1053        verify(validate(ml));
1054
1055        remove(m3);
1056
1057        verify(validate(ml));
1058
1059        printMariatheotokos(ml`first, ml`last, 0);     // 1.7, 2.7;       1.7;  2.7;  2.7, 1.7      (modified)
1060
1061        // observe m3 is now solo
1062        printMariatheotokos(m3, *0p, 0);               //3.7; 3.7; ;
1063
1064        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1065        assert(m3.$links.next.is_terminator == false);
1066        assert(m3.$links.prev.is_terminator == false);
1067}
1068
1069////////////////////////////////////////////////////////////
1070//
1071// Section 4e.iii
1072//
1073// Test cases of remove, of sole element of headed list
1074//
1075// Example of call-side user code
1076//
1077////////////////////////////////////////////////////////////
1078
1079void test__remove_of_sole__fred_mine() {
1080
1081        fred f = {0.7};
1082
1083        dlist(fred_in_mine, fred) flm;
1084        insert_last(flm, f);
1085
1086        dlist(fred_in_yours, fred) fly;
1087        insert_last(fly, f);
1088
1089        printMyFreddies(flm`first, flm`last, 1);     // 0.7; 0.7; 0.7; 0.7
1090        printYourFreddies(fly`first, fly`last, 1);   // 0.7; 0.7; 0.7; 0.7
1091
1092        verify(validate(fly));
1093        verify(validate(flm));
1094
1095        remove(f`in_mine);
1096
1097        verify(validate(fly));
1098        verify(validate(flm));
1099
1100        assert(& flm`first == 0p);
1101        assert(& flm`last  == 0p);
1102
1103        printYourFreddies(fly`first, fly`last, 0);   // 0.7; 0.7; 0.7; 0.7 (unmodified)
1104
1105        // observe f is solo in mine (now unlisted); in yours, it was just traversed
1106        printMyFreddies(f, *0p, 0);    // 0.7; 0.7; ;
1107
1108        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1109        assert(f.$links_mine.next.is_terminator == false);
1110        assert(f.$links_mine.prev.is_terminator == false);
1111
1112        insert_last(flm, f);
1113        verify(validate(fly));
1114        verify(validate(flm));
1115        printMyFreddies(flm`first, flm`last, 0);     // 0.7; 0.7; 0.7; 0.7
1116}
1117
1118void test__remove_of_sole__fred_yours() {
1119
1120        fred f = {0.7};
1121
1122        dlist(fred_in_mine, fred) flm;
1123        insert_last(flm, f);
1124
1125        dlist(fred_in_yours, fred) fly;
1126        insert_last(fly, f);
1127
1128        printMyFreddies(flm`first, flm`last, 1);     // 0.7; 0.7; 0.7; 0.7
1129        printYourFreddies(fly`first, fly`last, 1);   // 0.7; 0.7; 0.7; 0.7
1130
1131        verify(validate(fly));
1132        verify(validate(flm));
1133
1134        remove(f`in_yours);
1135
1136        verify(validate(fly));
1137        verify(validate(flm));
1138
1139        assert(& fly`first == 0p);
1140        assert(& fly`last  == 0p);
1141
1142        printYourFreddies(flm`first, flm`last, 0);   // 0.7; 0.7; 0.7; 0.7 (unmodified)
1143
1144        // observe f is solo in yours (now unlisted); in mine, it was just traversed
1145        printYourFreddies(f, *0p, 0);    // 0.7; 0.7; ;
1146
1147        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1148        assert(f.$links_yours.next.is_terminator == false);
1149        assert(f.$links_yours.prev.is_terminator == false);
1150
1151        insert_last(fly, f);
1152        verify(validate(fly));
1153        verify(validate(flm));
1154        printYourFreddies(fly`first, fly`last, 0);     // 0.7; 0.7; 0.7; 0.7
1155}
1156
1157void test__remove_of_sole__mary() {
1158
1159        mary m = {0.7};
1160
1161        dlist(mary, mary) ml;
1162        insert_last(ml, m);
1163
1164        printMariatheotokos(ml`first, ml`last, 1);     // 0.7; 0.7; 0.7; 0.7
1165
1166        verify(validate(ml));
1167
1168        remove(m);
1169
1170        verify(validate(ml));
1171
1172        assert(& ml`first == 0p);
1173        assert(& ml`last  == 0p);
1174
1175        // observe f is solo in mine (now unlisted); in yours, it was just traversed
1176        printMariatheotokos(m, *0p, 0);    // 0.7; 0.7; ;
1177
1178        // TODO: decide on appropriate ovservable outcome (is_listed?) and its itended semantics
1179        assert(m.$links.next.is_terminator == false);
1180        assert(m.$links.prev.is_terminator == false);
1181
1182        insert_last(ml, m);
1183        verify(validate(ml));
1184        printMariatheotokos(ml`first, ml`last, 0);     // 0.7; 0.7; 0.7; 0.7
1185}
1186
1187////////////////////////////////////////////////////////////
1188//
1189// Section 5
1190//
1191// Simple driver with the inter-scario printing
1192//
1193////////////////////////////////////////////////////////////
1194
1195int main() {
1196
1197        sout | "~~~~~~~~~~~~~~~~~ Headless List Tests - insert_after ~~~~~~~~~~~~~~~~";
1198        sout | "";
1199
1200        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1201        sout | "Test 1-i:  Modifying Freds on MINE ";
1202        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1203        test__insertafter_singleton_on_singleton__fred_mine();
1204
1205        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1206        sout | "Test 2-i.  Modifying Freds on YOURS";
1207        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1208        test__insertafter_singleton_on_singleton__fred_yours();
1209
1210        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1211        sout | "Test 3-i.  Modifying Maries";
1212        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1213        test__insertafter_singleton_on_singleton__mary();
1214
1215        sout | "";
1216        sout | "~~~~~~~~~~~~~~~~ Headless List Tests - insert_before ~~~~~~~~~~~~~~~~";
1217        sout | "";
1218
1219        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1220        sout | "Test 1-ii:  Modifying Freds on MINE ";
1221        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1222        test__insertbefore_singleton_on_singleton__fred_mine();
1223
1224        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1225        sout | "Test 2-ii.  Modifying Freds on YOURS";
1226        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1227        test__insertbefore_singleton_on_singleton__fred_yours();
1228
1229        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1230        sout | "Test 3-ii.  Modifying Maries";
1231        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1232        test__insertbefore_singleton_on_singleton__mary();
1233
1234        sout | "";
1235        sout | "~~~~~~~~~~~~~~~~~ Headed List Tests - insert_first ~~~~~~~~~~~~~~~~~~";
1236        sout | "";
1237
1238        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1239        sout | "Test 4-i:  Modifying Freds on MINE ";
1240        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1241        test__insertfirst_two_on_empty__fred_mine();
1242
1243        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1244        sout | "Test 5-i:  Modifying Freds on YOURS ";
1245        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1246        test__insertfirst_two_on_empty__fred_yours();
1247
1248        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1249        sout | "Test 6-i.  Modifying Maries";
1250        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1251        test__insertfirst_two_on_empty__mary();
1252
1253        sout | "";
1254        sout | "~~~~~~~~~~~~~~~~~ Headed List Tests - insert_last ~~~~~~~~~~~~~~~~~~~";
1255        sout | "";
1256
1257        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1258        sout | "Test 4-ii:  Modifying Freds on MINE ";
1259        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1260        test__insertlast_two_on_empty__fred_mine();
1261
1262        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1263        sout | "Test 5-ii:  Modifying Freds on YOURS ";
1264        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1265        test__insertlast_two_on_empty__fred_yours();
1266
1267        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1268        sout | "Test 6-ii.  Modifying Maries";
1269        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1270        test__insertlast_two_on_empty__mary();
1271
1272        sout | "";
1273        sout | "~~~~~~~~~~~ Element ops on Headed List Tests: after, last ~~~~~~~~~~~";
1274        sout | "";
1275
1276        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1277        sout | "Test 7-i.  Modifying Freds on MINE";
1278        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1279        test__insertafter_after_last__fred_mine();
1280
1281        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1282        sout | "Test 8-i.  Modifying Freds on YOURS";
1283        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1284        test__insertafter_after_last__fred_yours();
1285
1286        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~";
1287        sout | "Test 9-i.  Modifying Maries";
1288        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~";
1289        test__insertafter_after_last__mary();
1290
1291        sout | "";
1292        sout | "~~~~~~~~~~ Element ops on Headed List Tests: before, first ~~~~~~~~~~";
1293        sout | "";
1294
1295        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1296        sout | "Test 7-ii.  Modifying Freds on MINE";
1297        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1298        test__insertbefore_before_first__fred_mine();
1299
1300        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1301        sout | "Test 8-ii.  Modifying Freds on YOURS";
1302        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1303        test__insertbefore_before_first__fred_yours();
1304
1305        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1306        sout | "Test 9-ii.  Modifying Maries";
1307        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1308        test__insertbefore_before_first__mary();
1309
1310        sout | "";
1311        sout | "~~~~~~~~~~ Element removal tests on Headless List: mid ~~~~~~~~~~";
1312        sout | "";
1313
1314        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1315        sout | "Test 10-i.  Modifying Freds on MINE";
1316        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1317        test__remove_mid__fred_mine();
1318
1319        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1320        sout | "Test 11-i.  Modifying Freds on YOURS";
1321        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1322        test__remove_mid__fred_yours();
1323
1324        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1325        sout | "Test 12-i.  Modifying Maries";
1326        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1327        test__remove_mid__mary();
1328
1329        sout | "";
1330        sout | "~~~~~~~~~~ Element removal tests on Headless List: at first ~~~~~~~~~~";
1331        sout | "";
1332
1333        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1334        sout | "Test 10-ii.  Modifying Freds on MINE";
1335        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1336        test__remove_at_first__fred_mine();
1337
1338        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1339        sout | "Test 11-ii.  Modifying Freds on YOURS";
1340        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1341        test__remove_at_first__fred_yours();
1342
1343        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1344        sout | "Test 12-ii.  Modifying Maries";
1345        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1346        test__remove_at_first__mary();
1347
1348        sout | "";
1349        sout | "~~~~~~~~~~ Element removal tests on Headless List: at last ~~~~~~~~~~";
1350        sout | "";
1351
1352        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1353        sout | "Test 10-iii.  Modifying Freds on MINE";
1354        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1355        test__remove_at_last__fred_mine();
1356
1357        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1358        sout | "Test 11-iii.  Modifying Freds on YOURS";
1359        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1360        test__remove_at_last__fred_yours();
1361
1362        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1363        sout | "Test 12-iii.  Modifying Maries";
1364        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1365        test__remove_at_last__mary();
1366
1367        sout | "";
1368        sout | "~~~~~~~~~~ Element removal tests on Headed List: at first ~~~~~~~~~~";
1369        sout | "";
1370
1371        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1372        sout | "Test 13-i.  Modifying Freds on MINE";
1373        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1374        test__remove_at_head__fred_mine();
1375
1376        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1377        sout | "Test 14-i.  Modifying Freds on YOURS";
1378        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1379        test__remove_at_head__fred_yours();
1380
1381        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1382        sout | "Test 15-i.  Modifying Maries";
1383        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1384        test__remove_at_head__mary();
1385
1386        sout | "";
1387        sout | "~~~~~~~~~~ Element removal tests on Headed List: at last ~~~~~~~~~~";
1388        sout | "";
1389
1390        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1391        sout | "Test 13-ii.  Modifying Freds on MINE";
1392        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1393        test__remove_at_tail__fred_mine();
1394
1395        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1396        sout | "Test 14-ii.  Modifying Freds on YOURS";
1397        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1398        test__remove_at_tail__fred_yours();
1399
1400        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1401        sout | "Test 15-ii.  Modifying Maries";
1402        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1403        test__remove_at_tail__mary();
1404
1405        sout | "";
1406        sout | "~~~~~~~~~~ Element removal tests on Headed List: of sole ~~~~~~~~~~";
1407        sout | "";
1408
1409        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1410        sout | "Test 13-iii.  Modifying Freds on MINE";
1411        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1412        test__remove_of_sole__fred_mine();
1413
1414        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1415        sout | "Test 14-iii.  Modifying Freds on YOURS";
1416        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1417        test__remove_of_sole__fred_yours();
1418
1419        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1420        sout | "Test 15-iii.  Modifying Maries";
1421        sout | "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
1422        test__remove_of_sole__mary();
1423
1424        return 0;
1425}
Note: See TracBrowser for help on using the repository browser.