diff options
Diffstat (limited to 'test/cpp/util')
-rw-r--r-- | test/cpp/util/benchmark_config.cc | 14 | ||||
-rw-r--r-- | test/cpp/util/byte_buffer_test.cc | 7 | ||||
-rw-r--r-- | test/cpp/util/cli_call.cc | 15 | ||||
-rw-r--r-- | test/cpp/util/cli_call.h | 7 | ||||
-rw-r--r-- | test/cpp/util/cli_call_test.cc | 20 | ||||
-rw-r--r-- | test/cpp/util/create_test_channel.cc | 12 | ||||
-rw-r--r-- | test/cpp/util/create_test_channel.h | 11 | ||||
-rw-r--r-- | test/cpp/util/echo.proto | 6 | ||||
-rw-r--r-- | test/cpp/util/echo_duplicate.proto | 2 | ||||
-rw-r--r-- | test/cpp/util/grpc_cli.cc | 11 | ||||
-rw-r--r-- | test/cpp/util/messages.proto | 30 | ||||
-rw-r--r-- | test/cpp/util/slice_test.cc | 2 | ||||
-rw-r--r-- | test/cpp/util/status_test.cc | 3 | ||||
-rw-r--r-- | test/cpp/util/string_ref_test.cc | 215 | ||||
-rw-r--r-- | test/cpp/util/time_test.cc | 2 |
15 files changed, 284 insertions, 73 deletions
diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 91fbbf9677..3c38221b4c 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -37,7 +37,8 @@ DEFINE_bool(enable_log_reporter, true, "Enable reporting of benchmark results through GprLog"); -DEFINE_bool(report_metrics_db, false, "True if metrics to be reported to performance database"); +DEFINE_bool(report_metrics_db, false, + "True if metrics to be reported to performance database"); DEFINE_string(hashed_id, "", "Hash of the user id"); @@ -45,7 +46,8 @@ DEFINE_string(test_name, "", "Name of the test being executed"); DEFINE_string(sys_info, "", "System information"); -DEFINE_string(server_address, "localhost:50052", "Address of the performance database server"); +DEFINE_string(server_address, "localhost:50052", + "Address of the performance database server"); DEFINE_string(tag, "", "Optional tag for the test"); @@ -69,10 +71,10 @@ static std::shared_ptr<Reporter> InitBenchmarkReporters() { composite_reporter->add( std::unique_ptr<Reporter>(new GprLogReporter("LogReporter"))); } - if(FLAGS_report_metrics_db) { - composite_reporter->add( - std::unique_ptr<Reporter>(new PerfDbReporter("PerfDbReporter", FLAGS_hashed_id, FLAGS_test_name, - FLAGS_sys_info, FLAGS_server_address, FLAGS_tag))); + if (FLAGS_report_metrics_db) { + composite_reporter->add(std::unique_ptr<Reporter>( + new PerfDbReporter("PerfDbReporter", FLAGS_hashed_id, FLAGS_test_name, + FLAGS_sys_info, FLAGS_server_address, FLAGS_tag))); } return std::shared_ptr<Reporter>(composite_reporter); diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc index 13eb49730a..f36c32cac5 100644 --- a/test/cpp/util/byte_buffer_test.cc +++ b/test/cpp/util/byte_buffer_test.cc @@ -31,13 +31,13 @@ * */ -#include <grpc++/byte_buffer.h> +#include <grpc++/support/byte_buffer.h> #include <cstring> #include <vector> #include <grpc/support/slice.h> -#include <grpc++/slice.h> +#include <grpc++/support/slice.h> #include <gtest/gtest.h> namespace grpc { @@ -46,8 +46,7 @@ namespace { const char* kContent1 = "hello xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char* kContent2 = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy world"; -class ByteBufferTest : public ::testing::Test { -}; +class ByteBufferTest : public ::testing::Test {}; TEST_F(ByteBufferTest, CreateFromSingleSlice) { gpr_slice hello = gpr_slice_from_copied_string(kContent1); diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index 83a7a1744a..d60cee9c02 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -35,24 +35,21 @@ #include <iostream> -#include <grpc++/byte_buffer.h> -#include <grpc++/channel_interface.h> -#include <grpc++/client_context.h> -#include <grpc++/generic_stub.h> -#include <grpc++/status.h> -#include <grpc++/stream.h> - #include <grpc/grpc.h> #include <grpc/support/log.h> #include <grpc/support/slice.h> +#include <grpc++/support/byte_buffer.h> +#include <grpc++/channel.h> +#include <grpc++/client_context.h> +#include <grpc++/generic/generic_stub.h> namespace grpc { namespace testing { namespace { -void* tag(int i) { return (void*)(gpr_intptr) i; } +void* tag(int i) { return (void*)(gpr_intptr)i; } } // namespace -Status CliCall::Call(std::shared_ptr<grpc::ChannelInterface> channel, +Status CliCall::Call(std::shared_ptr<grpc::Channel> channel, const grpc::string& method, const grpc::string& request, grpc::string* response, const MetadataContainer& metadata, MetadataContainer* server_initial_metadata, diff --git a/test/cpp/util/cli_call.h b/test/cpp/util/cli_call.h index 8d114c9cb5..7a3dcf2e9f 100644 --- a/test/cpp/util/cli_call.h +++ b/test/cpp/util/cli_call.h @@ -36,9 +36,8 @@ #include <map> -#include <grpc++/channel_interface.h> -#include <grpc++/config.h> -#include <grpc++/status.h> +#include <grpc++/channel.h> +#include <grpc++/support/status.h> namespace grpc { namespace testing { @@ -46,7 +45,7 @@ namespace testing { class CliCall GRPC_FINAL { public: typedef std::multimap<grpc::string, grpc::string> MetadataContainer; - static Status Call(std::shared_ptr<grpc::ChannelInterface> channel, + static Status Call(std::shared_ptr<grpc::Channel> channel, const grpc::string& method, const grpc::string& request, grpc::string* response, const MetadataContainer& metadata, MetadataContainer* server_initial_metadata, diff --git a/test/cpp/util/cli_call_test.cc b/test/cpp/util/cli_call_test.cc index 848a3aee57..35bfad202f 100644 --- a/test/cpp/util/cli_call_test.cc +++ b/test/cpp/util/cli_call_test.cc @@ -31,24 +31,22 @@ * */ -#include "test/core/util/test_config.h" #include "test/cpp/util/cli_call.h" -#include "test/cpp/util/echo.grpc.pb.h" -#include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> + +#include <grpc/grpc.h> +#include <grpc++/channel.h> #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> -#include <grpc++/dynamic_thread_pool.h> #include <grpc++/server.h> #include <grpc++/server_builder.h> #include <grpc++/server_context.h> #include <grpc++/server_credentials.h> -#include <grpc++/status.h> -#include "test/core/util/port.h" #include <gtest/gtest.h> -#include <grpc/grpc.h> +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo.grpc.pb.h" using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoResponse; @@ -75,7 +73,7 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { class CliCallTest : public ::testing::Test { protected: - CliCallTest() : thread_pool_(2) {} + CliCallTest() {} void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); @@ -85,7 +83,6 @@ class CliCallTest : public ::testing::Test { builder.AddListeningPort(server_address_.str(), InsecureServerCredentials()); builder.RegisterService(&service_); - builder.SetThreadPool(&thread_pool_); server_ = builder.BuildAndStart(); } @@ -97,12 +94,11 @@ class CliCallTest : public ::testing::Test { stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel_)); } - std::shared_ptr<ChannelInterface> channel_; + std::shared_ptr<Channel> channel_; std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_; std::unique_ptr<Server> server_; std::ostringstream server_address_; TestServiceImpl service_; - DynamicThreadPool thread_pool_; }; // Send a rpc with a normal stub and then a CliCall. Verify they match. diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index dc48fa2d87..161b4bdc1d 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -33,11 +33,11 @@ #include "test/cpp/util/create_test_channel.h" -#include "test/core/end2end/data/ssl_test_data.h" -#include <grpc++/channel_arguments.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> +#include "test/core/end2end/data/ssl_test_data.h" + namespace grpc { // When ssl is enabled, if server is empty, override_hostname is used to @@ -55,7 +55,7 @@ namespace grpc { // CreateTestChannel("test.google.com:443", "", true, true, creds); // same as above // CreateTestChannel("", "test.google.com:443", true, true, creds); -std::shared_ptr<ChannelInterface> CreateTestChannel( +std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots, const std::shared_ptr<Credentials>& creds) { @@ -80,7 +80,7 @@ std::shared_ptr<ChannelInterface> CreateTestChannel( } } -std::shared_ptr<ChannelInterface> CreateTestChannel( +std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots) { return CreateTestChannel(server, override_hostname, enable_ssl, @@ -88,8 +88,8 @@ std::shared_ptr<ChannelInterface> CreateTestChannel( } // Shortcut for end2end and interop tests. -std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server, - bool enable_ssl) { +std::shared_ptr<Channel> CreateTestChannel(const grpc::string& server, + bool enable_ssl) { return CreateTestChannel(server, "foo.test.google.fr", enable_ssl, false); } diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index 5f2609ddd8..1263d4ed68 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -36,20 +36,19 @@ #include <memory> -#include <grpc++/config.h> #include <grpc++/credentials.h> namespace grpc { -class ChannelInterface; +class Channel; -std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server, - bool enable_ssl); +std::shared_ptr<Channel> CreateTestChannel(const grpc::string& server, + bool enable_ssl); -std::shared_ptr<ChannelInterface> CreateTestChannel( +std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots); -std::shared_ptr<ChannelInterface> CreateTestChannel( +std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots, const std::shared_ptr<Credentials>& creds); diff --git a/test/cpp/util/echo.proto b/test/cpp/util/echo.proto index 58ec680ecd..8ea2f59897 100644 --- a/test/cpp/util/echo.proto +++ b/test/cpp/util/echo.proto @@ -28,7 +28,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -syntax = "proto2"; +syntax = "proto3"; import "test/cpp/util/messages.proto"; @@ -41,3 +41,7 @@ service TestService { rpc BidiStream(stream EchoRequest) returns (stream EchoResponse); rpc Unimplemented(EchoRequest) returns (EchoResponse); } + +service UnimplementedService { + rpc Unimplemented(EchoRequest) returns (EchoResponse); +} diff --git a/test/cpp/util/echo_duplicate.proto b/test/cpp/util/echo_duplicate.proto index e54c016d2f..9c1d67825a 100644 --- a/test/cpp/util/echo_duplicate.proto +++ b/test/cpp/util/echo_duplicate.proto @@ -30,7 +30,7 @@ // This is a partial copy of echo.proto with a different package name. -syntax = "proto2"; +syntax = "proto3"; import "test/cpp/util/messages.proto"; diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc index 3c3baeb769..746d67deeb 100644 --- a/test/cpp/util/grpc_cli.cc +++ b/test/cpp/util/grpc_cli.cc @@ -64,14 +64,13 @@ #include <sstream> #include <gflags/gflags.h> -#include "test/cpp/util/cli_call.h" -#include "test/cpp/util/test_config.h" -#include <grpc++/channel_arguments.h> -#include <grpc++/channel_interface.h> +#include <grpc/grpc.h> +#include <grpc++/channel.h> #include <grpc++/create_channel.h> #include <grpc++/credentials.h> -#include <grpc/grpc.h> +#include "test/cpp/util/cli_call.h" +#include "test/cpp/util/test_config.h" DEFINE_bool(enable_ssl, true, "Whether to use ssl/tls."); DEFINE_bool(use_auth, false, "Whether to create default google credentials."); @@ -154,7 +153,7 @@ int main(int argc, char** argv) { creds = grpc::SslCredentials(grpc::SslCredentialsOptions()); } } - std::shared_ptr<grpc::ChannelInterface> channel = + std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_address, creds, grpc::ChannelArguments()); grpc::string response; diff --git a/test/cpp/util/messages.proto b/test/cpp/util/messages.proto index 24e199b809..359d1db74f 100644 --- a/test/cpp/util/messages.proto +++ b/test/cpp/util/messages.proto @@ -28,32 +28,32 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -syntax = "proto2"; +syntax = "proto3"; package grpc.cpp.test.util; message RequestParams { - optional bool echo_deadline = 1; - optional int32 client_cancel_after_us = 2; - optional int32 server_cancel_after_us = 3; - optional bool echo_metadata = 4; - optional bool check_auth_context = 5; - optional int32 response_message_length = 6; - optional bool echo_peer = 7; + bool echo_deadline = 1; + int32 client_cancel_after_us = 2; + int32 server_cancel_after_us = 3; + bool echo_metadata = 4; + bool check_auth_context = 5; + int32 response_message_length = 6; + bool echo_peer = 7; } message EchoRequest { - optional string message = 1; - optional RequestParams param = 2; + string message = 1; + RequestParams param = 2; } message ResponseParams { - optional int64 request_deadline = 1; - optional string host = 2; - optional string peer = 3; + int64 request_deadline = 1; + string host = 2; + string peer = 3; } message EchoResponse { - optional string message = 1; - optional ResponseParams param = 2; + string message = 1; + ResponseParams param = 2; } diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc index eb328490e1..de7ff031ab 100644 --- a/test/cpp/util/slice_test.cc +++ b/test/cpp/util/slice_test.cc @@ -31,7 +31,7 @@ * */ -#include <grpc++/slice.h> +#include <grpc++/support/slice.h> #include <grpc/support/slice.h> #include <gtest/gtest.h> diff --git a/test/cpp/util/status_test.cc b/test/cpp/util/status_test.cc index 17b92ab06a..837a6bab02 100644 --- a/test/cpp/util/status_test.cc +++ b/test/cpp/util/status_test.cc @@ -31,7 +31,8 @@ * */ -#include <grpc++/status.h> +#include <grpc++/support/status.h> + #include <grpc/status.h> #include <grpc/support/log.h> diff --git a/test/cpp/util/string_ref_test.cc b/test/cpp/util/string_ref_test.cc new file mode 100644 index 0000000000..c4ca4fce84 --- /dev/null +++ b/test/cpp/util/string_ref_test.cc @@ -0,0 +1,215 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 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. + * + */ + +#include <grpc++/support/string_ref.h> + +#include <string.h> + +#include <gtest/gtest.h> + +namespace grpc { +namespace { + +const char kTestString[] = "blah"; +const char kTestStringWithEmbeddedNull[] = "blah\0foo"; +const size_t kTestStringWithEmbeddedNullLength = 8; +const char kTestUnrelatedString[] = "foo"; + +class StringRefTest : public ::testing::Test { +}; + +TEST_F(StringRefTest, Empty) { + string_ref s; + EXPECT_EQ(0U, s.length()); + EXPECT_EQ(nullptr, s.data()); +} + +TEST_F(StringRefTest, FromCString) { + string_ref s(kTestString); + EXPECT_EQ(strlen(kTestString), s.length()); + EXPECT_EQ(kTestString, s.data()); +} + +TEST_F(StringRefTest, FromCStringWithLength) { + string_ref s(kTestString, 2); + EXPECT_EQ(2U, s.length()); + EXPECT_EQ(kTestString, s.data()); +} + +TEST_F(StringRefTest, FromString) { + string copy(kTestString); + string_ref s(copy); + EXPECT_EQ(copy.data(), s.data()); + EXPECT_EQ(copy.length(), s.length()); +} + +TEST_F(StringRefTest, CopyConstructor) { + string_ref s1(kTestString);; + string_ref s2(s1); + EXPECT_EQ(s1.length(), s2.length()); + EXPECT_EQ(s1.data(), s2.data()); +} + +TEST_F(StringRefTest, FromStringWithEmbeddedNull) { + string copy(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); + string_ref s(copy); + EXPECT_EQ(copy.data(), s.data()); + EXPECT_EQ(copy.length(), s.length()); + EXPECT_EQ(kTestStringWithEmbeddedNullLength, s.length()); +} + +TEST_F(StringRefTest, Assignment) { + string_ref s1(kTestString);; + string_ref s2; + EXPECT_EQ(nullptr, s2.data()); + s2 = s1; + EXPECT_EQ(s1.length(), s2.length()); + EXPECT_EQ(s1.data(), s2.data()); +} + +TEST_F(StringRefTest, Iterator) { + string_ref s(kTestString); + size_t i = 0; + for (char c : s) { + EXPECT_EQ(kTestString[i++], c); + } + EXPECT_EQ(strlen(kTestString), i); +} + +TEST_F(StringRefTest, ReverseIterator) { + string_ref s(kTestString); + size_t i = strlen(kTestString); + for (auto rit = s.crbegin(); rit != s.crend(); ++rit) { + EXPECT_EQ(kTestString[--i], *rit); + } + EXPECT_EQ(0U, i); +} + +TEST_F(StringRefTest, Capacity) { + string_ref empty; + EXPECT_EQ(0U, empty.length()); + EXPECT_EQ(0U, empty.size()); + EXPECT_EQ(0U, empty.max_size()); + EXPECT_TRUE(empty.empty()); + + string_ref s(kTestString); + EXPECT_EQ(strlen(kTestString), s.length()); + EXPECT_EQ(s.length(), s.size()); + EXPECT_EQ(s.max_size(), s.length()); + EXPECT_FALSE(s.empty()); +} + +TEST_F(StringRefTest, Compare) { + string_ref s1(kTestString); + string s1_copy(kTestString); + string_ref s2(kTestUnrelatedString); + string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); + EXPECT_EQ(0, s1.compare(s1_copy)); + EXPECT_NE(0, s1.compare(s2)); + EXPECT_NE(0, s1.compare(s3)); +} + +TEST_F(StringRefTest, StartsWith) { + string_ref s1(kTestString); + string_ref s2(kTestUnrelatedString); + string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); + EXPECT_TRUE(s1.starts_with(s1)); + EXPECT_FALSE(s1.starts_with(s2)); + EXPECT_FALSE(s2.starts_with(s1)); + EXPECT_FALSE(s1.starts_with(s3)); + EXPECT_TRUE(s3.starts_with(s1)); +} + +TEST_F(StringRefTest, Endswith) { + string_ref s1(kTestString); + string_ref s2(kTestUnrelatedString); + string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); + EXPECT_TRUE(s1.ends_with(s1)); + EXPECT_FALSE(s1.ends_with(s2)); + EXPECT_FALSE(s2.ends_with(s1)); + EXPECT_FALSE(s2.ends_with(s3)); + EXPECT_TRUE(s3.ends_with(s2)); +} + +TEST_F(StringRefTest, Find) { + string_ref s1(kTestString); + string_ref s2(kTestUnrelatedString); + string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); + EXPECT_EQ(0U, s1.find(s1)); + EXPECT_EQ(0U, s2.find(s2)); + EXPECT_EQ(0U, s3.find(s3)); + EXPECT_EQ(string_ref::npos,s1.find(s2) ); + EXPECT_EQ(string_ref::npos,s2.find(s1)); + EXPECT_EQ(string_ref::npos,s1.find(s3)); + EXPECT_EQ(0U, s3.find(s1)); + EXPECT_EQ(5U, s3.find(s2)); + EXPECT_EQ(string_ref::npos, s1.find('z')); + EXPECT_EQ(1U, s2.find('o')); +} + +TEST_F(StringRefTest, SubString) { + string_ref s(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); + string_ref sub1 = s.substr(0, 4); + EXPECT_EQ(string_ref(kTestString), sub1); + string_ref sub2 = s.substr(5); + EXPECT_EQ(string_ref(kTestUnrelatedString), sub2); +} + +TEST_F(StringRefTest, ComparisonOperators) { + string_ref s1(kTestString); + string_ref s2(kTestUnrelatedString); + string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); + EXPECT_EQ(s1, s1); + EXPECT_EQ(s2, s2); + EXPECT_EQ(s3, s3); + EXPECT_GE(s1, s1); + EXPECT_GE(s2, s2); + EXPECT_GE(s3, s3); + EXPECT_LE(s1, s1); + EXPECT_LE(s2, s2); + EXPECT_LE(s3, s3); + EXPECT_NE(s1, s2); + EXPECT_NE(s1, s3); + EXPECT_NE(s2, s3); + EXPECT_GT(s3, s1); + EXPECT_LT(s1, s3); +} + +} // namespace +} // namespace grpc + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + diff --git a/test/cpp/util/time_test.cc b/test/cpp/util/time_test.cc index 4cb6ec4b4e..1e501dfd28 100644 --- a/test/cpp/util/time_test.cc +++ b/test/cpp/util/time_test.cc @@ -32,7 +32,7 @@ */ #include <grpc/support/time.h> -#include <grpc++/time.h> +#include <grpc++/support/time.h> #include <gtest/gtest.h> using std::chrono::duration_cast; |