From fb8fdd0c2f75a421f2f1c3609a5ab94a00ba62f0 Mon Sep 17 00:00:00 2001 From: wb-hx510875 Date: Tue, 21 Jan 2020 10:57:30 +0800 Subject: [PATCH] improve tests --- .../alibabacloud/core/ServiceRequest.h | 11 ++++----- test/core/servicerequest_ut.cc | 23 +++++++++++++++++-- test/function_test/core/locationclient_ft.cc | 2 ++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/core/include/alibabacloud/core/ServiceRequest.h b/core/include/alibabacloud/core/ServiceRequest.h index 71e888deda..f3af40ecba 100644 --- a/core/include/alibabacloud/core/ServiceRequest.h +++ b/core/include/alibabacloud/core/ServiceRequest.h @@ -30,6 +30,11 @@ class ALIBABACLOUD_CORE_EXPORT ServiceRequest { typedef std::string ParameterValueType; typedef std::map ParameterCollection; + ServiceRequest(const std::string &product, const std::string &version); + ServiceRequest(const ServiceRequest &other); + ServiceRequest(ServiceRequest &&other); + ServiceRequest &operator=(const ServiceRequest &other); + ServiceRequest &operator=(ServiceRequest &&other); virtual ~ServiceRequest(); const char *content() const; @@ -54,12 +59,6 @@ class ALIBABACLOUD_CORE_EXPORT ServiceRequest { void setBodyParameter(const ParameterNameType &name, const ParameterValueType &value); protected: - ServiceRequest(const std::string &product, const std::string &version); - ServiceRequest(const ServiceRequest &other); - ServiceRequest(ServiceRequest &&other); - ServiceRequest &operator=(const ServiceRequest &other); - ServiceRequest &operator=(ServiceRequest &&other); - void addParameter(const ParameterNameType &name, const ParameterValueType &value); ParameterValueType parameter(const ParameterNameType &name) const; diff --git a/test/core/servicerequest_ut.cc b/test/core/servicerequest_ut.cc index 2422908319..4f990a1756 100644 --- a/test/core/servicerequest_ut.cc +++ b/test/core/servicerequest_ut.cc @@ -17,10 +17,12 @@ namespace { {} explicit TestServiceRequest(const ServiceRequest &other): ServiceRequest(other) - {} + { + } explicit TestServiceRequest(ServiceRequest &&other): ServiceRequest(other) - {} + { + } using ServiceRequest::addParameter; using ServiceRequest::coreParameter; @@ -103,4 +105,21 @@ namespace { EXPECT_TRUE(sr1.connectTimeout() == 1234); EXPECT_TRUE(sr1.readTimeout() == 22233); } + + TEST(ServiceRequest, other){ + ServiceRequest one("one", "1.0"); + EXPECT_EQ("one", one.product()); + + ServiceRequest two("two", "1.0"); + EXPECT_EQ("two", two.product()); + + ServiceRequest three = one; + EXPECT_EQ("one", three.product()); + + ServiceRequest four(two); + EXPECT_EQ("two" , four.product()); + + ServiceRequest &&five(move(two)); + EXPECT_EQ("two" , five.product()); + } } diff --git a/test/function_test/core/locationclient_ft.cc b/test/function_test/core/locationclient_ft.cc index 61d110b7dc..d928a306c0 100644 --- a/test/function_test/core/locationclient_ft.cc +++ b/test/function_test/core/locationclient_ft.cc @@ -131,9 +131,11 @@ TEST(LocationClient, callable) configuration.setConnectTimeout(100000); configuration.setReadTimeout(100000); Model::DescribeEndpointsRequest req; + req.setMethod(HttpRequest::Method::Get); req.setId("cn-hangzhou"); req.setServiceCode("ecs"); req.setType("openAPI"); + req.setBodyParameter("foo", "var"); LocationClient client(key, secret, configuration); LocationClient::DescribeEndpointsOutcomeCallable cb = client.describeEndpointsCallable(req);