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

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since c4f8170 was c2794b2, checked in by Michael Brooks <mlbrooks@…>, 3 years ago

Adding isListed accessor function to new linked list.

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