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

stuck-waitfor-destruct
Last change on this file since 1b4e5a8 was 75f888e7, checked in by Michael Brooks <mlbrooks@…>, 4 months ago

Replace dlist test's sout with printf, to enable testing non-libcfa draft implementations

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