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

Last change on this file since 81ab5eb was 81ab5eb, checked in by Peter A. Buhr <pabuhr@…>, 5 days ago

2nd attempt at harmonizing isOp functions, e.g., isEmpty, to C/C++ form empty

  • Property mode set to 100644
File size: 51.4 KB
RevLine 
[8f448e0]1#ifdef __TEMP_DLIST_V2__
2#include <collections/list2.hfa>
3#else
[55b060d]4#include <collections/list.hfa>
[8f448e0]5#endif
[6091b88a]6#include <assert.h>
[75f888e7]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.
[6091b88a]11
[75f888e7]12
13// Former Section 1: replaced by above include list.hfa
[6091b88a]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;
[69914cbc]29 inline struct mine { inline dlink(fred); };
30 inline struct yours { inline dlink(fred); };
[6091b88a]31};
[69914cbc]32P9_EMBEDDED(fred, fred.mine)
33P9_EMBEDDED(fred, fred.yours)
34P9_EMBEDDED(fred.mine, dlink(fred))
35P9_EMBEDDED(fred.yours, dlink(fred))
[6091b88a]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;
[69914cbc]45 inline dlink(mary);
[6091b88a]46};
47
[69914cbc]48P9_EMBEDDED(mary, dlink(mary))
[6091b88a]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
[69914cbc]65void printMyFredsFwd(fred & f) {
66 with( DLINK_VIA( fred, fred.mine ) )
67 do {
[75f888e7]68 printf( "%g\n", f.adatum );
[6b33e89]69 } while (advance( f ));
[6091b88a]70}
71
[69914cbc]72void printMyFredsRev(fred & f) {
73 with( DLINK_VIA( fred, fred.mine ) )
74 do {
[75f888e7]75 printf( "%g\n", f.adatum );
[6b33e89]76 } while (recede( f ));
[6091b88a]77}
78
[69914cbc]79
[6091b88a]80void printMyFreddies(fred &f1, fred &f2, int isBefore) {
81 if (isBefore) {
[75f888e7]82 printf( "==== fred by MINE before \n" );
[6091b88a]83 } else {
[75f888e7]84 printf( "==== fred by MINE after \n" );
[6091b88a]85 }
[69914cbc]86 if (&f1) {
[75f888e7]87 printMyFredsFwd(f1); printf( "-\n" );
88 printMyFredsRev(f1); printf( "-\n" );
[69914cbc]89 } else {
[75f888e7]90 printf( "-\n" ); printf( "-\n" );
[69914cbc]91 }
92 if (&f2) {
[75f888e7]93 printMyFredsFwd(f2); printf( "-\n" );
94 printMyFredsRev(f2); printf( "-\n" );
[69914cbc]95 } else {
[75f888e7]96 printf( "-\n" ); printf( "-\n" );
[69914cbc]97 }
[6091b88a]98}
99
[69914cbc]100void printYourFredsFwd(fred & f) {
101 with( DLINK_VIA( fred, fred.yours ) )
102 do {
[75f888e7]103 printf( "%g\n", f.adatum );
[6b33e89]104 } while (advance( f ));
[6091b88a]105}
106
[69914cbc]107void printYourFredsRev(fred & f) {
108 with( DLINK_VIA( fred, fred.yours ) )
109 do {
[75f888e7]110 printf( "%g\n", f.adatum );
[6b33e89]111 } while (recede( f ));
[6091b88a]112}
113
114void printYourFreddies(fred &f1, fred &f2, int isBefore) {
115 if (isBefore) {
[75f888e7]116 printf( "==== fred by YOURS before \n" );
[6091b88a]117 } else {
[75f888e7]118 printf( "==== fred by YOURS after \n" );
[6091b88a]119 }
[69914cbc]120 if (&f1) {
[75f888e7]121 printYourFredsFwd(f1); printf( "-\n" );
122 printYourFredsRev(f1); printf( "-\n" );
[69914cbc]123 } else {
[75f888e7]124 printf( "-\n" ); printf( "-\n" );
[69914cbc]125 }
126 if (&f2) {
[75f888e7]127 printYourFredsFwd(f2); printf( "-\n" );
128 printYourFredsRev(f2); printf( "-\n" );
[69914cbc]129 } else {
[75f888e7]130 printf( "-\n" ); printf( "-\n" );
[69914cbc]131 }
[6091b88a]132}
133
134void printMariesFwd(mary &m) {
[69914cbc]135 do {
[75f888e7]136 printf( "%g\n", m.anotherdatum );
[6b33e89]137 } while (advance( m ));
[6091b88a]138}
139
140void printMariesRev(mary &m) {
[69914cbc]141 do {
[75f888e7]142 printf( "%g\n", m.anotherdatum );
[6b33e89]143 } while (recede( m ));
[6091b88a]144}
145
146void printMariatheotokos(mary &m1, mary &m2, int isBefore) {
147 if (isBefore) {
[75f888e7]148 printf( "==== mary before \n" );
[6091b88a]149 } else {
[75f888e7]150 printf( "==== mary after \n" );
[6091b88a]151 }
[69914cbc]152 if (&m1) {
[75f888e7]153 printMariesFwd(m1); printf( "-\n" );
154 printMariesRev(m1); printf( "-\n" );
[69914cbc]155 } else {
[75f888e7]156 printf( "-\n" ); printf( "-\n" );
[69914cbc]157 }
158 if (&m2) {
[75f888e7]159 printMariesFwd(m2); printf( "-\n" );
160 printMariesRev(m2); printf( "-\n" );
[69914cbc]161 } else {
[75f888e7]162 printf( "-\n" ); printf( "-\n" );
[69914cbc]163 }
[6091b88a]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
[69914cbc]188#if 0
[6091b88a]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
[69914cbc]196 diref(fred, fred.mine) f1_mine = f1`from;
197 insert_after(f1_mine, f2);
[6091b88a]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
[69914cbc]210 diref(fred, fred.yours) f1_yours = f1`from;
211 insert_after(f1_yours, f2);
[6091b88a]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
[69914cbc]245 diref(fred, fred.mine) f2_mine = f2`from;
246 insert_before(f2_mine, f1);
[6091b88a]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
[69914cbc]259 diref(fred, fred.yours) f2_yours = f2`from;
260 insert_before(f2_yours, f1);
[6091b88a]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}
[69914cbc]276#endif
[6091b88a]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
[69914cbc]294 dlist(fred, fred.mine) lf;
[6091b88a]295
[4d741e9]296 verify(validate(lf));
297
[6091b88a]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
[4d741e9]304 verify(validate(lf));
305
[6091b88a]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
[69914cbc]315 dlist(fred, fred.yours) lf;
[6091b88a]316
[4d741e9]317 verify(validate(lf));
318
[6091b88a]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
[4d741e9]325 verify(validate(lf));
326
[6091b88a]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
[69914cbc]335 dlist(mary) lm;
[6091b88a]336
[4d741e9]337 verify(validate(lm));
[6091b88a]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)
[4d741e9]344 verify(validate(lm));
[6091b88a]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
[69914cbc]362 dlist(fred, fred.mine) lf;
[6091b88a]363
[4d741e9]364 verify(validate(lf));
365
[6091b88a]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
[4d741e9]372 verify(validate(lf));
373
[6091b88a]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
[69914cbc]383 dlist(fred, fred.yours) lf;
[6091b88a]384
[4d741e9]385 verify(validate(lf));
386
[6091b88a]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
[4d741e9]393 verify(validate(lf));
394
[6091b88a]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
[69914cbc]404 dlist(mary) lm;
[6091b88a]405
[4d741e9]406 verify(validate(lm));
[6091b88a]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
[4d741e9]412 verify(validate(lm));
[6091b88a]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
[69914cbc]431 dlist(fred, fred.mine) lf;
[6091b88a]432
[6b33e89]433 assert( &first( lf ) == 0p );
434 assert( &last( lf ) == 0p );
[6091b88a]435
436 insert_first(lf, f1);
437
[6b33e89]438 assert( &first( lf ) == &f1 );
439 assert( &last( lf ) == &f1 );
[6091b88a]440
[4d741e9]441 verify(validate(lf));
442
[69914cbc]443 with ( DLINK_VIA(fred, fred.mine) ) insert_after(f1, f2);
[6091b88a]444
[4d741e9]445 verify(validate(lf));
446
[6091b88a]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
[6b33e89]450 assert( &first( lf ) == &f1 );
451 assert( &last( lf ) == &f2 );
[6091b88a]452}
453
454void test__insertafter_after_last__fred_yours() {
455
456 fred f1 = {3.14};
457 fred f2 = {0.5};
458
[69914cbc]459 dlist(fred, fred.yours) lf;
[6091b88a]460
[6b33e89]461 assert( &first( lf ) == 0p );
462 assert( &last( lf ) == 0p );
[6091b88a]463
464 insert_first(lf, f1);
465
[6b33e89]466 assert( &first( lf ) == & f1 );
467 assert( &last( lf ) == & f1 );
[6091b88a]468
[4d741e9]469 verify(validate(lf));
470
[69914cbc]471 with ( DLINK_VIA(fred, fred.yours) ) insert_after(f1, f2);
[6091b88a]472
[4d741e9]473 verify(validate(lf));
474
[6091b88a]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
[6b33e89]478 assert( &first( lf ) == & f1 );
479 assert( &last( lf ) == & f2 );
[6091b88a]480}
481
482void test__insertafter_after_last__mary() {
483
484 mary m1 = {3.14};
485 mary m2 = {0.5};
486
[69914cbc]487 dlist(mary) lm;
[6091b88a]488
[6b33e89]489 assert( &first( lm ) == 0p );
490 assert( &last( lm ) == 0p );
[6091b88a]491
492 insert_first(lm, m1);
493
[6b33e89]494 assert( &first( lm ) == & m1 );
495 assert( &last( lm ) == & m1 );
[6091b88a]496
[4d741e9]497 verify(validate(lm));
498
[6091b88a]499 insert_after(m1, m2);
500
[4d741e9]501 verify(validate(lm));
502
[6091b88a]503 printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
504
[6b33e89]505 assert( &first( lm ) == & m1 );
506 assert( &last( lm ) == & m2 );
[6091b88a]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
[69914cbc]524 dlist(fred, fred.mine) lf;
[6091b88a]525
[6b33e89]526 assert( &first( lf ) == 0p );
527 assert( &last( lf ) == 0p );
[6091b88a]528
529 insert_last(lf, f2);
530
[6b33e89]531 assert( &first( lf ) == & f2 );
532 assert( &last( lf ) == & f2 );
[6091b88a]533
[4d741e9]534 verify(validate(lf));
535
[69914cbc]536 with ( DLINK_VIA(fred, fred.mine) ) insert_before(f2, f1);
[6091b88a]537
[4d741e9]538 verify(validate(lf));
539
[6091b88a]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
[6b33e89]543 assert( &first( lf ) == & f1 );
544 assert( &last( lf ) == & f2 );
[6091b88a]545}
546
547void test__insertbefore_before_first__fred_yours() {
548
549 fred f1 = {3.14};
550 fred f2 = {0.5};
551
[69914cbc]552 dlist(fred, fred.yours) lf;
[6091b88a]553
[6b33e89]554 assert( &first( lf ) == 0p );
555 assert( &last( lf ) == 0p );
[6091b88a]556
557 insert_last(lf, f2);
558
[6b33e89]559 assert( &first( lf ) == & f2 );
560 assert( &last( lf ) == & f2 );
[6091b88a]561
[4d741e9]562 verify(validate(lf));
563
[69914cbc]564 with ( DLINK_VIA(fred, fred.yours) )insert_before(f2, f1);
[6091b88a]565
[4d741e9]566 verify(validate(lf));
567
[6091b88a]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
[6b33e89]571 assert( &first( lf ) == & f1 );
572 assert( &last( lf ) == & f2 );
[6091b88a]573}
574
575void test__insertbefore_before_first__mary() {
576
577 mary m1 = {3.14};
578 mary m2 = {0.5};
579
[69914cbc]580 dlist(mary) lm;
[6091b88a]581
[6b33e89]582 assert( &first( lm ) == 0p );
583 assert( &last( lm ) == 0p );
[6091b88a]584
585 insert_last(lm, m2);
586
[6b33e89]587 assert( &first( lm ) == & m2 );
588 assert( &last( lm ) == & m2 );
[6091b88a]589
[4d741e9]590 verify(validate(lm));
591
[6091b88a]592 insert_before(m2, m1);
593
[4d741e9]594 verify(validate(lm));
595
[6091b88a]596 printMariatheotokos(m1, m2, 0); // 3.14, 0.5; 3.14; 0.5; 0.5, 3.14 (modified)
597
[6b33e89]598 assert( &first( lm ) == & m1 );
599 assert( &last( lm ) == & m2 );
[6091b88a]600}
[69914cbc]601#if 0
[6091b88a]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////////////////////////////////////////////////////////////
[69914cbc]884#endif
[6091b88a]885void test__remove_at_head__fred_mine() {
886
887 fred f1 = {1.7};
888 fred f2 = {2.7};
889 fred f3 = {3.7};
890
[69914cbc]891 dlist(fred, fred.mine) flm;
[6091b88a]892 insert_last(flm, f1);
893 insert_last(flm, f2);
894 insert_last(flm, f3);
895
[69914cbc]896 dlist(fred, fred.yours) fly;
[6091b88a]897 insert_last(fly, f1);
898 insert_last(fly, f2);
899 insert_last(fly, f3);
900
[6b33e89]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
[6091b88a]903
[4d741e9]904 verify(validate(fly));
905 verify(validate(flm));
906
[69914cbc]907 with( DLINK_VIA(fred, fred.mine) ) remove(f1);
[6091b88a]908
[4d741e9]909 verify(validate(fly));
910 verify(validate(flm));
911
[6b33e89]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)
[6091b88a]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
[69914cbc]919 // assert(f1.$links_mine.next.is_terminator == false);
920 // assert(f1.$links_mine.prev.is_terminator == false);
[6091b88a]921}
922
[69914cbc]923
[6091b88a]924void test__remove_at_head__fred_yours() {
925
926 fred f1 = {1.7};
927 fred f2 = {2.7};
928 fred f3 = {3.7};
929
[69914cbc]930 dlist(fred, fred.mine) flm;
[6091b88a]931 insert_last(flm, f1);
932 insert_last(flm, f2);
933 insert_last(flm, f3);
934
[69914cbc]935 dlist(fred, fred.yours) fly;
[6091b88a]936 insert_last(fly, f1);
937 insert_last(fly, f2);
938 insert_last(fly, f3);
939
[6b33e89]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
[6091b88a]942
[4d741e9]943 verify(validate(fly));
944 verify(validate(flm));
945
[69914cbc]946 with( DLINK_VIA(fred, fred.yours) ) remove(f1);
[6091b88a]947
[4d741e9]948 verify(validate(fly));
949 verify(validate(flm));
950
[6b33e89]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)
[6091b88a]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
[69914cbc]958 // assert(f1.$links_yours.next.is_terminator == false);
959 // assert(f1.$links_yours.prev.is_terminator == false);
[6091b88a]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
[69914cbc]968 dlist(mary) ml;
[6091b88a]969 insert_last(ml, m1);
970 insert_last(ml, m2);
971 insert_last(ml, m3);
972
[6b33e89]973 printMariatheotokos(first( ml ), last( ml ), 1); // 1.7, 2.7, 3.7; 1.7; 3.7; 3.7, 2.7, 1.7
[6091b88a]974
[4d741e9]975 verify(validate(ml));
976
[6091b88a]977 remove(m1);
978
[4d741e9]979 verify(validate(ml));
980
[6b33e89]981 printMariatheotokos(first( ml ), last( ml ), 0); // 2.7, 3.7; 2.7; 3.7; 3.7, 2.7 (modified)
[6091b88a]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
[69914cbc]987 // assert(m1.$links.next.is_terminator == false);
988 // assert(m1.$links.prev.is_terminator == false);
[6091b88a]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
[69914cbc]1007 dlist(fred, fred.mine) flm;
[6091b88a]1008 insert_last(flm, f1);
1009 insert_last(flm, f2);
1010 insert_last(flm, f3);
1011
[69914cbc]1012 dlist(fred, fred.yours) fly;
[6091b88a]1013 insert_last(fly, f1);
1014 insert_last(fly, f2);
1015 insert_last(fly, f3);
1016
[6b33e89]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
[6091b88a]1019
[4d741e9]1020 verify(validate(fly));
1021 verify(validate(flm));
1022
[69914cbc]1023 with( DLINK_VIA(fred, fred.mine) ) remove(f3);
[6091b88a]1024
[4d741e9]1025 verify(validate(fly));
1026 verify(validate(flm));
1027
[6b33e89]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)
[6091b88a]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
[69914cbc]1035 // assert(f3.$links_mine.next.is_terminator == false);
1036 // assert(f3.$links_mine.prev.is_terminator == false);
[6091b88a]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
[69914cbc]1045 dlist(fred, fred.mine) flm;
[6091b88a]1046 insert_last(flm, f1);
1047 insert_last(flm, f2);
1048 insert_last(flm, f3);
1049
[69914cbc]1050 dlist(fred, fred.yours) fly;
[6091b88a]1051 insert_last(fly, f1);
1052 insert_last(fly, f2);
1053 insert_last(fly, f3);
1054
[6b33e89]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
[6091b88a]1057
[4d741e9]1058 verify(validate(fly));
1059 verify(validate(flm));
1060
[69914cbc]1061 with( DLINK_VIA(fred, fred.yours) ) remove(f3);
[6091b88a]1062
[4d741e9]1063 verify(validate(fly));
1064 verify(validate(flm));
1065
[6b33e89]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)
[6091b88a]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
[69914cbc]1073 // assert(f3.$links_yours.next.is_terminator == false);
1074 // assert(f3.$links_yours.prev.is_terminator == false);
[6091b88a]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
[69914cbc]1083 dlist(mary) ml;
[6091b88a]1084 insert_last(ml, m1);
1085 insert_last(ml, m2);
1086 insert_last(ml, m3);
1087
[6b33e89]1088 printMariatheotokos(first( ml ), last( ml ), 1); // 1.7, 2.7, 3.7; 1.7; 3.7; 3.7, 2.7, 1.7
[6091b88a]1089
[4d741e9]1090 verify(validate(ml));
1091
[6091b88a]1092 remove(m3);
1093
[4d741e9]1094 verify(validate(ml));
1095
[6b33e89]1096 printMariatheotokos(first( ml ), last( ml ), 0); // 1.7, 2.7; 1.7; 2.7; 2.7, 1.7 (modified)
[6091b88a]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
[69914cbc]1102 // assert(m3.$links.next.is_terminator == false);
1103 // assert(m3.$links.prev.is_terminator == false);
[6091b88a]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
[69914cbc]1120 dlist(fred, fred.mine) flm;
[6091b88a]1121 insert_last(flm, f);
1122
[69914cbc]1123 dlist(fred, fred.yours) fly;
[6091b88a]1124 insert_last(fly, f);
1125
[6b33e89]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
[6091b88a]1128
[4d741e9]1129 verify(validate(fly));
1130 verify(validate(flm));
1131
[69914cbc]1132 with( DLINK_VIA(fred, fred.mine) ) remove(f);
[6091b88a]1133
[4d741e9]1134 verify(validate(fly));
1135 verify(validate(flm));
1136
[6b33e89]1137 assert( &first( flm ) == 0p );
1138 assert( &last( flm ) == 0p );
[6091b88a]1139
[6b33e89]1140 printYourFreddies(first( fly ), last( fly ), 0); // 0.7; 0.7; 0.7; 0.7 (unmodified)
[6091b88a]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
[69914cbc]1146 // assert(f.$links_mine.next.is_terminator == false);
1147 // assert(f.$links_mine.prev.is_terminator == false);
[6091b88a]1148
1149 insert_last(flm, f);
[4d741e9]1150 verify(validate(fly));
1151 verify(validate(flm));
[6b33e89]1152 printMyFreddies(first( flm ), last( flm ), 0); // 0.7; 0.7; 0.7; 0.7
[6091b88a]1153}
1154
1155void test__remove_of_sole__fred_yours() {
1156
1157 fred f = {0.7};
1158
[69914cbc]1159 dlist(fred, fred.mine) flm;
[6091b88a]1160 insert_last(flm, f);
1161
[69914cbc]1162 dlist(fred, fred.yours) fly;
[6091b88a]1163 insert_last(fly, f);
1164
[6b33e89]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
[6091b88a]1167
[4d741e9]1168 verify(validate(fly));
1169 verify(validate(flm));
1170
[69914cbc]1171 with( DLINK_VIA(fred, fred.yours) ) remove(f);
[6091b88a]1172
[4d741e9]1173 verify(validate(fly));
1174 verify(validate(flm));
1175
[6b33e89]1176 assert( &first( fly ) == 0p );
1177 assert( &last( fly ) == 0p );
[6091b88a]1178
[6b33e89]1179 printYourFreddies(first( flm ), last( flm ), 0); // 0.7; 0.7; 0.7; 0.7 (unmodified)
[6091b88a]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
[69914cbc]1185 // assert(f.$links_yours.next.is_terminator == false);
1186 // assert(f.$links_yours.prev.is_terminator == false);
[6091b88a]1187
1188 insert_last(fly, f);
[4d741e9]1189 verify(validate(fly));
1190 verify(validate(flm));
[6b33e89]1191 printYourFreddies(first( fly ), last( fly ), 0); // 0.7; 0.7; 0.7; 0.7
[6091b88a]1192}
1193
1194void test__remove_of_sole__mary() {
1195
1196 mary m = {0.7};
1197
[69914cbc]1198 dlist(mary) ml;
[6091b88a]1199 insert_last(ml, m);
1200
[6b33e89]1201 printMariatheotokos(first( ml ), last( ml ), 1); // 0.7; 0.7; 0.7; 0.7
[6091b88a]1202
[4d741e9]1203 verify(validate(ml));
1204
[6091b88a]1205 remove(m);
1206
[4d741e9]1207 verify(validate(ml));
1208
[6b33e89]1209 assert( &first( ml ) == 0p );
1210 assert( &last( ml ) == 0p );
[6091b88a]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
[69914cbc]1216 // assert(m.$links.next.is_terminator == false);
1217 // assert(m.$links.prev.is_terminator == false);
[6091b88a]1218
1219 insert_last(ml, m);
[4d741e9]1220 verify(validate(ml));
[6b33e89]1221 printMariatheotokos(first( ml ), last( ml ), 0); // 0.7; 0.7; 0.7; 0.7
[6091b88a]1222}
1223
[f2d05e9]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
[69914cbc]1242 dlist(fred, fred.mine) flm;
[f2d05e9]1243 insert_last(flm, f1);
1244 insert_last(flm, f2);
1245 insert_last(flm, f3);
1246
[69914cbc]1247 dlist(fred, fred.yours) fly;
[f2d05e9]1248 insert_last(fly, f1);
1249 insert_last(fly, f2);
1250 insert_last(fly, f3);
1251
[6b33e89]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
[f2d05e9]1254
1255 verify(validate(fly));
1256 verify(validate(flm));
1257
[6b33e89]1258 fred & popped = remove_first(flm);
[f2d05e9]1259
1260 verify(validate(fly));
1261 verify(validate(flm));
1262
[6b33e89]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)
[f2d05e9]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
[69914cbc]1278 dlist(fred, fred.mine) flm;
[f2d05e9]1279 insert_last(flm, f1);
1280 insert_last(flm, f2);
1281 insert_last(flm, f3);
1282
[69914cbc]1283 dlist(fred, fred.yours) fly;
[f2d05e9]1284 insert_last(fly, f1);
1285 insert_last(fly, f2);
1286 insert_last(fly, f3);
1287
[6b33e89]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
[f2d05e9]1290
1291 verify(validate(fly));
1292 verify(validate(flm));
1293
[6b33e89]1294 fred & popped = remove_first(fly);
[f2d05e9]1295
1296 verify(validate(fly));
1297 verify(validate(flm));
1298
[6b33e89]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)
[f2d05e9]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
[69914cbc]1314 dlist(mary) ml;
[f2d05e9]1315 insert_last(ml, m1);
1316 insert_last(ml, m2);
1317 insert_last(ml, m3);
1318
[6b33e89]1319 printMariatheotokos(first( ml ), last( ml ), 1); // 1.7, 2.7, 3.7; 1.7; 3.7; 3.7, 2.7, 1.7
[f2d05e9]1320
1321 verify(validate(ml));
1322
[6b33e89]1323 mary & popped = remove_first(ml);
[f2d05e9]1324
1325 verify(validate(ml));
1326
[6b33e89]1327 printMariatheotokos(first( ml ), last( ml ), 0); // 2.7, 3.7; 2.7; 3.7; 3.7, 2.7 (modified)
[f2d05e9]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
[69914cbc]1341 dlist(fred, fred.mine) flm;
[f2d05e9]1342 insert_last(flm, f1);
1343 insert_last(flm, f2);
1344 insert_last(flm, f3);
1345
[69914cbc]1346 dlist(fred, fred.yours) fly;
[f2d05e9]1347 insert_last(fly, f1);
1348 insert_last(fly, f2);
1349 insert_last(fly, f3);
1350
[6b33e89]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
[f2d05e9]1353
1354 verify(validate(fly));
1355 verify(validate(flm));
1356
[6b33e89]1357 fred & popped = remove_last(flm);
[f2d05e9]1358
1359 verify(validate(fly));
1360 verify(validate(flm));
1361
[6b33e89]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)
[f2d05e9]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
[69914cbc]1377 dlist(fred, fred.mine) flm;
[f2d05e9]1378 insert_last(flm, f1);
1379 insert_last(flm, f2);
1380 insert_last(flm, f3);
1381
[69914cbc]1382 dlist(fred, fred.yours) fly;
[f2d05e9]1383 insert_last(fly, f1);
1384 insert_last(fly, f2);
1385 insert_last(fly, f3);
1386
[6b33e89]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
[f2d05e9]1389
1390 verify(validate(fly));
1391 verify(validate(flm));
1392
[6b33e89]1393 fred & popped = remove_last(fly);
[f2d05e9]1394
1395 verify(validate(fly));
1396 verify(validate(flm));
1397
[6b33e89]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)
[f2d05e9]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
[69914cbc]1413 dlist(mary) ml;
[f2d05e9]1414 insert_last(ml, m1);
1415 insert_last(ml, m2);
1416 insert_last(ml, m3);
1417
[6b33e89]1418 printMariatheotokos(first( ml ), last( ml ), 1); // 1.7, 2.7, 3.7; 1.7; 3.7; 3.7, 2.7, 1.7
[f2d05e9]1419
1420 verify(validate(ml));
1421
[6b33e89]1422 mary & popped = remove_last(ml);
[f2d05e9]1423
1424 verify(validate(ml));
1425
[6b33e89]1426 printMariatheotokos(first( ml ), last( ml ), 0); // 1.7, 1.7; 1.7; 2.7; 2.7, 1.7 (modified)
[f2d05e9]1427
1428 // observe m1 is now solo
1429 printMariatheotokos(m3, *0p, 0); // 3.7; 3.7; ;
1430
1431 assert( &popped == &m3 );
1432}
1433
[69914cbc]1434////////////////////////////////////////////////////////////
1435//
1436// Section 4g
1437//
[81ab5eb]1438// Test cases of empty, isFirst, isLast,
[6b33e89]1439// remove_first, remove_last, modifications via iter
[69914cbc]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
[81ab5eb]1451 dlist(mary) ml; assert(empty( ml ));
[6b33e89]1452
[81ab5eb]1453 insert_last(ml, m1); assert(!empty( ml ));
1454 insert_last(ml, m2); assert(!empty( ml ));
1455 insert_last(ml, m3); assert(!empty( ml ));
[6b33e89]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 ) );
[69914cbc]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
[81ab5eb]1496 assert(empty( ml ));
[69914cbc]1497
1498 insert_last(ml, m1);
1499 insert_last(ml, m2);
1500 insert_last(ml, m3);
1501
[81ab5eb]1502 &m1r = & remove_first(ml); assert(!empty( ml ));
1503 &m2r = & remove_first(ml); assert(!empty( ml ));
1504 &m3r = & remove_first(ml); assert(empty( ml ));
1505 &mxr = & remove_first(ml); assert(empty( ml ));
[69914cbc]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
[81ab5eb]1518 assert(empty( ml ));
[69914cbc]1519
1520 insert_first(ml, m1);
1521 insert_first(ml, m2);
1522 insert_first(ml, m3);
1523
[81ab5eb]1524 &m1r = & remove_last(ml); assert(!empty( ml ));
1525 &m2r = & remove_last(ml); assert(!empty( ml ));
1526 &m3r = & remove_last(ml); assert(empty( ml ));
1527 &mxr = & remove_last(ml); assert(empty( ml ));
[69914cbc]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
[81ab5eb]1540 assert(empty( ml ));
[69914cbc]1541
1542 insert_first(ml, m1);
1543 insert_first(ml, m2);
1544 insert_first(ml, m3);
1545
[81ab5eb]1546 &m3r = & remove_first(ml); assert(!empty( ml ));
1547 &m2r = & remove_first(ml); assert(!empty( ml ));
1548 &m1r = & remove_first(ml); assert(empty( ml ));
1549 &mxr = & remove_first(ml); assert(empty( ml ));
[69914cbc]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
[81ab5eb]1562 assert(empty( ml ));
[69914cbc]1563
1564 insert_last(ml, m1);
1565 insert_last(ml, m2);
1566 insert_last(ml, m3);
1567
[81ab5eb]1568 &m3r = & remove_last(ml); assert(!empty( ml ));
1569 &m2r = & remove_last(ml); assert(!empty( ml ));
1570 &m1r = & remove_last(ml); assert(empty( ml ));
1571 &mxr = & remove_last(ml); assert(empty( ml ));
[69914cbc]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;
[6b33e89]1590 mary & mlorigin = iter( ml );
[69914cbc]1591
1592 // insert before the origin
1593
[6b33e89]1594 insert_before( iter( ml ), m1 );
[81ab5eb]1595 assert( !empty( ml ) );
[69914cbc]1596
[6b33e89]1597 mary & mlfirst = first( ml );
1598 mary & mllast = last( ml );
[69914cbc]1599
1600 assert( &m1 == & mlfirst );
1601 assert( &m1 == & mllast );
1602
1603 // moveNext after last goes back to origin, &vv
1604
[6b33e89]1605 bool canMoveNext = advance( mllast );
1606 bool canMovePrev = recede( mlfirst );
[69914cbc]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
[c2794b2]1617void test__isListed_cases__mary() {
1618
[6b33e89]1619 mary m1 = {1.7}; assert( ! isListed( m1 ) );
1620 mary m2 = {2.7}; assert( ! isListed( m2 ) );
1621 mary m3 = {3.7}; assert( ! isListed( m3 ) );
[c2794b2]1622
1623 dlist(mary) ml;
1624
[6b33e89]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 ) );
[c2794b2]1628
[6b33e89]1629 remove( m1 ); assert( ! isListed( m1 ) ); assert( isListed( m2 ) );
1630 remove( m2 ); assert( ! isListed( m2 ) ); assert( isListed( m3 ) );
1631 remove( m3 ); assert( ! isListed( m3 ) );
[c2794b2]1632
1633 printf("isListed cases done\n");
1634}
1635
[6091b88a]1636////////////////////////////////////////////////////////////
1637//
1638// Section 5
1639//
1640// Simple driver with the inter-scario printing
1641//
1642////////////////////////////////////////////////////////////
1643
1644int main() {
[69914cbc]1645#if 0
[75f888e7]1646 printf( "~~~~~~~~~~~~~~~~~ Headless List Tests - insert_after ~~~~~~~~~~~~~~~~\n" );
1647 printf( "\n" );
[6091b88a]1648
[75f888e7]1649 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1650 printf( "Test 1-i: Modifying Freds on MINE \n" );
1651 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1652 test__insertafter_singleton_on_singleton__fred_mine();
1653
[75f888e7]1654 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1655 printf( "Test 2-i. Modifying Freds on YOURS\n" );
1656 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1657 test__insertafter_singleton_on_singleton__fred_yours();
1658
[75f888e7]1659 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1660 printf( "Test 3-i. Modifying Maries\n" );
1661 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1662 test__insertafter_singleton_on_singleton__mary();
1663
[75f888e7]1664 printf( "\n" );
1665 printf( "~~~~~~~~~~~~~~~~ Headless List Tests - insert_before ~~~~~~~~~~~~~~~~\n" );
1666 printf( "\n" );
[6091b88a]1667
[75f888e7]1668 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1669 printf( "Test 1-ii: Modifying Freds on MINE \n" );
1670 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1671 test__insertbefore_singleton_on_singleton__fred_mine();
1672
[75f888e7]1673 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1674 printf( "Test 2-ii. Modifying Freds on YOURS\n" );
1675 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1676 test__insertbefore_singleton_on_singleton__fred_yours();
1677
[75f888e7]1678 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1679 printf( "Test 3-ii. Modifying Maries\n" );
1680 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1681 test__insertbefore_singleton_on_singleton__mary();
[69914cbc]1682#endif
[75f888e7]1683 printf( "\n" );
1684 printf( "~~~~~~~~~~~~~~~~~ Headed List Tests - insert_first ~~~~~~~~~~~~~~~~~~\n" );
1685 printf( "\n" );
[6091b88a]1686
[75f888e7]1687 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1688 printf( "Test 4-i: Modifying Freds on MINE \n" );
1689 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1690 test__insertfirst_two_on_empty__fred_mine();
1691
[75f888e7]1692 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1693 printf( "Test 5-i: Modifying Freds on YOURS \n" );
1694 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1695 test__insertfirst_two_on_empty__fred_yours();
1696
[75f888e7]1697 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1698 printf( "Test 6-i. Modifying Maries\n" );
1699 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1700 test__insertfirst_two_on_empty__mary();
1701
[75f888e7]1702 printf( "\n" );
1703 printf( "~~~~~~~~~~~~~~~~~ Headed List Tests - insert_last ~~~~~~~~~~~~~~~~~~~\n" );
1704 printf( "\n" );
[6091b88a]1705
[75f888e7]1706 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1707 printf( "Test 4-ii: Modifying Freds on MINE \n" );
1708 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1709 test__insertlast_two_on_empty__fred_mine();
1710
[75f888e7]1711 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1712 printf( "Test 5-ii: Modifying Freds on YOURS \n" );
1713 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1714 test__insertlast_two_on_empty__fred_yours();
1715
[75f888e7]1716 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1717 printf( "Test 6-ii. Modifying Maries\n" );
1718 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1719 test__insertlast_two_on_empty__mary();
1720
[75f888e7]1721 printf( "\n" );
1722 printf( "~~~~~~~~~~~ Element ops on Headed List Tests: after, last ~~~~~~~~~~~\n" );
1723 printf( "\n" );
[6091b88a]1724
[75f888e7]1725 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1726 printf( "Test 7-i. Modifying Freds on MINE\n" );
1727 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1728 test__insertafter_after_last__fred_mine();
1729
[75f888e7]1730 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1731 printf( "Test 8-i. Modifying Freds on YOURS\n" );
1732 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1733 test__insertafter_after_last__fred_yours();
1734
[75f888e7]1735 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1736 printf( "Test 9-i. Modifying Maries\n" );
1737 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1738 test__insertafter_after_last__mary();
1739
[75f888e7]1740 printf( "\n" );
1741 printf( "~~~~~~~~~~ Element ops on Headed List Tests: before, first ~~~~~~~~~~\n" );
1742 printf( "\n" );
[6091b88a]1743
[75f888e7]1744 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1745 printf( "Test 7-ii. Modifying Freds on MINE\n" );
1746 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1747 test__insertbefore_before_first__fred_mine();
1748
[75f888e7]1749 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1750 printf( "Test 8-ii. Modifying Freds on YOURS\n" );
1751 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1752 test__insertbefore_before_first__fred_yours();
1753
[75f888e7]1754 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1755 printf( "Test 9-ii. Modifying Maries\n" );
1756 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1757 test__insertbefore_before_first__mary();
[69914cbc]1758#if 0
[6091b88a]1759
[75f888e7]1760 printf( "\n" );
1761 printf( "~~~~~~~~~~ Element removal tests on Headless List: mid ~~~~~~~~~~\n" );
1762 printf( "\n" );
[6091b88a]1763
[75f888e7]1764 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1765 printf( "Test 10-i. Modifying Freds on MINE\n" );
1766 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1767 test__remove_mid__fred_mine();
1768
[75f888e7]1769 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1770 printf( "Test 11-i. Modifying Freds on YOURS\n" );
1771 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1772 test__remove_mid__fred_yours();
1773
[75f888e7]1774 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1775 printf( "Test 12-i. Modifying Maries\n" );
1776 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1777 test__remove_mid__mary();
1778
[75f888e7]1779 printf( "\n" );
1780 printf( "~~~~~~~~~~ Element removal tests on Headless List: at first ~~~~~~~~~~\n" );
1781 printf( "\n" );
[6091b88a]1782
[75f888e7]1783 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1784 printf( "Test 10-ii. Modifying Freds on MINE\n" );
1785 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1786 test__remove_at_first__fred_mine();
1787
[75f888e7]1788 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1789 printf( "Test 11-ii. Modifying Freds on YOURS\n" );
1790 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1791 test__remove_at_first__fred_yours();
1792
[75f888e7]1793 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1794 printf( "Test 12-ii. Modifying Maries\n" );
1795 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1796 test__remove_at_first__mary();
1797
[75f888e7]1798 printf( "\n" );
1799 printf( "~~~~~~~~~~ Element removal tests on Headless List: at last ~~~~~~~~~~\n" );
1800 printf( "\n" );
[6091b88a]1801
[75f888e7]1802 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1803 printf( "Test 10-iii. Modifying Freds on MINE\n" );
1804 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1805 test__remove_at_last__fred_mine();
1806
[75f888e7]1807 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1808 printf( "Test 11-iii. Modifying Freds on YOURS\n" );
1809 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1810 test__remove_at_last__fred_yours();
1811
[75f888e7]1812 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1813 printf( "Test 12-iii. Modifying Maries\n" );
1814 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1815 test__remove_at_last__mary();
[69914cbc]1816#endif
[75f888e7]1817 printf( "\n" );
1818 printf( "~~~~~~~~~~ Element removal tests on Headed List: at first ~~~~~~~~~~\n" );
1819 printf( "\n" );
[6091b88a]1820
[75f888e7]1821 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1822 printf( "Test 13-i. Modifying Freds on MINE\n" );
1823 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1824 test__remove_at_head__fred_mine();
1825
[75f888e7]1826 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1827 printf( "Test 14-i. Modifying Freds on YOURS\n" );
1828 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1829 test__remove_at_head__fred_yours();
1830
[75f888e7]1831 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1832 printf( "Test 15-i. Modifying Maries\n" );
1833 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1834 test__remove_at_head__mary();
1835
[75f888e7]1836 printf( "\n" );
1837 printf( "~~~~~~~~~~ Element removal tests on Headed List: at last ~~~~~~~~~~\n" );
1838 printf( "\n" );
[6091b88a]1839
[75f888e7]1840 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1841 printf( "Test 13-ii. Modifying Freds on MINE\n" );
1842 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1843 test__remove_at_tail__fred_mine();
1844
[75f888e7]1845 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1846 printf( "Test 14-ii. Modifying Freds on YOURS\n" );
1847 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1848 test__remove_at_tail__fred_yours();
1849
[75f888e7]1850 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1851 printf( "Test 15-ii. Modifying Maries\n" );
1852 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1853 test__remove_at_tail__mary();
1854
[75f888e7]1855 printf( "\n" );
1856 printf( "~~~~~~~~~~ Element removal tests on Headed List: of sole ~~~~~~~~~~\n" );
1857 printf( "\n" );
[6091b88a]1858
[75f888e7]1859 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1860 printf( "Test 13-iii. Modifying Freds on MINE\n" );
1861 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1862 test__remove_of_sole__fred_mine();
1863
[75f888e7]1864 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1865 printf( "Test 14-iii. Modifying Freds on YOURS\n" );
1866 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1867 test__remove_of_sole__fred_yours();
1868
[75f888e7]1869 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1870 printf( "Test 15-iii. Modifying Maries\n" );
1871 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[6091b88a]1872 test__remove_of_sole__mary();
1873
[75f888e7]1874 printf( "\n" );
1875 printf( "~~~~~~~~~~ End removal tests on Headed List: First ~~~~~~~~~~\n" );
1876 printf( "\n" );
[f2d05e9]1877
[75f888e7]1878 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1879 printf( "Test 16-i. Modifying Freds on MINE\n" );
1880 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[f2d05e9]1881 test__pop_first__fred_mine();
1882
[75f888e7]1883 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1884 printf( "Test 16-ii. Modifying Freds on YOURS\n" );
1885 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[f2d05e9]1886 test__pop_first__fred_yours();
1887
[75f888e7]1888 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1889 printf( "Test 16-iii. Modifying Maries\n" );
1890 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[f2d05e9]1891 test__pop_first__maries();
1892
[75f888e7]1893 printf( "\n" );
1894 printf( "~~~~~~~~~~ End removal tests on Headed List: Last ~~~~~~~~~~\n" );
1895 printf( "\n" );
[f2d05e9]1896
[75f888e7]1897 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1898 printf( "Test 17-i. Modifying Freds on MINE\n" );
1899 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[f2d05e9]1900 test__pop_last__fred_mine();
1901
[75f888e7]1902 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1903 printf( "Test 17-ii. Modifying Freds on YOURS\n" );
1904 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[f2d05e9]1905 test__pop_last__fred_yours();
1906
[75f888e7]1907 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1908 printf( "Test 17-iii. Modifying Maries\n" );
1909 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[f2d05e9]1910 test__pop_last__maries();
1911
[75f888e7]1912 printf( "\n" );
1913 printf( "~~~~~~~~~~~~~~~~~~~ Ease-of-access cases ~~~~~~~~~~~~~~~~~~\n" );
1914 printf( "\n" );
[69914cbc]1915
[75f888e7]1916 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1917 printf( "Test 18-i. Modifying Freds on MINE\n" );
1918 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1919 printf( "Not implmented\n" );
[69914cbc]1920
[75f888e7]1921 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1922 printf( "Test 18-ii. Modifying Freds on YOURS\n" );
1923 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1924 printf( "Not implmented\n" );
[69914cbc]1925
[75f888e7]1926 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
1927 printf( "Test 18-iii. Modifying Maries\n" );
1928 printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
[69914cbc]1929
1930 test__accessor_cases__mary();
1931 test__try_pop__mary();
1932 test__origin_mutation__mary();
[c2794b2]1933 test__isListed_cases__mary();
[69914cbc]1934
[6091b88a]1935 return 0;
1936}
Note: See TracBrowser for help on using the repository browser.