Uses different pass count for different parallel queue test cases
[libcds.git] / test / unit / misc / cxx11_atomic_class.cpp
index cb142621ea18c56a9c49cabef07b3c9aa8eb01a1..4041d8f70a0ae595b9625610871119049dca0d3b 100644 (file)
     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include <gtest/gtest.h>
+#include <cds_test/ext_gtest.h>
 #include <cds/algo/atomic.h>
 #include "cxx11_convert_memory_order.h"
 
-#if CDS_COMPILER == CDS_COMPILER_CLANG && !defined( _LIBCPP_VERSION )
-    // CLang (at least 3.6) without libc++ has no gcc-specific __atomic_is_lock_free function
-#   define EXPECT_ATOMIC_IS_LOCK_FREE( x )
-#else
-#   define EXPECT_ATOMIC_IS_LOCK_FREE( x ) EXPECT_TRUE( x.is_lock_free() )
-#endif
-
+#define EXPECT_ATOMIC_IS_LOCK_FREE( x ) EXPECT_TRUE( x.is_lock_free())
 
 namespace {
     class cxx11_atomic_class: public ::testing::Test
@@ -433,6 +427,8 @@ namespace {
         template <typename Atomic>
         void do_test_atomic_pointer_void_( Atomic& a, char * arr, char aSize, atomics::memory_order order )
         {
+            CDS_UNUSED( aSize );
+
             atomics::memory_order oLoad = convert_to_load_order(order);
             atomics::memory_order oStore = convert_to_store_order(order);
             void *  p;
@@ -458,18 +454,6 @@ namespace {
             EXPECT_EQ( reinterpret_cast<char *>(a.exchange( (void *) arr, order )), arr + 3 );
             EXPECT_EQ( reinterpret_cast<char *>(a.load( oLoad )), arr );
             EXPECT_EQ( *reinterpret_cast<char *>(a.load( oLoad )), 1 );
-
-            for ( char i = 1; i < aSize; ++i ) {
-                EXPECT_EQ( *reinterpret_cast<char *>(a.load( oLoad )), i );
-                a.fetch_add( 1, order );
-                EXPECT_EQ( *reinterpret_cast<char *>(a.load( oLoad )), i + 1 );
-            }
-
-            for ( char i = aSize; i > 1; --i ) {
-                EXPECT_EQ( *reinterpret_cast<char *>(a.load( oLoad )), i );
-                a.fetch_sub( 1, order );
-                EXPECT_EQ( *reinterpret_cast<char *>(a.load( oLoad )), i - 1 );
-            }
         }
 
         template <bool Volatile>
@@ -504,18 +488,6 @@ namespace {
             EXPECT_EQ( reinterpret_cast<char *>( a.load()), arr );
             EXPECT_EQ( *reinterpret_cast<char *>( a.load()), 1 );
 
-            for ( char i = 1; i < aSize; ++i ) {
-                EXPECT_EQ( *reinterpret_cast<char *>(a.load()), i );
-                a.fetch_add( 1 );
-                EXPECT_EQ( *reinterpret_cast<char *>(a.load()), i + 1 );
-            }
-
-            for ( char i = aSize; i > 1; --i ) {
-                EXPECT_EQ( *reinterpret_cast<char *>(a.load()), i );
-                a.fetch_sub( 1 );
-                EXPECT_EQ( *reinterpret_cast<char *>(a.load()), i - 1 );
-            }
-
             do_test_atomic_pointer_void_( a, arr, aSize, atomics::memory_order_relaxed );
             do_test_atomic_pointer_void_( a, arr, aSize, atomics::memory_order_acquire );
             do_test_atomic_pointer_void_( a, arr, aSize, atomics::memory_order_release );
@@ -554,14 +526,14 @@ namespace {
             EXPECT_EQ( *a.load( oLoad ), 1 );
 
             for ( integral_type i = 1; i < aSize; ++i ) {
-                integral_type * p = a.load();
+                p = a.load();
                 EXPECT_EQ( *p, i );
                 EXPECT_EQ( a.fetch_add( 1, order ), p );
                 EXPECT_EQ( *a.load( oLoad ), i + 1 );
             }
 
             for ( integral_type i = aSize; i > 1; --i ) {
-                integral_type * p = a.load();
+                p = a.load();
                 EXPECT_EQ( *p, i  );
                 EXPECT_EQ( a.fetch_sub( 1, order ), p );
                 EXPECT_EQ( *a.load( oLoad ), i - 1 );
@@ -606,7 +578,7 @@ namespace {
             EXPECT_EQ( *a.load(), 1 );
 
             for ( integral_type i = 1; i < aSize; ++i ) {
-                integral_type * p = a.load();
+                p = a.load();
                 EXPECT_EQ( *p, i );
                 integral_type * pa = a.fetch_add( 1 );
                 EXPECT_EQ( pa, p );
@@ -614,7 +586,7 @@ namespace {
             }
 
             for ( integral_type i = aSize; i > 1; --i ) {
-                integral_type * p = a.load();
+                p = a.load();
                 EXPECT_EQ( *p, i  );
                 EXPECT_EQ( a.fetch_sub( 1 ), p );
                 EXPECT_EQ( *a.load(), i - 1 );
@@ -794,8 +766,6 @@ namespace {
         test_atomic_integral_volatile<unsigned long long>();
     }
 
-#if !( CDS_COMPILER == CDS_COMPILER_CLANG && CDS_COMPILER_VERSION < 40000 )
-    //clang error with atomic<void*> fetch_add/fetch_sub
     TEST_F( cxx11_atomic_class, atomic_pointer_void )
     {
         do_test_atomic_pointer_void<false>();
@@ -805,7 +775,6 @@ namespace {
     {
         do_test_atomic_pointer_void<true>();
     }
-#endif
 
     TEST_F( cxx11_atomic_class, atomic_pointer_char )
     {