From 5b1423b260fb92f38ad7c15d90bc3e84859f95bd Mon Sep 17 00:00:00 2001 From: khizmax Date: Sun, 2 Nov 2014 17:51:40 +0300 Subject: [PATCH] Unit tests for set are only with C++11 std::set and std::unordered_set --- projects/Win/vc12/cds.sln | 2 -- .../set2/{std_hash_set_std.h => std_hash_set.h} | 1 - tests/unit/set2/std_set.h | 15 +++++++-------- 3 files changed, 7 insertions(+), 11 deletions(-) rename tests/unit/set2/{std_hash_set_std.h => std_hash_set.h} (98%) diff --git a/projects/Win/vc12/cds.sln b/projects/Win/vc12/cds.sln index 8789bdbb..7bead727 100644 --- a/projects/Win/vc12/cds.sln +++ b/projects/Win/vc12/cds.sln @@ -79,8 +79,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "set", "set", "{A64449B7-90F ..\..\..\tests\unit\set2\set_defs.h = ..\..\..\tests\unit\set2\set_defs.h ..\..\..\tests\unit\set2\set_types.h = ..\..\..\tests\unit\set2\set_types.h ..\..\..\tests\unit\set2\std_hash_set.h = ..\..\..\tests\unit\set2\std_hash_set.h - ..\..\..\tests\unit\set2\std_hash_set_std.h = ..\..\..\tests\unit\set2\std_hash_set_std.h - ..\..\..\tests\unit\set2\std_hash_set_vc9.h = ..\..\..\tests\unit\set2\std_hash_set_vc9.h ..\..\..\tests\unit\set2\std_set.h = ..\..\..\tests\unit\set2\std_set.h EndProjectSection EndProject diff --git a/tests/unit/set2/std_hash_set_std.h b/tests/unit/set2/std_hash_set.h similarity index 98% rename from tests/unit/set2/std_hash_set_std.h rename to tests/unit/set2/std_hash_set.h index 611e76b0..dcc6c422 100644 --- a/tests/unit/set2/std_hash_set_std.h +++ b/tests/unit/set2/std_hash_set.h @@ -4,7 +4,6 @@ #define __CDSUNIT_STD_HASH_SET_STD_H #include -#include // ref #include //unique_lock namespace set2 { diff --git a/tests/unit/set2/std_set.h b/tests/unit/set2/std_set.h index fa9a270d..096b121f 100644 --- a/tests/unit/set2/std_set.h +++ b/tests/unit/set2/std_set.h @@ -4,7 +4,6 @@ #define __CDSUNIT_STD_SET_VC_H #include -#include // ref #include //unique_lock namespace set2 { @@ -14,7 +13,7 @@ namespace set2 { class StdSet: public std::set { Lock m_lock; - typedef std::unique_lock AutoLock; + typedef std::unique_lock scoped_lock; typedef std::set base_class; public: typedef typename base_class::key_type value_type; @@ -26,20 +25,20 @@ namespace set2 { bool find( const Key& key ) { value_type v( key ); - AutoLock al( m_lock ); + scoped_lock al( m_lock ); return base_class::find( v ) != base_class::end(); } bool insert( value_type const& v ) { - AutoLock al( m_lock ); + scoped_lock al( m_lock ); return base_class::insert( v ).second; } template bool insert( Key const& key, Func func ) { - AutoLock al( m_lock ); + scoped_lock al( m_lock ); std::pair pRet = base_class::insert( value_type( key )); if ( pRet.second ) { func( *pRet.first ); @@ -51,7 +50,7 @@ namespace set2 { template std::pair ensure( const T& key, Func func ) { - AutoLock al( m_lock ); + scoped_lock al( m_lock ); std::pair pRet = base_class::insert( value_type( key )); if ( pRet.second ) { func( true, *pRet.first, key ); @@ -66,14 +65,14 @@ namespace set2 { template bool erase( const Key& key ) { - AutoLock al( m_lock ); + scoped_lock al( m_lock ); return base_class::erase( value_type(key) ) != 0; } template bool erase( const T& key, Func func ) { - AutoLock al( m_lock ); + scoped_lock al( m_lock ); typename base_class::iterator it = base_class::find( value_type(key) ); if ( it != base_class::end() ) { func( *it ); -- 2.34.1