]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
c++11: fix shared_ptr conversions to bool
authorCasey Bodley <cbodley@redhat.com>
Fri, 31 Jul 2015 17:36:26 +0000 (13:36 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 7 Aug 2015 15:42:58 +0000 (11:42 -0400)
operator bool() is marked as explicit, which prevents it from being used
directly in gtest macros

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/test/common/test_shared_cache.cc
src/test/common/test_sharedptr_registry.cc
src/test/erasure-code/TestErasureCodePlugin.cc
src/test/erasure-code/TestErasureCodePluginIsa.cc
src/test/erasure-code/TestErasureCodePluginJerasure.cc
src/test/erasure-code/TestErasureCodePluginLrc.cc
src/test/erasure-code/TestErasureCodePluginShec.cc

index b9f53771f90a6fea530b22f91b8359fc21433c7b..f54a2a36a6b5090201c14c1be58567a5639ffb08 100644 (file)
@@ -28,8 +28,6 @@
 #include "global/global_init.h"
 #include <gtest/gtest.h>
 
-using namespace std::tr1;
-
 class SharedLRUTest : public SharedLRU<unsigned int, int> {
 public:
   Mutex &get_lock() { return lock; }
@@ -141,28 +139,28 @@ TEST_F(SharedLRU_all, lookup) {
   unsigned int key = 1;
   {
     int value = 2;
-    ASSERT_TRUE(cache.add(key, new int(value)));
-    ASSERT_TRUE(cache.lookup(key));
+    ASSERT_TRUE(cache.add(key, new int(value)).get());
+    ASSERT_TRUE(cache.lookup(key).get());
     ASSERT_EQ(value, *cache.lookup(key));
   }
-  ASSERT_TRUE(cache.lookup(key));
+  ASSERT_TRUE(cache.lookup(key).get());
 }
 TEST_F(SharedLRU_all, lookup_or_create) {
   SharedLRUTest cache;
   {
     int value = 2;
     unsigned int key = 1;
-    ASSERT_TRUE(cache.add(key, new int(value)));
-    ASSERT_TRUE(cache.lookup_or_create(key));
+    ASSERT_TRUE(cache.add(key, new int(value)).get());
+    ASSERT_TRUE(cache.lookup_or_create(key).get());
     ASSERT_EQ(value, *cache.lookup(key));
   }
   {
     unsigned int key = 2;
-    ASSERT_TRUE(cache.lookup_or_create(key));
+    ASSERT_TRUE(cache.lookup_or_create(key).get());
     ASSERT_EQ(0, *cache.lookup(key));
   }
-  ASSERT_TRUE(cache.lookup(1));
-  ASSERT_TRUE(cache.lookup(2));
+  ASSERT_TRUE(cache.lookup(1).get());
+  ASSERT_TRUE(cache.lookup(2).get());
 }
 
 TEST_F(SharedLRU_all, wait_lookup) {
@@ -207,7 +205,7 @@ TEST_F(SharedLRU_all, wait_lookup_or_create) {
   ASSERT_TRUE(wait_for(cache, 1));
   EXPECT_EQ(value, *t.ptr);
   // waiting on a key does not block lookups on other keys
-  EXPECT_TRUE(cache.lookup_or_create(key + 12345));
+  EXPECT_TRUE(cache.lookup_or_create(key + 12345).get());
   {
     Mutex::Locker l(cache.get_lock());
     cache.get_weak_refs().erase(key);
@@ -226,8 +224,8 @@ TEST_F(SharedLRU_all, lower_bound) {
     ASSERT_FALSE(cache.lower_bound(key));
     int value = 2;
 
-    ASSERT_TRUE(cache.add(key, new int(value)));
-    ASSERT_TRUE(cache.lower_bound(key));
+    ASSERT_TRUE(cache.add(key, new int(value)).get());
+    ASSERT_TRUE(cache.lower_bound(key).get());
     EXPECT_EQ(value, *cache.lower_bound(key));
   }
 }
@@ -239,7 +237,7 @@ TEST_F(SharedLRU_all, wait_lower_bound) {
   unsigned int other_key = key + 1;
   int other_value = value + 1;
 
-  ASSERT_TRUE(cache.add(other_key, new int(other_value)));
+  ASSERT_TRUE(cache.add(other_key, new int(other_value)).get());
 
   {
     shared_ptr<int> ptr(new int);
@@ -252,7 +250,7 @@ TEST_F(SharedLRU_all, wait_lower_bound) {
   ASSERT_TRUE(wait_for(cache, 1));
   EXPECT_FALSE(t.ptr);
   // waiting on a key does not block getting lower_bound on other keys
-  EXPECT_TRUE(cache.lower_bound(other_key));
+  EXPECT_TRUE(cache.lower_bound(other_key).get());
   {
     Mutex::Locker l(cache.get_lock());
     cache.get_weak_refs().erase(key);
@@ -260,7 +258,7 @@ TEST_F(SharedLRU_all, wait_lower_bound) {
   }
   ASSERT_TRUE(wait_for(cache, 0));
   t.join();
-  EXPECT_TRUE(t.ptr);
+  EXPECT_TRUE(t.ptr.get());
 }
 TEST_F(SharedLRU_all, get_next) {
 
@@ -322,14 +320,14 @@ TEST_F(SharedLRU_all, clear) {
     ceph::shared_ptr<int> ptr = cache.add(key, new int(value));
     ASSERT_EQ(value, *cache.lookup(key));
   }
-  ASSERT_TRUE(cache.lookup(key));
+  ASSERT_TRUE(cache.lookup(key).get());
   cache.clear(key);
   ASSERT_FALSE(cache.lookup(key));
 
   {
     ceph::shared_ptr<int> ptr = cache.add(key, new int(value));
   }
-  ASSERT_TRUE(cache.lookup(key));
+  ASSERT_TRUE(cache.lookup(key).get());
   cache.clear(key);
   ASSERT_FALSE(cache.lookup(key));
 }
@@ -341,14 +339,14 @@ TEST_F(SharedLRU_all, clear_all) {
     ceph::shared_ptr<int> ptr = cache.add(key, new int(value));
     ASSERT_EQ(value, *cache.lookup(key));
   }
-  ASSERT_TRUE(cache.lookup(key));
+  ASSERT_TRUE(cache.lookup(key).get());
   cache.clear();
   ASSERT_FALSE(cache.lookup(key));
 
   ceph::shared_ptr<int> ptr2 = cache.add(key, new int(value));
-  ASSERT_TRUE(cache.lookup(key));
+  ASSERT_TRUE(cache.lookup(key).get());
   cache.clear();
-  ASSERT_TRUE(cache.lookup(key));
+  ASSERT_TRUE(cache.lookup(key).get());
   ASSERT_FALSE(cache.empty());
 }
 
@@ -379,12 +377,12 @@ TEST(SharedCache_all, lru) {
     ASSERT_FALSE(existed);
   }
 
-  ASSERT_TRUE(cache.lookup(0));
+  ASSERT_TRUE(cache.lookup(0).get());
   ASSERT_EQ(0, *cache.lookup(0));
 
   ASSERT_FALSE(cache.lookup(SIZE-1));
   ASSERT_FALSE(cache.lookup(SIZE));
-  ASSERT_TRUE(cache.lookup(SIZE+1));
+  ASSERT_TRUE(cache.lookup(SIZE+1).get());
   ASSERT_EQ((int)SIZE+1, *cache.lookup(SIZE+1));
 
   cache.purge(0);
@@ -392,7 +390,7 @@ TEST(SharedCache_all, lru) {
   shared_ptr<int> ptr2 = cache.add(0, new int(0), &existed);
   ASSERT_FALSE(ptr == ptr2);
   ptr = shared_ptr<int>();
-  ASSERT_TRUE(cache.lookup(0));
+  ASSERT_TRUE(cache.lookup(0).get());
 }
 
 int main(int argc, char **argv) {
index 9c9e89f9cf78b3e7094827a765ab881278146131..7b06b7e163f6dd33fd243510a8acbc919b550003 100644 (file)
@@ -27,8 +27,6 @@
 #include "global/global_init.h"
 #include <gtest/gtest.h>
 
-using namespace std::tr1;
-
 class SharedPtrRegistryTest : public SharedPtrRegistry<unsigned int, int> {
 public:
   Mutex &get_lock() { return lock; }
@@ -136,11 +134,11 @@ TEST_F(SharedPtrRegistry_all, wait_lookup_or_create) {
     ASSERT_TRUE(wait_for(registry, 1));
     EXPECT_FALSE(t.ptr);
     // waiting on a key does not block lookups on other keys
-    EXPECT_TRUE(registry.lookup_or_create(key + 12345));
+    EXPECT_TRUE(registry.lookup_or_create(key + 12345).get());
     registry.remove(key);
     ASSERT_TRUE(wait_for(registry, 0));
     t.join();
-    EXPECT_TRUE(t.ptr);
+    EXPECT_TRUE(t.ptr.get());
   }
   {
     unsigned int key = 2;
@@ -160,13 +158,13 @@ TEST_F(SharedPtrRegistry_all, wait_lookup_or_create) {
       int other_value = value + 1;
       unsigned int other_key = key + 1;
       shared_ptr<int> ptr = registry.lookup_or_create<int>(other_key, other_value);
-      EXPECT_TRUE(ptr);
+      EXPECT_TRUE(ptr.get());
       EXPECT_EQ(other_value, *ptr);
     }
     registry.remove(key);
     ASSERT_TRUE(wait_for(registry, 0));
     t.join();
-    EXPECT_TRUE(t.ptr);
+    EXPECT_TRUE(t.ptr.get());
     EXPECT_EQ(value, *t.ptr);
   }
 }
@@ -320,7 +318,7 @@ TEST_F(SharedPtrRegistry_destructor, destructor) {
   {
     shared_ptr<TellDie> a = registry.lookup_or_create(key);
     EXPECT_EQ(NO, died);
-    EXPECT_TRUE(a);
+    EXPECT_TRUE(a.get());
   }
   EXPECT_EQ(YES, died);
   EXPECT_FALSE(registry.lookup(key));
index e8c594fc8e6f712675c4f0fdb2d04b3d0674ee1d..ee620a280b4346e795a23dd6416f812936341602 100644 (file)
@@ -92,7 +92,7 @@ TEST_F(ErasureCodePluginRegistryTest, all)
                                     &erasure_code, &cerr));
   EXPECT_FALSE(erasure_code);
   EXPECT_EQ(0, instance.factory("example", profile, &erasure_code, &cerr));
-  EXPECT_TRUE(erasure_code);
+  EXPECT_TRUE(erasure_code.get());
   ErasureCodePlugin *plugin = 0;
   {
     Mutex::Locker l(instance.lock);
index e730b40015414e0f1e63a621758cdf33e259c45c..a07b387f1584d2f0b8f0e44bc9eaeee1912973bd 100644 (file)
@@ -43,7 +43,7 @@ TEST(ErasureCodePlugin, factory)
     EXPECT_FALSE(erasure_code);
     EXPECT_EQ(0, instance.factory("isa", profile,
                                   &erasure_code, &cerr));
-    EXPECT_TRUE(erasure_code);
+    EXPECT_TRUE(erasure_code.get());
   }
 }
 
index ad456c0235f9a93d1f6a4da138e41b864b74b216..4c4ed1ed975baf198854caa02dc1efa04745f953 100644 (file)
@@ -55,7 +55,7 @@ TEST(ErasureCodePlugin, factory)
     EXPECT_FALSE(erasure_code);
     EXPECT_EQ(0, instance.factory("jerasure", profile,
                                   &erasure_code, &cerr));
-    EXPECT_TRUE(erasure_code);
+    EXPECT_TRUE(erasure_code.get());
   }
 }
 
@@ -201,7 +201,7 @@ TEST(ErasureCodePlugin, sse)
     EXPECT_FALSE(erasure_code);
     EXPECT_EQ(0, instance.factory("jerasure_" + *sse_variant, profile,
                                   &erasure_code, &cerr));
-    EXPECT_TRUE(erasure_code);
+    EXPECT_TRUE(erasure_code.get());
 
     //
     // encode
index fea576c546082ddbb4232d28c26f3e95d27d93ad..c6909e6e1dd81bfbc51ef63c172ce4504b44cda3 100644 (file)
@@ -34,7 +34,7 @@ TEST(ErasureCodePlugin, factory)
   ErasureCodeInterfaceRef erasure_code;
   EXPECT_FALSE(erasure_code);
   EXPECT_EQ(0, instance.factory("lrc", profile, &erasure_code, &cerr));
-  EXPECT_TRUE(erasure_code);
+  EXPECT_TRUE(erasure_code.get());
 }
 
 int main(int argc, char **argv)
index 405aca2330a6d1c283e81e173b4a6db642b9fe96..da3ed67d3bf5cd444ab419542841703da830456b 100644 (file)
@@ -36,7 +36,7 @@ TEST(ErasureCodePlugin, factory)
     EXPECT_FALSE(erasure_code);
     EXPECT_EQ(0, instance.factory("shec", profile,
                                         &erasure_code, &cerr));
-    EXPECT_TRUE(erasure_code);
+    EXPECT_TRUE(erasure_code.get());
   }
   const char *techniques[] = {
     "single",
@@ -50,7 +50,7 @@ TEST(ErasureCodePlugin, factory)
     EXPECT_FALSE(erasure_code);
     EXPECT_EQ(0, instance.factory("shec", profile,
                                   &erasure_code, &cerr));
-    EXPECT_TRUE(erasure_code);
+    EXPECT_TRUE(erasure_code.get());
   }
 }
 
@@ -197,7 +197,7 @@ TEST(ErasureCodePlugin, sse)
     EXPECT_FALSE(erasure_code);
     EXPECT_EQ(0, instance.factory("shec_" + *sse_variant, profile,
                                   &erasure_code, &cerr));
-    EXPECT_TRUE(erasure_code);
+    EXPECT_TRUE(erasure_code.get());
 
     //
     // encode