3 #ifndef CDSTEST_HDR_INTRUSIVE_MICHAEL_H
4 #define CDSTEST_HDR_INTRUSIVE_MICHAEL_H
6 #include "cppunit/cppunit_proxy.h"
7 #include <cds/intrusive/details/michael_list_base.h>
10 namespace ci = cds::intrusive;
11 namespace co = cds::opt;
13 class IntrusiveMichaelListHeaderTest: public CppUnitMini::TestCase
19 int nEnsureExistsCall;
26 , nEnsureExistsCall(0)
37 stat& operator =(const stat& s)
39 memcpy( this, &s, sizeof(s));
44 template <typename GC>
45 struct base_int_item: public ci::michael_list::node< GC >
55 base_int_item(int key, int val)
61 base_int_item(const base_int_item& v )
67 const int& key() const
73 template <typename GC>
74 struct member_int_item
79 ci::michael_list::node< GC > hMember;
86 member_int_item(int key, int val)
92 member_int_item(const member_int_item& v )
98 const int& key() const
104 template <typename T>
107 bool operator ()(const T& v1, const T& v2 ) const
109 return v1.key() < v2.key();
112 template <typename Q>
113 bool operator ()(const T& v1, const Q& v2 ) const
115 return v1.key() < v2;
118 template <typename Q>
119 bool operator ()(const Q& v1, const T& v2 ) const
121 return v1 < v2.key();
134 template <typename T, typename Q>
135 bool operator()( T const& i1, Q const& i2) const
137 return i1.nKey < i2.nKey;
141 template <typename T>
143 int operator ()(const T& v1, const T& v2 ) const
145 if ( v1.key() < v2.key() )
147 return v1.key() > v2.key() ? 1 : 0;
150 template <typename Q>
151 int operator ()(const T& v1, const Q& v2 ) const
155 return v1.key() > v2 ? 1 : 0;
158 template <typename Q>
159 int operator ()(const Q& v1, const T& v2 ) const
163 return v1 > v2.key() ? 1 : 0;
167 struct faked_disposer
169 template <typename T>
170 void operator ()( T * p )
172 ++p->s.nDisposeCount;
176 struct ensure_functor
178 template <typename T>
179 void operator ()(bool bNew, T& item, T& /*val*/ )
182 ++item.s.nEnsureNewCall;
184 ++item.s.nEnsureExistsCall;
190 template <typename T, typename Q>
191 void operator ()( T& item, Q& /*val*/ )
199 template <typename T>
200 void operator()( T const& item )
206 template <class OrdList>
207 void test_int_common()
209 typedef typename OrdList::value_type value_type;
211 value_type v1( 10, 50 );
212 value_type v2( 5, 25 );
213 value_type v3( 20, 100 );
216 CPPUNIT_ASSERT( l.empty() );
218 CPPUNIT_ASSERT( l.insert( v1 )) ; // true
219 CPPUNIT_ASSERT( l.find( v1.key() ));
221 CPPUNIT_ASSERT( v1.s.nFindCall == 0 );
222 CPPUNIT_ASSERT( l.find( v1.key(), find_functor() ));
223 CPPUNIT_ASSERT( v1.s.nFindCall == 1 );
225 CPPUNIT_ASSERT( !l.find( v2.key() ));
226 CPPUNIT_ASSERT( !l.find_with( v3.key(), less<value_type>() ));
227 CPPUNIT_ASSERT( !l.empty() );
229 CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is not raised since pNext is nullptr
233 CPPUNIT_ASSERT( !l.insert( v )) ; // false
236 std::pair<bool, bool> ret = l.ensure( v2, ensure_functor() );
237 CPPUNIT_ASSERT( ret.first );
238 CPPUNIT_ASSERT( ret.second );
239 CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 );
240 CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 );
242 //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty"
244 CPPUNIT_ASSERT( l.find_with( v1.key(), less<value_type>() )) ; // true
246 CPPUNIT_ASSERT( v1.s.nFindCall == 1 );
247 CPPUNIT_ASSERT( l.find_with( v1.key(), less<value_type>(), find_functor() ));
248 CPPUNIT_ASSERT( v1.s.nFindCall == 2 );
250 CPPUNIT_ASSERT( l.find( v2.key() ));
252 CPPUNIT_ASSERT( v2.s.nFindCall == 0 );
253 CPPUNIT_ASSERT( l.find( v2.key(), find_functor() ));
254 CPPUNIT_ASSERT( v2.s.nFindCall == 1 );
256 CPPUNIT_ASSERT( !l.find( v3.key() ));
259 CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 );
260 CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 );
263 ret = l.ensure( v, ensure_functor() );
265 CPPUNIT_ASSERT( ret.first );
266 CPPUNIT_ASSERT( !ret.second );
267 CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 );
268 CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 );
269 CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 );
270 CPPUNIT_ASSERT( v.s.nEnsureNewCall == 0 );
273 CPPUNIT_ASSERT( !l.empty() );
275 CPPUNIT_ASSERT( l.insert( v3 )) ; // true
276 CPPUNIT_ASSERT( l.find( v3.key() ));
278 CPPUNIT_ASSERT( v3.s.nFindCall == 0 );
279 CPPUNIT_ASSERT( l.find( v3.key(), find_functor() ));
280 CPPUNIT_ASSERT( v3.s.nFindCall == 1 );
282 CPPUNIT_ASSERT( l.unlink( v2 ) );
283 CPPUNIT_ASSERT( l.find( v1.key() )) ; // true
284 CPPUNIT_ASSERT( !l.find( v2.key() )) ; // true
285 CPPUNIT_ASSERT( l.find( v3.key() )) ; // true
286 CPPUNIT_ASSERT( !l.empty() );
287 CPPUNIT_ASSERT( !l.unlink( v2 ) );
290 // v1 key is in the list but v NODE is not in the list
292 CPPUNIT_ASSERT( !l.unlink( v ) );
295 CPPUNIT_ASSERT( l.unlink( v1 ) );
296 CPPUNIT_ASSERT( !l.unlink( v1 ) );
297 CPPUNIT_ASSERT( !l.find( v1.key() ));
298 CPPUNIT_ASSERT( !l.find( v2.key() ));
299 CPPUNIT_ASSERT( l.find( v3.key() ));
300 CPPUNIT_ASSERT( !l.empty() );
301 CPPUNIT_ASSERT( !l.unlink( v1 ) );
302 CPPUNIT_ASSERT( !l.unlink( v2 ) );
304 CPPUNIT_ASSERT( l.unlink( v3 ) );
305 CPPUNIT_ASSERT( !l.find_with( v1.key(), less<value_type>() ));
306 CPPUNIT_ASSERT( !l.find_with( v2.key(), less<value_type>(), find_functor() ));
307 CPPUNIT_ASSERT( !l.find( v3.key(), find_functor() ));
308 CPPUNIT_ASSERT( l.empty() );
309 CPPUNIT_ASSERT( !l.unlink( v1 ) );
310 CPPUNIT_ASSERT( !l.unlink( v2 ) );
311 CPPUNIT_ASSERT( !l.unlink( v3 ) );
313 // Apply retired pointer to clean links
314 OrdList::gc::force_dispose();
317 ret = l.ensure( v3, ensure_functor() );
318 CPPUNIT_ASSERT( ret.first );
319 CPPUNIT_ASSERT( ret.second );
320 CPPUNIT_ASSERT( v3.s.nEnsureNewCall == s.nEnsureNewCall + 1);
321 CPPUNIT_ASSERT( v3.s.nEnsureExistsCall == s.nEnsureExistsCall );
322 CPPUNIT_ASSERT( !l.empty() );
325 ret = l.ensure( v2, ensure_functor() );
326 CPPUNIT_ASSERT( ret.first );
327 CPPUNIT_ASSERT( ret.second );
328 CPPUNIT_ASSERT( v2.s.nEnsureNewCall == s.nEnsureNewCall + 1);
329 CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == s.nEnsureExistsCall );
330 CPPUNIT_ASSERT( !l.empty() );
333 ret = l.ensure( v1, ensure_functor() );
334 CPPUNIT_ASSERT( ret.first );
335 CPPUNIT_ASSERT( ret.second );
336 CPPUNIT_ASSERT( v1.s.nEnsureNewCall == s.nEnsureNewCall + 1);
337 CPPUNIT_ASSERT( v1.s.nEnsureExistsCall == s.nEnsureExistsCall );
338 CPPUNIT_ASSERT( !l.empty() );
341 CPPUNIT_ASSERT( v1.s.nEraseCall == 0 );
342 CPPUNIT_ASSERT( l.erase( v1.key(), erase_functor()) );
343 CPPUNIT_ASSERT( v1.s.nEraseCall == 1 );
344 //CPPUNIT_ASSERT( v1.s.nDisposeCount == 0 );
345 CPPUNIT_ASSERT( !l.empty() );
347 CPPUNIT_ASSERT( l.erase_with( v2.key(), less<value_type>() ) );
348 CPPUNIT_ASSERT( !l.erase( v2.key()));
349 //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 );
350 CPPUNIT_ASSERT( !l.empty() );
352 CPPUNIT_ASSERT( v2.s.nEraseCall == 0 );
353 CPPUNIT_ASSERT( !l.erase( v2, erase_functor() ));
354 CPPUNIT_ASSERT( v2.s.nEraseCall == 0 );
355 CPPUNIT_ASSERT( !l.erase( v1 ));
356 //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 );
357 CPPUNIT_ASSERT( !l.empty() );
359 CPPUNIT_ASSERT( v3.s.nEraseCall == 0 );
360 CPPUNIT_ASSERT( l.erase_with( v3, less<value_type>(), erase_functor() ));
361 CPPUNIT_ASSERT( v3.s.nEraseCall == 1 );
362 //CPPUNIT_ASSERT( v3.s.nDisposeCount == 0 );
363 CPPUNIT_ASSERT( l.empty() );
365 // Apply retired pointer to clean links
366 OrdList::gc::force_dispose();
369 CPPUNIT_ASSERT( l.insert( v1 ));
370 CPPUNIT_ASSERT( l.insert( v3 ));
371 CPPUNIT_ASSERT( !l.empty() );
372 CPPUNIT_ASSERT( !l.unlink( v2 ));
373 CPPUNIT_ASSERT( l.unlink( v1 ));
374 CPPUNIT_ASSERT( !l.unlink( v1 ));
375 CPPUNIT_ASSERT( l.unlink( v3 ));
376 CPPUNIT_ASSERT( !l.unlink( v3 ));
377 CPPUNIT_ASSERT( l.empty() );
379 // Apply retired pointer
380 OrdList::gc::force_dispose();
381 CPPUNIT_ASSERT( v1.s.nDisposeCount == 3 );
382 CPPUNIT_ASSERT( v2.s.nDisposeCount == 2 );
383 CPPUNIT_ASSERT( v3.s.nDisposeCount == 3 );
385 // Destructor test (call disposer)
386 CPPUNIT_ASSERT( l.insert( v1 ));
387 CPPUNIT_ASSERT( l.insert( v3 ));
388 CPPUNIT_ASSERT( l.insert( v2 ));
393 typename OrdList::iterator it = l.begin();
394 typename OrdList::const_iterator cit = l.cbegin();
395 CPPUNIT_ASSERT( it != l.end() );
396 CPPUNIT_ASSERT( it != l.cend() );
397 CPPUNIT_ASSERT( cit != l.end() );
398 CPPUNIT_ASSERT( cit != l.cend() );
399 CPPUNIT_ASSERT( cit == it );
401 CPPUNIT_ASSERT( it->nKey == v2.nKey );
402 CPPUNIT_ASSERT( it->nVal == v2.nVal );
403 CPPUNIT_ASSERT( ++it != l.end() );
404 CPPUNIT_ASSERT( it->nKey == v1.nKey );
405 CPPUNIT_ASSERT( it->nVal == v1.nVal );
406 CPPUNIT_ASSERT( ++it != l.end() );
407 CPPUNIT_ASSERT( it->nKey == v3.nKey );
408 CPPUNIT_ASSERT( it->nVal == v3.nVal );
409 CPPUNIT_ASSERT( ++it == l.end() );
414 typename OrdList::const_iterator it = l.cbegin();
415 CPPUNIT_ASSERT( it != l.cend() );
416 CPPUNIT_ASSERT( it->nKey == v2.nKey );
417 CPPUNIT_ASSERT( it->nVal == v2.nVal );
418 CPPUNIT_ASSERT( ++it != l.cend() );
419 CPPUNIT_ASSERT( it->nKey == v1.nKey );
420 CPPUNIT_ASSERT( it->nVal == v1.nVal );
421 CPPUNIT_ASSERT( ++it != l.cend() );
422 CPPUNIT_ASSERT( it->nKey == v3.nKey );
423 CPPUNIT_ASSERT( it->nVal == v3.nVal );
424 CPPUNIT_ASSERT( ++it == l.cend() );
429 OrdList const & lref = l;
430 typename OrdList::const_iterator it = lref.begin();
431 CPPUNIT_ASSERT( it != l.end() );
432 CPPUNIT_ASSERT( it->nKey == v2.nKey );
433 CPPUNIT_ASSERT( it->nVal == v2.nVal );
434 CPPUNIT_ASSERT( ++it != lref.end() );
435 CPPUNIT_ASSERT( it->nKey == v1.nKey );
436 CPPUNIT_ASSERT( it->nVal == v1.nVal );
437 CPPUNIT_ASSERT( ++it != l.end() );
438 CPPUNIT_ASSERT( it->nKey == v3.nKey );
439 CPPUNIT_ASSERT( it->nVal == v3.nVal );
440 CPPUNIT_ASSERT( ++it == l.end() );
444 // Apply retired pointer
445 OrdList::gc::force_dispose();
447 CPPUNIT_ASSERT( v1.s.nDisposeCount == 4 );
448 CPPUNIT_ASSERT( v2.s.nDisposeCount == 3 );
449 CPPUNIT_ASSERT( v3.s.nDisposeCount == 4 );
452 template <class OrdList>
455 test_int_common<OrdList>();
458 typename OrdList::guarded_ptr gp;
460 static int const nLimit = 20;
461 typename OrdList::value_type arrItem[nLimit];
465 for (int i = 0; i < nLimit; ++i)
467 shuffle( a, a + nLimit );
469 for (int i = 0; i < nLimit; ++i) {
470 arrItem[i].nKey = a[i];
471 arrItem[i].nVal = a[i] * 2;
475 for ( int i = 0; i < nLimit; ++i )
476 CPPUNIT_ASSERT( l.insert( arrItem[i] ) );
478 for ( int i=0; i < nLimit; ++i ) {
479 gp = l.get( arrItem[i].nKey );
480 CPPUNIT_ASSERT_EX( gp, "i=" << i );
481 CPPUNIT_ASSERT( !gp.empty());
482 CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey );
483 CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal );
486 gp = l.extract( arrItem[i].nKey );
487 CPPUNIT_ASSERT_EX( gp, "i=" << i );
488 CPPUNIT_ASSERT( !gp.empty());
489 CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey );
490 CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal );
493 gp = l.get( arrItem[i].nKey );
494 CPPUNIT_CHECK( !gp );
495 CPPUNIT_CHECK( gp.empty());
496 CPPUNIT_CHECK( !l.extract( arrItem[i].nKey ));
497 CPPUNIT_CHECK( gp.empty());
499 CPPUNIT_ASSERT( l.empty() );
500 CPPUNIT_ASSERT( !l.get( nLimit/2 ));
501 CPPUNIT_ASSERT( gp.empty());
502 CPPUNIT_ASSERT( !l.extract( nLimit/2 ));
503 CPPUNIT_ASSERT( gp.empty());
505 // Apply retired pointer
506 OrdList::gc::force_dispose();
508 // extract_with/get_with
509 for ( int i = 0; i < nLimit; ++i )
510 CPPUNIT_ASSERT( l.insert( arrItem[i] ) );
512 for ( int i=0; i < nLimit; ++i ) {
513 other_item itm( arrItem[i].nKey );
514 gp = l.get_with( itm, other_less() );
515 CPPUNIT_ASSERT_EX( gp, "i=" << i );
516 CPPUNIT_ASSERT( !gp.empty());
517 CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey );
518 CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal );
521 gp = l.extract_with( itm, other_less() );
522 CPPUNIT_ASSERT_EX( gp, "i=" << i );
523 CPPUNIT_ASSERT( !gp.empty());
524 CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey );
525 CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal );
528 gp = l.get_with( itm, other_less() );
529 CPPUNIT_CHECK( !gp );
530 CPPUNIT_CHECK( gp.empty());
531 CPPUNIT_CHECK( !l.extract_with( itm, other_less() ));
532 CPPUNIT_CHECK( gp.empty());
534 CPPUNIT_ASSERT( l.empty() );
535 CPPUNIT_ASSERT( !l.get_with( other_item(nLimit/2), other_less() ));
536 CPPUNIT_ASSERT( gp.empty());
537 CPPUNIT_ASSERT( !l.extract_with( other_item(nLimit/2), other_less() ));
538 CPPUNIT_ASSERT( gp.empty());
540 // Apply retired pointer
541 OrdList::gc::force_dispose();
543 for ( int i=0; i < nLimit; i++ ) {
544 CPPUNIT_ASSERT( arrItem[i].s.nDisposeCount == 2 );
549 template <class OrdList>
552 test_int_common<OrdList>();
555 static int const nLimit = 20;
556 typename OrdList::value_type arrItem[nLimit];
558 typedef typename OrdList::rcu_lock rcu_lock;
559 typedef typename OrdList::value_type value_type;
560 typedef typename OrdList::gc rcu_type;
564 for (int i = 0; i < nLimit; ++i)
566 shuffle( a, a + nLimit );
568 for (int i = 0; i < nLimit; ++i) {
569 arrItem[i].nKey = a[i];
570 arrItem[i].nVal = a[i] * 2;
574 for ( int i = 0; i < nLimit; ++i )
575 CPPUNIT_ASSERT( l.insert( arrItem[i] ) );
577 typename OrdList::exempt_ptr ep;
578 typename OrdList::raw_ptr rp;
580 for ( int i = 0; i < nLimit; ++i ) {
584 CPPUNIT_ASSERT( rp );
585 CPPUNIT_CHECK( rp->nKey == a[i] );
586 CPPUNIT_CHECK( rp->nVal == a[i] * 2 );
590 ep = l.extract( a[i] );
591 CPPUNIT_ASSERT( ep );
592 CPPUNIT_ASSERT( !ep.empty() );
593 CPPUNIT_CHECK( ep->nKey == a[i] );
594 CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 );
599 CPPUNIT_CHECK( !l.get( a[i] ));
601 CPPUNIT_CHECK( !l.extract( a[i] ));
602 CPPUNIT_CHECK( ep.empty() );
604 CPPUNIT_ASSERT( l.empty() );
608 CPPUNIT_CHECK( !l.get( a[0] ));
610 ep = l.extract( a[0] );
611 CPPUNIT_CHECK( !ep );
612 CPPUNIT_CHECK( ep.empty() );
614 // Apply retired pointer
615 OrdList::gc::force_dispose();
617 // extract_with/get_with
618 for ( int i = 0; i < nLimit; ++i ) {
619 CPPUNIT_ASSERT( l.insert( arrItem[i] ) );
622 for ( int i = 0; i < nLimit; ++i ) {
623 other_item itm( a[i] );
626 rp = l.get_with( itm, other_less() );
627 CPPUNIT_ASSERT( rp );
628 CPPUNIT_CHECK( rp->nKey == a[i] );
629 CPPUNIT_CHECK( rp->nVal == a[i] * 2 );
633 ep = l.extract_with( itm, other_less() );
634 CPPUNIT_ASSERT( ep );
635 CPPUNIT_ASSERT( !ep.empty() );
636 CPPUNIT_CHECK( ep->nKey == a[i] );
637 CPPUNIT_CHECK( ep->nVal == a[i] * 2 );
642 CPPUNIT_CHECK( !l.get_with( itm, other_less() ));
644 ep = l.extract_with( itm, other_less() );
645 CPPUNIT_CHECK( !ep );
646 CPPUNIT_CHECK( ep.empty() );
648 CPPUNIT_ASSERT( l.empty() );
652 CPPUNIT_CHECK( !l.get_with( other_item( 0 ), other_less() ));
654 CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() ));
655 CPPUNIT_CHECK( ep.empty() );
657 // Apply retired pointer
658 OrdList::gc::force_dispose();
662 template <class OrdList>
665 typedef typename OrdList::value_type value_type;
667 value_type v1( 10, 50 );
668 value_type v2( 5, 25 );
669 value_type v3( 20, 100 );
672 CPPUNIT_ASSERT( l.empty() );
674 CPPUNIT_ASSERT( l.insert( v1 )) ; // true
675 CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 );
677 CPPUNIT_ASSERT( v1.s.nFindCall == 0 );
678 CPPUNIT_ASSERT( l.find( v1.key(), find_functor() ));
679 CPPUNIT_ASSERT( v1.s.nFindCall == 1 );
681 CPPUNIT_ASSERT( l.find_with( v2.key(), less<value_type>() ) == nullptr );
682 CPPUNIT_ASSERT( !l.find_with( v3.key(), less<value_type>(), find_functor() ));
683 CPPUNIT_ASSERT( !l.empty() );
685 CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is not raised since pNext is nullptr
689 CPPUNIT_ASSERT( !l.insert( v )) ; // false
692 std::pair<bool, bool> ret = l.ensure( v2, ensure_functor() );
693 CPPUNIT_ASSERT( ret.first );
694 CPPUNIT_ASSERT( ret.second );
695 CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 );
696 CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 );
698 //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty"
700 CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ) ; // true
702 CPPUNIT_ASSERT( v1.s.nFindCall == 1 );
703 CPPUNIT_ASSERT( l.find( v1.key(), find_functor() ));
704 CPPUNIT_ASSERT( v1.s.nFindCall == 2 );
706 CPPUNIT_ASSERT( l.find( v2.key() ) == &v2 );
708 CPPUNIT_ASSERT( v2.s.nFindCall == 0 );
709 CPPUNIT_ASSERT( l.find( v2.key(), find_functor() ));
710 CPPUNIT_ASSERT( v2.s.nFindCall == 1 );
712 CPPUNIT_ASSERT( !l.find( v3.key() ));
716 ret = l.ensure( v, ensure_functor() );
718 CPPUNIT_ASSERT( ret.first );
719 CPPUNIT_ASSERT( !ret.second );
720 CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 );
721 CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 && v.s.nEnsureNewCall == 0 );
724 CPPUNIT_ASSERT( !l.empty() );
726 CPPUNIT_ASSERT( l.insert( v3 )) ; // true
727 CPPUNIT_ASSERT( l.find( v3.key() ) == &v3 );
729 CPPUNIT_ASSERT( v3.s.nFindCall == 0 );
730 CPPUNIT_ASSERT( l.find( v3.key(), find_functor() ));
731 CPPUNIT_ASSERT( v3.s.nFindCall == 1 );
734 typename OrdList::iterator it = l.begin();
735 typename OrdList::const_iterator cit = l.cbegin();
736 CPPUNIT_ASSERT( it != l.end() );
737 CPPUNIT_ASSERT( it != l.cend() );
738 CPPUNIT_ASSERT( cit != l.end() );
739 CPPUNIT_ASSERT( cit != l.cend() );
740 CPPUNIT_ASSERT( cit == it );
742 CPPUNIT_ASSERT( it->nKey == v2.nKey );
743 CPPUNIT_ASSERT( it->nVal == v2.nVal );
744 CPPUNIT_ASSERT( ++it != l.end() );
745 CPPUNIT_ASSERT( it->nKey == v1.nKey );
746 CPPUNIT_ASSERT( it->nVal == v1.nVal );
747 CPPUNIT_ASSERT( it++ != l.end() );
748 CPPUNIT_ASSERT( it->nKey == v3.nKey );
749 CPPUNIT_ASSERT( it->nVal == v3.nVal );
750 CPPUNIT_ASSERT( it++ != l.end() );
751 CPPUNIT_ASSERT( it == l.end() );
755 OrdList const & lref = l;
756 typename OrdList::const_iterator it = lref.begin();
757 CPPUNIT_ASSERT( it != l.end() );
758 CPPUNIT_ASSERT( it->nKey == v2.nKey );
759 CPPUNIT_ASSERT( it->nVal == v2.nVal );
760 CPPUNIT_ASSERT( ++it != lref.end() );
761 CPPUNIT_ASSERT( it->nKey == v1.nKey );
762 CPPUNIT_ASSERT( it->nVal == v1.nVal );
763 CPPUNIT_ASSERT( it++ != l.end() );
764 CPPUNIT_ASSERT( it->nKey == v3.nKey );
765 CPPUNIT_ASSERT( it->nVal == v3.nVal );
766 CPPUNIT_ASSERT( it++ != lref.end() );
767 CPPUNIT_ASSERT( it == l.end() );
771 // Disposer called on list destruction
772 CPPUNIT_ASSERT( v1.s.nDisposeCount == 1 );
773 CPPUNIT_ASSERT( v2.s.nDisposeCount == 1 );
774 CPPUNIT_ASSERT( v3.s.nDisposeCount == 1 );
780 void HP_base_cmpmix();
782 void HP_member_cmp();
783 void HP_member_less();
784 void HP_member_cmpmix();
788 void DHP_base_less();
789 void DHP_base_cmpmix();
791 void DHP_member_cmp();
792 void DHP_member_less();
793 void DHP_member_cmpmix();
794 void DHP_member_ic();
796 void RCU_GPI_base_cmp();
797 void RCU_GPI_base_less();
798 void RCU_GPI_base_cmpmix();
799 void RCU_GPI_base_ic();
800 void RCU_GPI_member_cmp();
801 void RCU_GPI_member_less();
802 void RCU_GPI_member_cmpmix();
803 void RCU_GPI_member_ic();
805 void RCU_GPB_base_cmp();
806 void RCU_GPB_base_less();
807 void RCU_GPB_base_cmpmix();
808 void RCU_GPB_base_ic();
809 void RCU_GPB_member_cmp();
810 void RCU_GPB_member_less();
811 void RCU_GPB_member_cmpmix();
812 void RCU_GPB_member_ic();
814 void RCU_GPT_base_cmp();
815 void RCU_GPT_base_less();
816 void RCU_GPT_base_cmpmix();
817 void RCU_GPT_base_ic();
818 void RCU_GPT_member_cmp();
819 void RCU_GPT_member_less();
820 void RCU_GPT_member_cmpmix();
821 void RCU_GPT_member_ic();
823 void RCU_SHB_base_cmp();
824 void RCU_SHB_base_less();
825 void RCU_SHB_base_cmpmix();
826 void RCU_SHB_base_ic();
827 void RCU_SHB_member_cmp();
828 void RCU_SHB_member_less();
829 void RCU_SHB_member_cmpmix();
830 void RCU_SHB_member_ic();
832 void RCU_SHT_base_cmp();
833 void RCU_SHT_base_less();
834 void RCU_SHT_base_cmpmix();
835 void RCU_SHT_base_ic();
836 void RCU_SHT_member_cmp();
837 void RCU_SHT_member_less();
838 void RCU_SHT_member_cmpmix();
839 void RCU_SHT_member_ic();
841 void nogc_base_cmp();
842 void nogc_base_less();
843 void nogc_base_cmpmix();
845 void nogc_member_cmp();
846 void nogc_member_less();
847 void nogc_member_cmpmix();
848 void nogc_member_ic();
851 CPPUNIT_TEST_SUITE(IntrusiveMichaelListHeaderTest)
852 CPPUNIT_TEST(HP_base_cmp)
853 CPPUNIT_TEST(HP_base_less)
854 CPPUNIT_TEST(HP_base_cmpmix)
855 CPPUNIT_TEST(HP_base_ic)
856 CPPUNIT_TEST(HP_member_cmp)
857 CPPUNIT_TEST(HP_member_less)
858 CPPUNIT_TEST(HP_member_cmpmix)
859 CPPUNIT_TEST(HP_member_ic)
861 CPPUNIT_TEST(DHP_base_cmp)
862 CPPUNIT_TEST(DHP_base_less)
863 CPPUNIT_TEST(DHP_base_cmpmix)
864 CPPUNIT_TEST(DHP_base_ic)
865 CPPUNIT_TEST(DHP_member_cmp)
866 CPPUNIT_TEST(DHP_member_less)
867 CPPUNIT_TEST(DHP_member_cmpmix)
868 CPPUNIT_TEST(DHP_member_ic)
870 CPPUNIT_TEST(RCU_GPI_base_cmp)
871 CPPUNIT_TEST(RCU_GPI_base_less)
872 CPPUNIT_TEST(RCU_GPI_base_cmpmix)
873 CPPUNIT_TEST(RCU_GPI_base_ic)
874 CPPUNIT_TEST(RCU_GPI_member_cmp)
875 CPPUNIT_TEST(RCU_GPI_member_less)
876 CPPUNIT_TEST(RCU_GPI_member_cmpmix)
877 CPPUNIT_TEST(RCU_GPI_member_ic)
879 CPPUNIT_TEST(RCU_GPB_base_cmp)
880 CPPUNIT_TEST(RCU_GPB_base_less)
881 CPPUNIT_TEST(RCU_GPB_base_cmpmix)
882 CPPUNIT_TEST(RCU_GPB_base_ic)
883 CPPUNIT_TEST(RCU_GPB_member_cmp)
884 CPPUNIT_TEST(RCU_GPB_member_less)
885 CPPUNIT_TEST(RCU_GPB_member_cmpmix)
886 CPPUNIT_TEST(RCU_GPB_member_ic)
888 CPPUNIT_TEST(RCU_GPT_base_cmp)
889 CPPUNIT_TEST(RCU_GPT_base_less)
890 CPPUNIT_TEST(RCU_GPT_base_cmpmix)
891 CPPUNIT_TEST(RCU_GPT_base_ic)
892 CPPUNIT_TEST(RCU_GPT_member_cmp)
893 CPPUNIT_TEST(RCU_GPT_member_less)
894 CPPUNIT_TEST(RCU_GPT_member_cmpmix)
895 CPPUNIT_TEST(RCU_GPT_member_ic)
897 CPPUNIT_TEST(nogc_base_cmp)
898 CPPUNIT_TEST(nogc_base_less)
899 CPPUNIT_TEST(nogc_base_cmpmix)
900 CPPUNIT_TEST(nogc_base_ic)
901 CPPUNIT_TEST(nogc_member_cmp)
902 CPPUNIT_TEST(nogc_member_less)
903 CPPUNIT_TEST(nogc_member_cmpmix)
904 CPPUNIT_TEST(nogc_member_ic)
906 CPPUNIT_TEST_SUITE_END()
908 } // namespace ordlist
910 #endif // CDSTEST_HDR_INTRUSIVE_MICHAEL_H