mock_stream_test.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2020 the gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #include <gtest/gtest.h>
20 
21 #include "absl/memory/memory.h"
22 
24 
25 #include "src/proto/grpc/testing/echo.grpc.pb.h"
26 
27 using grpc::testing::EchoRequest;
28 using grpc::testing::EchoResponse;
29 
30 TEST(MockStreamTest, Basic) {
31  auto cr = absl::make_unique<grpc::testing::MockClientReader<EchoResponse>>();
32  ASSERT_NE(cr, nullptr);
33 
34  auto cw = absl::make_unique<grpc::testing::MockClientWriter<EchoResponse>>();
35  ASSERT_NE(cw, nullptr);
36 
37  auto crw = absl::make_unique<
39  ASSERT_NE(crw, nullptr);
40 
41  auto carr = absl::make_unique<
43  ASSERT_NE(carr, nullptr);
44 
45  auto car =
46  absl::make_unique<grpc::testing::MockClientAsyncReader<EchoResponse>>();
47  ASSERT_NE(car, nullptr);
48 
49  auto caw =
50  absl::make_unique<grpc::testing::MockClientAsyncWriter<EchoResponse>>();
51  ASSERT_NE(caw, nullptr);
52 
53  auto carw = absl::make_unique<
55  ASSERT_NE(carw, nullptr);
56 
57  auto sr = absl::make_unique<grpc::testing::MockServerReader<EchoRequest>>();
58  ASSERT_NE(sr, nullptr);
59 
60  auto sw = absl::make_unique<grpc::testing::MockServerWriter<EchoResponse>>();
61  ASSERT_NE(sw, nullptr);
62 
63  auto srw = absl::make_unique<
65  ASSERT_NE(srw, nullptr);
66 }
67 
68 int main(int argc, char** argv) {
69  ::testing::InitGoogleTest(&argc, argv);
70  return RUN_ALL_TESTS();
71 }
ASSERT_NE
#define ASSERT_NE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2060
grpc::testing::MockServerReaderWriter
Definition: grpcpp/test/mock_stream.h:179
TEST
TEST(MockStreamTest, Basic)
Definition: mock_stream_test.cc:30
grpc::testing::MockClientReaderWriter
Definition: grpcpp/test/mock_stream.h:66
absl::make_unique
memory_internal::MakeUniqueResult< T >::scalar make_unique(Args &&... args)
Definition: third_party/abseil-cpp/absl/memory/memory.h:168
grpc::testing::MockClientAsyncReaderWriter
Definition: grpcpp/test/mock_stream.h:132
RUN_ALL_TESTS
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2471
testing::InitGoogleTest
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6106
grpc::testing::MockClientAsyncResponseReader
TODO: We do not support mocking an async RPC for now.
Definition: grpcpp/test/mock_stream.h:88
mock_stream.h
main
int main(int argc, char **argv)
Definition: mock_stream_test.cc:68


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:30