From: khizmax Date: Mon, 30 Mar 2015 15:48:17 +0000 (+0300) Subject: Removed test-hdr/unordered_list dir X-Git-Tag: v2.1.0~290 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=51e33192f0c3d984c3dd78e77911561191e40739;p=libcds.git Removed test-hdr/unordered_list dir Fixed build script --- diff --git a/projects/source.test-hdr.mk b/projects/source.test-hdr.mk index 4be0271f..0f27e11f 100644 --- a/projects/source.test-hdr.mk +++ b/projects/source.test-hdr.mk @@ -73,6 +73,7 @@ CDS_TESTHDR_LIST := \ tests/test-hdr/list/hdr_lazy_kv_dhp.cpp \ tests/test-hdr/list/hdr_lazy_kv_hp.cpp \ tests/test-hdr/list/hdr_lazy_kv_nogc.cpp \ + tests/test-hdr/list/hdr_lazy_kv_nogc_unord.cpp \ tests/test-hdr/list/hdr_lazy_kv_rcu_gpb.cpp \ tests/test-hdr/list/hdr_lazy_kv_rcu_gpi.cpp \ tests/test-hdr/list/hdr_lazy_kv_rcu_gpt.cpp \ @@ -95,9 +96,6 @@ CDS_TESTHDR_LIST := \ tests/test-hdr/list/hdr_michael_kv_rcu_shb.cpp \ tests/test-hdr/list/hdr_michael_kv_rcu_sht.cpp -CDS_TESTHDR_UNORDLIST := \ - tests/test-hdr/unordered_list/hdr_lazy_kv_nogc.cpp - CDS_TESTHDR_PQUEUE := \ tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_dyn.cpp \ tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_static.cpp \ diff --git a/tests/test-hdr/unordered_list/hdr_intrusive_lazy.h b/tests/test-hdr/unordered_list/hdr_intrusive_lazy.h deleted file mode 100644 index 9f1f96c7..00000000 --- a/tests/test-hdr/unordered_list/hdr_intrusive_lazy.h +++ /dev/null @@ -1,354 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSTEST_HDR_INTRUSIVE_LAZY_H -#define CDSTEST_HDR_INTRUSIVE_LAZY_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace unordlist { - namespace ci = cds::intrusive; - namespace co = cds::opt; - - struct stat { - int nDisposeCount; - int nEnsureExistsCall; - int nEnsureNewCall; - int nFindCall; - int nEraseCall; - - stat() - : nDisposeCount(0) - , nEnsureExistsCall(0) - , nEnsureNewCall(0) - , nFindCall(0) - , nEraseCall(0) - {} - - stat( const stat& s ) - { - *this = s; - } - - stat& operator =(const stat& s) - { - memcpy( this, &s, sizeof(s)); - return *this; - } - }; - - template - struct base_int_item: public ci::lazy_list::node< GC > - { - int nKey; - int nVal; - - mutable stat s; - - base_int_item() - {} - - base_int_item(int key, int val) - : nKey( key ) - , nVal(val) - , s() - {} - - base_int_item(const base_int_item& v ) - : nKey( v.nKey ) - , nVal( v.nVal ) - , s() - {} - - const int& key() const - { - return nKey; - } - - operator int() const - { return nKey; } - }; - - template - struct member_int_item - { - int nKey; - int nVal; - - ci::lazy_list::node< GC > hMember; - - mutable stat s; - - member_int_item() - {} - - member_int_item(int key, int val) - : nKey( key ) - , nVal(val) - , s() - {} - - member_int_item(const member_int_item& v ) - : nKey( v.nKey ) - , nVal( v.nVal ) - , s() - {} - - const int& key() const - { - return nKey; - } - - operator int() const - { return nKey; } - }; - - template - struct less - { - bool operator ()(const T& v1, const T& v2 ) const - { - return v1.key() < v2.key(); - } - - template - bool operator ()(const T& v1, const Q& v2 ) const - { - return v1.key() < v2; - } - - template - bool operator ()(const Q& v1, const T& v2 ) const - { - return v1 < v2.key(); - } - }; - - template - struct cmp { - int operator ()(const T& v1, const T& v2 ) const - { - if ( v1.key() < v2.key() ) - return -1; - return v1.key() > v2.key() ? 1 : 0; - } - - template - int operator ()(const T& v1, const Q& v2 ) const - { - if ( v1.key() < v2 ) - return -1; - return v1.key() > v2 ? 1 : 0; - } - - template - int operator ()(const Q& v1, const T& v2 ) const - { - if ( v1 < v2.key() ) - return -1; - return v1 > v2.key() ? 1 : 0; - } - }; - - template - struct equal_to { - bool operator()( T const& l, T const& r ) const - { - return l.key() == r.key(); - } - - template - bool operator()( Q const& l, T const& r ) const - { - return l == r.key(); - } - - template - bool operator()( T const& l, Q const& r ) const - { - return l.key() == r; - } - }; - - struct faked_disposer - { - template - void operator ()( T * p ) - { - ++p->s.nDisposeCount; - } - }; - - struct ensure_functor - { - template - void operator ()(bool bNew, T& item, T& /*val*/ ) - { - if ( bNew ) - ++item.s.nEnsureNewCall; - else - ++item.s.nEnsureExistsCall; - } - }; - - struct find_functor - { - template - void operator ()( T& item, Q& /*val*/ ) - { - ++item.s.nFindCall; - } - }; - - class UnorderedIntrusiveLazyListHeaderTest: public CppUnitMini::TestCase - { - public: - template - void test_nogc_int() - { - typedef typename UnordList::value_type value_type; - { - value_type v1( 10, 50 ); - value_type v2( 5, 25 ); - value_type v3( 20, 100 ); - { - UnordList l; - CPPUNIT_ASSERT( l.empty() ); - - CPPUNIT_ASSERT( l.insert( v1 )); // true - CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ); - - CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( l.find_with( v2.key(), equal_to() ) == nullptr ); - CPPUNIT_ASSERT( l.find( v3.key() ) == nullptr ); - CPPUNIT_ASSERT( !l.empty() ); - - //CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is raised - - { - value_type v( v1 ); - CPPUNIT_ASSERT( !l.insert( v )) ; // false - } - - std::pair ret = l.ensure( v2, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); - - //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" - - CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ) ; // true - - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); - - CPPUNIT_ASSERT( l.find_with( v2.key(), equal_to() ) == &v2 ); - - CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find_with( v2.key(), equal_to(), find_functor() )); - CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( !l.find( v3.key() )); - - { - value_type v( v2 ); - ret = l.ensure( v, ensure_functor() ); - - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( !ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); - CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 && v.s.nEnsureNewCall == 0 ); - } - - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.insert( v3 )) ; // true - CPPUNIT_ASSERT( l.find( v3.key() ) == &v3 ); - - CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); - CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); - - { - typename UnordList::iterator it = l.begin(); - typename UnordList::const_iterator cit = l.cbegin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it != l.cend() ); - CPPUNIT_ASSERT( cit != l.end() ); - CPPUNIT_ASSERT( cit != l.cend() ); - CPPUNIT_ASSERT( cit == it ); - - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( ++it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( it++ != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( it++ != l.end() ); - CPPUNIT_ASSERT( it == l.end() ); - } - - { - UnordList const & lref = l; - typename UnordList::const_iterator it = lref.begin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( ++it != lref.end() ); - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( it++ != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( it++ != lref.end() ); - CPPUNIT_ASSERT( it == l.end() ); - } - } - - // Disposer called on list destruction - CPPUNIT_ASSERT( v1.s.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v2.s.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v3.s.nDisposeCount == 1 ); - } - } - - void nogc_base_cmp(); - void nogc_base_less(); - void nogc_base_equal_to(); - void nogc_base_cmpmix(); - void nogc_base_equal_to_mix(); - void nogc_base_ic(); - void nogc_member_cmp(); - void nogc_member_less(); - void nogc_member_equal_to(); - void nogc_member_cmpmix(); - void nogc_member_equal_to_mix(); - void nogc_member_ic(); - - CPPUNIT_TEST_SUITE(UnorderedIntrusiveLazyListHeaderTest) - - CPPUNIT_TEST(nogc_base_cmp) - CPPUNIT_TEST(nogc_base_less) - CPPUNIT_TEST(nogc_base_equal_to) - CPPUNIT_TEST(nogc_base_cmpmix) - CPPUNIT_TEST(nogc_base_equal_to_mix) - CPPUNIT_TEST(nogc_base_ic) - CPPUNIT_TEST(nogc_member_cmp) - CPPUNIT_TEST(nogc_member_less) - CPPUNIT_TEST(nogc_member_equal_to) - CPPUNIT_TEST(nogc_member_cmpmix) - CPPUNIT_TEST(nogc_member_equal_to_mix) - CPPUNIT_TEST(nogc_member_ic) - - CPPUNIT_TEST_SUITE_END() - }; -} // namespace unordlist - -#endif // #ifndef CDSTEST_HDR_INTRUSIVE_LAZY_H diff --git a/tests/test-hdr/unordered_list/hdr_intrusive_lazy_nogc.cpp b/tests/test-hdr/unordered_list/hdr_intrusive_lazy_nogc.cpp deleted file mode 100644 index d519e602..00000000 --- a/tests/test-hdr/unordered_list/hdr_intrusive_lazy_nogc.cpp +++ /dev/null @@ -1,168 +0,0 @@ -//$$CDS-header$$ - -#include "unordered_list/hdr_intrusive_lazy.h" -#include - -namespace unordlist { - namespace { - typedef base_int_item< cds::gc::nogc > base_item; - typedef member_int_item< cds::gc::nogc > member_item; - - struct cmp_traits : public ci::lazy_list::traits { - typedef ci::lazy_list::base_hook< co::gc > hook; - typedef unordlist::cmp compare; - typedef faked_disposer disposer; - static const bool sort = false; - }; - - struct less_traits: public ci::lazy_list::traits { - typedef ci::lazy_list::base_hook< co::gc > hook; - typedef unordlist::less less; - typedef faked_disposer disposer; - static const bool sort = false; - }; - - struct equal_to_traits: public ci::lazy_list::traits { - typedef ci::lazy_list::base_hook< co::gc > hook; - typedef unordlist::equal_to equal_to; - typedef faked_disposer disposer; - static const bool sort = false; - }; - - typedef typename ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::sort< false > >::type cmpmix_traits; - - typedef typename ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::compare< cmp > - ,co::equal_to< equal_to > - ,ci::opt::disposer< faked_disposer > - ,co::sort< false > >::type equal_to_mix_traits; - - typedef typename ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::equal_to< equal_to > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - ,co::sort< false > >::type ic_traits; - - typedef typename ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( member_item, hMember ) - ,co::gc > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::sort< false > >::type member_cmp_traits; - - typedef typename ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( member_item, hMember ) - ,co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - ,co::sort< false > >::type member_less_traits; - - typedef typename ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( member_item, hMember ) - ,co::gc > > - ,co::equal_to< equal_to > - ,ci::opt::disposer< faked_disposer > - ,co::sort< false > >::type member_equal_to_traits; - - typedef typename ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( member_item, hMember ) - ,co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::sort< false > >::type member_cmpmix_traits; - - typedef typename ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( member_item, hMember ) - ,co::gc > > - ,co::compare< cmp > - ,co::equal_to< equal_to > - ,ci::opt::disposer< faked_disposer > - ,co::sort< false > >::type member_equal_to_mix_traits; - - typedef typename ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( member_item, hMember ), - co::gc > > - ,co::equal_to< equal_to > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - ,co::sort< false > >::type member_ic_traits; - - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_base_cmp() - { - typedef ci::LazyList< cds::gc::nogc, base_item, cmp_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_base_less() - { - typedef ci::LazyList< cds::gc::nogc, base_item, less_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_base_equal_to() - { - typedef ci::LazyList< cds::gc::nogc, base_item, equal_to_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_base_cmpmix() - { - typedef ci::LazyList< cds::gc::nogc, base_item, cmpmix_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_base_equal_to_mix() - { - typedef ci::LazyList< cds::gc::nogc, base_item, equal_to_mix_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_base_ic() - { - typedef ci::LazyList< cds::gc::nogc, base_item, ic_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_member_cmp() - { - typedef ci::LazyList< cds::gc::nogc, member_item, member_cmp_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_member_less() - { - typedef ci::LazyList< cds::gc::nogc, member_item, member_less_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_member_equal_to() - { - typedef ci::LazyList< cds::gc::nogc, member_item, member_equal_to_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_member_cmpmix() - { - typedef ci::LazyList< cds::gc::nogc, member_item, member_cmpmix_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_member_equal_to_mix() - { - typedef ci::LazyList< cds::gc::nogc, member_item, member_equal_to_mix_traits > list; - test_nogc_int(); - } - void UnorderedIntrusiveLazyListHeaderTest::nogc_member_ic() - { - typedef ci::LazyList< cds::gc::nogc, member_item, member_ic_traits > list; - test_nogc_int(); - } - -} // namespace unordlist - -CPPUNIT_TEST_SUITE_REGISTRATION(unordlist::UnorderedIntrusiveLazyListHeaderTest); diff --git a/tests/test-hdr/unordered_list/hdr_lazy.h b/tests/test-hdr/unordered_list/hdr_lazy.h deleted file mode 100644 index 7321c08d..00000000 --- a/tests/test-hdr/unordered_list/hdr_lazy.h +++ /dev/null @@ -1,238 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSTEST_HDR_LAZY_H -#define CDSTEST_HDR_LAZY_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace unordlist { - namespace cc = cds::container; - namespace co = cds::container::opt; - - class UnorderedLazyListTestHeader: public CppUnitMini::TestCase - { - public: - struct stat { - int nEnsureExistsCall; - int nEnsureNewCall; - - stat() - { - nEnsureExistsCall - = nEnsureNewCall - = 0; - } - }; - - struct item { - int nKey; - int nVal; - - stat s; - - item(int key) - : nKey( key ) - , nVal( key * 2 ) - , s() - {} - - item(int key, int val) - : nKey( key ) - , nVal(val) - , s() - {} - - item( item const& v ) - : nKey( v.nKey ) - , nVal( v.nVal ) - , s() - {} - - int key() const - { - return nKey; - } - }; - - template - struct lt - { - bool operator ()(const T& v1, const T& v2 ) const - { - return v1.key() < v2.key(); - } - - template - bool operator ()(const T& v1, const Q& v2 ) const - { - return v1.key() < v2; - } - - template - bool operator ()(const Q& v1, const T& v2 ) const - { - return v1 < v2.key(); - } - }; - - template - struct cmp { - int operator ()(const T& v1, const T& v2 ) const - { - if ( v1.key() < v2.key() ) - return -1; - return v1.key() > v2.key() ? 1 : 0; - } - - template - int operator ()(const T& v1, const Q& v2 ) const - { - if ( v1.key() < v2 ) - return -1; - return v1.key() > v2 ? 1 : 0; - } - - template - int operator ()(const Q& v1, const T& v2 ) const - { - if ( v1 < v2.key() ) - return -1; - return v1 > v2.key() ? 1 : 0; - } - }; - - template - struct equal_to { - int operator ()(const T& v1, const T& v2 ) const - { - return v1.key() == v2.key(); - } - - template - int operator ()(const T& v1, const Q& v2 ) const - { - return v1.key() == v2; - } - - template - int operator ()(const Q& v1, const T& v2 ) const - { - return v1 == v2.key(); - } - }; - - protected: - template - void nogc_test() - { - typedef UnordList list; - typedef typename list::value_type value_type; - typedef std::pair ensure_result; - - typename list::iterator it; - - list l; - CPPUNIT_ASSERT( l.empty() ); - CPPUNIT_ASSERT( l.insert(50) != l.end() ); - CPPUNIT_ASSERT( !l.empty() ); - - ensure_result eres = l.ensure( item(100, 33) ); - CPPUNIT_ASSERT( eres.second ); - CPPUNIT_ASSERT( eres.first != l.end() ); - CPPUNIT_ASSERT( l.insert( item(150) ) != l.end() ); - - CPPUNIT_ASSERT( l.insert(100) == l.end() ); - eres = l.ensure( item(50, 33) ); - CPPUNIT_ASSERT( !eres.second ); - CPPUNIT_ASSERT( eres.first->nVal == eres.first->nKey * 2 ); - eres.first->nVal = 63; - - it = l.find( 33 ); - CPPUNIT_ASSERT( it == l.end() ); - - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 50 ); - CPPUNIT_ASSERT( it->nVal == 63 ); - - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 100 ); - CPPUNIT_ASSERT( it->nVal == 33 ); - - it = l.find_with( 150, equal_to() ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 150 ); - CPPUNIT_ASSERT( it->nVal == it->nKey * 2 ); - - CPPUNIT_ASSERT( !l.empty() ); - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); - CPPUNIT_ASSERT( l.emplace( item( 1001 )) != l.end()); - - // insert failed - such key exists - CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); - - it = l.find( 501 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 501 ); - CPPUNIT_ASSERT( it->nVal == 501 * 2 ); - - it = l.find( 1001 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 1001 ); - CPPUNIT_ASSERT( it->nVal == 1001 * 2 ); - - { - typename UnordList::iterator it( l.begin() ); - typename UnordList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - - void NOGC_cmp(); - void NOGC_less(); - void NOGC_equal_to(); - void NOGC_cmpmix(); - void NOGC_equal_to_mix(); - void NOGC_ic(); - - CPPUNIT_TEST_SUITE(UnorderedLazyListTestHeader) - CPPUNIT_TEST(NOGC_cmp) - CPPUNIT_TEST(NOGC_less) - CPPUNIT_TEST(NOGC_equal_to) - CPPUNIT_TEST(NOGC_cmpmix) - CPPUNIT_TEST(NOGC_equal_to_mix) - CPPUNIT_TEST(NOGC_ic) - CPPUNIT_TEST_SUITE_END() - }; - -} // namespace unordlist - -#endif // #ifndef CDSTEST_HDR_LAZY_H diff --git a/tests/test-hdr/unordered_list/hdr_lazy_kv.h b/tests/test-hdr/unordered_list/hdr_lazy_kv.h deleted file mode 100644 index ab37f57f..00000000 --- a/tests/test-hdr/unordered_list/hdr_lazy_kv.h +++ /dev/null @@ -1,264 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSTEST_HDR_LAZY_KV_H -#define CDSTEST_HDR_LAZY_KV_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace unordlist { - namespace cc = cds::container; - namespace co = cds::container::opt; - - class UnorderedLazyKVListTestHeader: public CppUnitMini::TestCase - { - public: - typedef int key_type; - struct value_type { - int m_val; - - value_type() - : m_val(0) - {} - - value_type( int n ) - : m_val( n ) - {} - }; - - template - struct lt - { - bool operator ()(const T& v1, const T& v2 ) const - { - return v1 < v2; - } - }; - - template - struct cmp { - int operator ()(const T& v1, const T& v2 ) const - { - if ( v1 < v2 ) - return -1; - return v1 > v2 ? 1 : 0; - } - }; - - template - struct eq { - bool operator ()(const T& v1, const T& v2 ) const - { - return v1 == v2; - } - }; - - struct insert_functor { - template - void operator()( T& pair ) - { - pair.second.m_val = pair.first * 10; - } - }; - - protected: - template - void nogc_test() - { - typedef typename UnordList::value_type value_type; - typedef typename UnordList::iterator iterator; - - { - UnordList l; - iterator it; - - CPPUNIT_ASSERT( l.empty() ); - - // insert / find test - CPPUNIT_ASSERT( l.find( 100 ) == l.end() ); - CPPUNIT_ASSERT( l.insert( 100 ) != l.end() ); - CPPUNIT_ASSERT( !l.empty() ); - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 100 ); - CPPUNIT_ASSERT( it.val().m_val == 0 ); - - CPPUNIT_ASSERT( l.find_with( 50, eq() ) == l.end() ); - CPPUNIT_ASSERT( l.insert( 50, 500 ) != l.end()); - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 500 ); - - CPPUNIT_ASSERT( l.insert( 50, 5 ) == l.end() ); - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 500 ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.find( 150 ) == l.end() ); - CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ) != l.end() ); - it = l.find( 150 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 150 ); - CPPUNIT_ASSERT( it.val().m_val == 1500 ); - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 100 ); - CPPUNIT_ASSERT( it.val().m_val == 0 ); - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 500 ); - it.val().m_val = 25; - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 25 ); - CPPUNIT_ASSERT( !l.empty() ); - - // ensure existing item - std::pair ensureResult; - ensureResult = l.ensure( 100 ); - CPPUNIT_ASSERT( !ensureResult.second ); - CPPUNIT_ASSERT( ensureResult.first.key() == 100 ); - CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); - ensureResult.first.val().m_val = 5; - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 100 ); - CPPUNIT_ASSERT( it.val().m_val == 5 ); - - CPPUNIT_ASSERT( !l.empty() ); - - // ensure new item - ensureResult = l.ensure( 1000 ); - CPPUNIT_ASSERT( ensureResult.second ); - CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); - CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); - ensureResult.first.val().m_val = 33; - ensureResult = l.ensure( 1000 ); - CPPUNIT_ASSERT( !ensureResult.second ); - CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); - CPPUNIT_ASSERT( ensureResult.first.val().m_val == 33 ); - - // clear test - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); - - // insert failed - such key exists - CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); - - it = l.find(501); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 501 ); - CPPUNIT_ASSERT( it.val().m_val == 0 ); - - it = l.find(251); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 251 ); - CPPUNIT_ASSERT( it.val().m_val == 152 ); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Iterator test - { - int nCount = 100; - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 2 ) != l.end() ); - - { - typename UnordList::iterator it( l.begin() ); - typename UnordList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - int i = 0; - for ( typename UnordList::iterator iter = l.begin(), itEnd = l.end(); iter != itEnd; ++iter, ++i ) { - CPPUNIT_ASSERT( iter.key() == i ); - CPPUNIT_ASSERT( iter->first == i ); - CPPUNIT_ASSERT( (*iter).first == i ); - - CPPUNIT_ASSERT( iter.val().m_val == i * 2 ); - CPPUNIT_ASSERT( iter->second.m_val == i * 2 ); - CPPUNIT_ASSERT( (*iter).second.m_val == i * 2 ); - - iter.val().m_val = i * 3; - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) { - it = l.find( i ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == i ); - CPPUNIT_ASSERT( it.val().m_val == i * 3 ); - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Const iterator - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 7) != l.end() ); - - i = 0; - const UnordList& rl = l; - for ( typename UnordList::const_iterator iter = rl.begin(), itEnd = rl.end(); iter != itEnd; ++iter, ++i ) { - CPPUNIT_ASSERT( iter.key() == i ); - CPPUNIT_ASSERT( iter->first == i ); - CPPUNIT_ASSERT( (*iter).first == i ); - - CPPUNIT_ASSERT( iter.val().m_val == i * 7 ); - CPPUNIT_ASSERT( iter->second.m_val == i * 7 ); - CPPUNIT_ASSERT( (*iter).second.m_val == i * 7 ); - // it.val().m_val = i * 3 ; // error: const-iterator - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - - } - } - - void NOGC_cmp(); - void NOGC_less(); - void NOGC_equal_to(); - void NOGC_cmpmix(); - void NOGC_ic(); - - CPPUNIT_TEST_SUITE(UnorderedLazyKVListTestHeader) - CPPUNIT_TEST(NOGC_cmp) - CPPUNIT_TEST(NOGC_less) - CPPUNIT_TEST(NOGC_equal_to) - CPPUNIT_TEST(NOGC_cmpmix) - CPPUNIT_TEST(NOGC_ic) - CPPUNIT_TEST_SUITE_END() - }; - -} // namespace unordlist - -#endif // #ifndef CDSTEST_HDR_LAZY_KV_H diff --git a/tests/test-hdr/unordered_list/hdr_lazy_kv_nogc.cpp b/tests/test-hdr/unordered_list/hdr_lazy_kv_nogc.cpp deleted file mode 100644 index 66e0179d..00000000 --- a/tests/test-hdr/unordered_list/hdr_lazy_kv_nogc.cpp +++ /dev/null @@ -1,132 +0,0 @@ -//$$CDS-header$$ - -#include "unordered_list/hdr_lazy_kv.h" -#include - -namespace unordlist { - namespace { - struct NOGC_cmp_traits: public cc::lazy_list::traits - { - typedef UnorderedLazyKVListTestHeader::cmp compare; - static const bool sort = false; - }; - - } - void UnorderedLazyKVListTestHeader::NOGC_cmp() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_cmp_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyKVList< cds::gc::nogc, - key_type, - value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_less_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyKVListTestHeader::lt less; - static const bool sort = false; - }; - } - void UnorderedLazyKVListTestHeader::NOGC_less() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_less_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_equal_to_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyKVListTestHeader::eq equal_to; - static const bool sort = false; - }; - } - void UnorderedLazyKVListTestHeader::NOGC_equal_to() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_equal_to_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::equal_to< eq > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_cmpmix_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyKVListTestHeader::cmp compare; - typedef UnorderedLazyKVListTestHeader::lt less; - typedef UnorderedLazyKVListTestHeader::eq equal_to; - static const bool sort = false; - }; - } - void UnorderedLazyKVListTestHeader::NOGC_cmpmix() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_cmpmix_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - ,cc::opt::equal_to< eq > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_ic_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyKVListTestHeader::eq equal_to; - typedef cds::atomicity::item_counter item_counter; - static const bool sort = false; - }; - } - void UnorderedLazyKVListTestHeader::NOGC_ic() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_ic_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::equal_to< eq > - ,cc::opt::item_counter< cds::atomicity::item_counter > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - -} // namespace unordlist -CPPUNIT_TEST_SUITE_REGISTRATION(unordlist::UnorderedLazyKVListTestHeader); diff --git a/tests/test-hdr/unordered_list/hdr_lazy_nogc.cpp b/tests/test-hdr/unordered_list/hdr_lazy_nogc.cpp deleted file mode 100644 index c1538ab5..00000000 --- a/tests/test-hdr/unordered_list/hdr_lazy_nogc.cpp +++ /dev/null @@ -1,153 +0,0 @@ -//$$CDS-header$$ - -#include "unordered_list/hdr_lazy.h" -#include - -namespace unordlist { - namespace { - struct NOGC_cmp_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyListTestHeader::cmp compare; - static const bool sort = false; - }; - } - void UnorderedLazyListTestHeader::NOGC_cmp() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_cmp_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_less_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyListTestHeader::lt less; - static const bool sort = false; - }; - } - void UnorderedLazyListTestHeader::NOGC_less() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_less_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_equal_to_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyListTestHeader::equal_to equal_to; - static const bool sort = false; - }; - } - void UnorderedLazyListTestHeader::NOGC_equal_to() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_equal_to_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::equal_to< equal_to > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_cmpmix_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyListTestHeader::cmp compare; - typedef UnorderedLazyListTestHeader::lt less; - static const bool sort = false; - }; - } - void UnorderedLazyListTestHeader::NOGC_cmpmix() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_cmpmix_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_equal_to_mix_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyListTestHeader::cmp compare; - typedef UnorderedLazyListTestHeader::lt less; - typedef UnorderedLazyListTestHeader::equal_to equal_to; - static const bool sort = false; - }; - } - void UnorderedLazyListTestHeader::NOGC_equal_to_mix() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_equal_to_mix_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - ,cc::opt::equal_to< equal_to > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - namespace { - struct NOGC_ic_traits : public cc::lazy_list::traits - { - typedef UnorderedLazyListTestHeader::equal_to equal_to; - typedef cds::atomicity::item_counter item_counter; - static const bool sort = false; - }; - } - void UnorderedLazyListTestHeader::NOGC_ic() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_ic_traits > list; - nogc_test< list >(); - - // option-based version - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::equal_to< equal_to > - ,cc::opt::item_counter< cds::atomicity::item_counter > - ,cc::opt::sort - >::type - > opt_list; - nogc_test< opt_list >(); - } - -} // namespace unordlist -CPPUNIT_TEST_SUITE_REGISTRATION(unordlist::UnorderedLazyListTestHeader);