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

stuck-waitfor-destruct
Last change on this file since 2b3ebe5 was 8f448e0, checked in by Michael Brooks <mlbrooks@…>, 4 months ago

Make dlist2 pass the original dlist test. Now, there is one common test for both.

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