Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <gtest/gtest.h>
// push_front/pop_front
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_front( i ) );
+ EXPECT_TRUE( dq.push_front( i ));
EXPECT_EQ( dq.size(), c_nSize );
size_t nCount = 0;
int val;
- while ( !dq.empty() ) {
- EXPECT_TRUE( dq.pop_front( val ) );
+ while ( !dq.empty()) {
+ EXPECT_TRUE( dq.pop_front( val ));
++nCount;
EXPECT_EQ( static_cast<int>(c_nSize - nCount), val );
}
// push_back/pop_back
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_back( i ) );
+ EXPECT_TRUE( dq.push_back( i ));
EXPECT_EQ( dq.size(), c_nSize );
nCount = 0;
- while ( !dq.empty() ) {
- EXPECT_TRUE( dq.pop_back( val ) );
+ while ( !dq.empty()) {
+ EXPECT_TRUE( dq.pop_back( val ));
++nCount;
EXPECT_EQ( static_cast<int>(c_nSize - nCount), val );
}
// push_back/pop_front
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_back( i ) );
+ EXPECT_TRUE( dq.push_back( i ));
EXPECT_EQ( dq.size(), c_nSize );
nCount = 0;
- while ( !dq.empty() ) {
- EXPECT_TRUE( dq.pop_front( val ) );
+ while ( !dq.empty()) {
+ EXPECT_TRUE( dq.pop_front( val ));
EXPECT_EQ( static_cast<int>( nCount ), val );
++nCount;
}
// push_front/pop_back
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_front( i ) );
+ EXPECT_TRUE( dq.push_front( i ));
EXPECT_EQ( dq.size(), c_nSize );
nCount = 0;
- while ( !dq.empty() ) {
- EXPECT_TRUE( dq.pop_back( val ) );
+ while ( !dq.empty()) {
+ EXPECT_TRUE( dq.pop_back( val ));
EXPECT_EQ( static_cast<int>( nCount ), val );
++nCount;
}
// clear
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_front( i ) );
+ EXPECT_TRUE( dq.push_front( i ));
EXPECT_EQ( dq.size(), c_nSize );
- EXPECT_FALSE( dq.empty() );
+ EXPECT_FALSE( dq.empty());
dq.clear();
- EXPECT_TRUE( dq.empty() );
+ EXPECT_TRUE( dq.empty());
}
};
test( dq );
}
+ TEST_F( FCDeque, std_empty_wait_strategy )
+ {
+ typedef cds::container::FCDeque<int, std::deque<int>,
+ cds::container::fcdeque::make_traits<
+ cds::opt::wait_strategy< cds::algo::flat_combining::wait_strategy::empty >
+ >::type
+ > deque_type;
+
+ deque_type dq;
+ test( dq );
+ }
+
+ TEST_F( FCDeque, std_multi_mutex_multi_condvar )
+ {
+ typedef cds::container::FCDeque<int, std::deque<int>,
+ cds::container::fcdeque::make_traits<
+ cds::opt::wait_strategy< cds::algo::flat_combining::wait_strategy::multi_mutex_multi_condvar<>>
+ >::type
+ > deque_type;
+
+ deque_type dq;
+ test( dq );
+ }
+
TEST_F( FCDeque, std_elimination )
{
typedef cds::container::FCDeque<int, std::deque<int>,
test( dq );
}
+ TEST_F( FCDeque, std_elimination_single_mutex_single_condvar )
+ {
+ typedef cds::container::FCDeque<int, std::deque<int>,
+ cds::container::fcdeque::make_traits<
+ cds::opt::enable_elimination< true >
+ , cds::opt::wait_strategy< cds::algo::flat_combining::wait_strategy::single_mutex_single_condvar<3>>
+ >::type
+ > deque_type;
+
+ deque_type dq;
+ test( dq );
+ }
+
TEST_F( FCDeque, std_statistics )
{
typedef cds::container::FCDeque<int, std::deque<int>,
test( dq );
}
+ TEST_F( FCDeque, std_stat_single_mutex_multi_condvar )
+ {
+ typedef cds::container::FCDeque<int, std::deque<int>,
+ cds::container::fcdeque::make_traits<
+ cds::opt::stat< cds::container::fcdeque::stat<> >
+ , cds::opt::wait_strategy< cds::algo::flat_combining::wait_strategy::single_mutex_multi_condvar<2>>
+ >::type
+ > deque_type;
+
+ deque_type dq;
+ test( dq );
+ }
+
TEST_F( FCDeque, std_mutex )
{
struct deque_traits : public
test( dq );
}
+ TEST_F( FCDeque, boost_empty_wait_strategy )
+ {
+ typedef cds::container::FCDeque<int, boost::container::deque<int>,
+ cds::container::fcdeque::make_traits<
+ cds::opt::wait_strategy< cds::algo::flat_combining::wait_strategy::empty >
+ >::type
+ > deque_type;
+
+ deque_type dq;
+ test( dq );
+ }
+
+ TEST_F( FCDeque, boost_single_mutex_single_condvar )
+ {
+ typedef cds::container::FCDeque<int, boost::container::deque<int>,
+ cds::container::fcdeque::make_traits<
+ cds::opt::wait_strategy< cds::algo::flat_combining::wait_strategy::single_mutex_single_condvar<>>
+ >::type
+ > deque_type;
+
+ deque_type dq;
+ test( dq );
+ }
+
TEST_F( FCDeque, boost_elimination )
{
typedef cds::container::FCDeque<int, boost::container::deque<int>,
test( dq );
}
+ TEST_F( FCDeque, boost_elimination_single_mutex_multi_condvar )
+ {
+ typedef cds::container::FCDeque<int, boost::container::deque<int>,
+ cds::container::fcdeque::make_traits<
+ cds::opt::enable_elimination< true >
+ ,cds::opt::wait_strategy< cds::algo::flat_combining::wait_strategy::single_mutex_multi_condvar<5>>
+ >::type
+ > deque_type;
+
+ deque_type dq;
+ test( dq );
+ }
+
TEST_F( FCDeque, boost_statistics )
{
typedef cds::container::FCDeque<int, boost::container::deque<int>,
test( dq );
}
+ TEST_F( FCDeque, boost_mutex_multi_mutex_multi_condvar )
+ {
+ typedef cds::container::FCDeque<int, boost::container::deque<int>,
+ cds::container::fcdeque::make_traits<
+ cds::opt::enable_elimination< true >
+ , cds::opt::lock_type< std::mutex >
+ , cds::opt::wait_strategy< cds::algo::flat_combining::wait_strategy::multi_mutex_multi_condvar<>>
+ >::type
+ > deque_type;
+
+ deque_type dq;
+ test( dq );
+ }
+
} // namespace