]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/common: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 03:51:25 +0000 (11:51 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Aug 2021 04:23:36 +0000 (12:23 +0800)
* add "std::" prefix in headers
* add "using" declarations in .cc files.

so we don't rely on "using namespace std" in one or more included
headers.

Signed-off-by: Kefu Chai <kchai@redhat.com>
13 files changed:
src/test/common/Readahead.cc
src/test/common/Throttle.cc
src/test/common/dns_resolve.cc
src/test/common/get_command_descriptions.cc
src/test/common/test_cdc.cc
src/test/common/test_config.cc
src/test/common/test_context.cc
src/test/common/test_crc32c.cc
src/test/common/test_option.cc
src/test/common/test_shared_cache.cc
src/test/common/test_sharedptr_registry.cc
src/test/common/test_time.cc
src/test/common/test_util.cc

index 9b4e612849fe7f0c726dc05b5841e526bdfc5486..30402b02214aabae1a0c592d29116f96e8b1c128 100644 (file)
@@ -28,6 +28,8 @@
     } \
   } while(0)
 
+using namespace std;
+
 TEST(Readahead, random_access) {
   Readahead r;
   r.set_trigger_requests(2);
index c5c984d99a7590e6c43bc3b7f204c9298eb8cf56..b36d0a901de6e82c9b735bc1cbd8f0dc0627488f 100644 (file)
@@ -33,6 +33,8 @@
 #include "common/Throttle.h"
 #include "common/ceph_argparse.h"
 
+using namespace std;
+
 class ThrottleTest : public ::testing::Test {
 protected:
 
index e5b1e5f7b9defb83650c14ecc6d4478b4457a363..437004860fa9c0bc5d8d4f2d9c215368b6b36d6c 100644 (file)
@@ -26,6 +26,7 @@
 
 #define dout_subsys ceph_subsys_
 
+using namespace std;
 
 using ::testing::Return;
 using ::testing::_;
index aef74066a03237203db0854979adbd2e89d9e22e..b83605ec9bf99adc3bface123def239c29a165e4 100644 (file)
@@ -25,6 +25,8 @@
 #include "common/ceph_argparse.h"
 #include "global/global_init.h"
 
+using namespace std;
+
 static void usage(ostream &out)
 {
   out << "usage: get_command_descriptions [options ...]" << std::endl;
index 36047655ef756b37ed1a959e33233978651999de..620ecf4679f19c2dbff257c77561a9f938b29f92 100644 (file)
@@ -11,6 +11,8 @@
 #include "common/CDC.h"
 #include "gtest/gtest.h"
 
+using namespace std;
+
 class CDCTest : public ::testing::Test,
                public ::testing::WithParamInterface<const char*> {
 public:
index fe5e10c5b52ae0653ff99e2432547b8ef461d51b..a70d567a434ee13984aa2c1326f9aae4782bc1a2 100644 (file)
@@ -24,6 +24,8 @@
 #include "gtest/gtest.h"
 #include "common/hostname.h"
 
+using namespace std;
+
 extern std::string exec(const char* cmd); // defined in test_hostname.cc
 
 class test_config_proxy : public ConfigProxy, public ::testing::Test {
index 8afdaec1f107f10e491d61962d6e2a626bb4366c..f95c03853036c02ee5b8560ede04aec3d6fdba74 100644 (file)
@@ -26,6 +26,8 @@
 #include "common/config_proxy.h"
 #include "log/Log.h"
 
+using namespace std;
+
 TEST(CephContext, do_command)
 {
   CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_CLIENT))->get();
index 67ec67263690d0c47bbf7cbdceaddb43bbc99d82..ff5d0019dba5121e1675ff5aeacacc8300ce81f7 100644 (file)
@@ -293,7 +293,7 @@ double estimate_clock_resolution()
   double v = *(head++);
   double range=0;
   while (head != tail) {
-    range = max(range, *head - v);
+    range = std::max(range, *head - v);
     v = *head;
     head++;
   }
index dd6bab651d996012b5a5e74ec84522f5e987ce8c..a75f74dc96daf1a402033f16573adba6d1104804 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "common/options.h"
 
+using namespace std;
+
 TEST(Option, validate_min_max)
 {
   auto opt = Option{"foo", Option::TYPE_MILLISECS, Option::LEVEL_ADVANCED}
index eeb526236c9b824eb2c67b62a3352ef1fd72ba7f..91120c7e59f49c2de19a8c55157c0dced52c5e0e 100644 (file)
@@ -26,6 +26,8 @@
 #include "common/Thread.h"
 #include "common/shared_cache.hpp"
 
+using namespace std;
+
 class SharedLRUTest : public SharedLRU<unsigned int, int> {
 public:
   auto& get_lock() { return lock; }
index 01d0a8489942497a52493dbf8ed1d9a8bd3a5ca0..9a856652ea91b055ae4cf786940fead39f4cd883 100644 (file)
@@ -26,6 +26,8 @@
 #include "common/sharedptr_registry.hpp"
 #include "common/ceph_argparse.h"
 
+using namespace std;
+
 class SharedPtrRegistryTest : public SharedPtrRegistry<unsigned int, int> {
 public:
   ceph::mutex &get_lock() { return lock; }
index 2ce362b63c17f468b7aac2c059b0afe5c30519ca..bc19ba573d1fc4d196fd0cf73646c275c1bccf47 100644 (file)
@@ -20,6 +20,7 @@
 #include "gtest/gtest.h"
 #include "include/stringify.h"
 
+using namespace std;
 
 using ceph::real_clock;
 using ceph::real_time;
index cfef2dbad76f2a7cfad9e3e7470905bec2c01cd6..6cc9906906a36f3604aa5b8243a0f8fe6f43fa97 100644 (file)
@@ -18,6 +18,8 @@
 #include "common/ceph_context.h"
 #include "include/util.h"
 
+using namespace std;
+
 namespace fs = std::filesystem;
 
 #if defined(__linux__)