• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
23 #include <grpcpp/test/mock_stream.h>
24 
25 #include "src/proto/grpc/testing/echo.grpc.pb.h"
26 
27 using grpc::testing::EchoRequest;
28 using grpc::testing::EchoResponse;
29 
TEST(MockStreamTest,Basic)30 TEST(MockStreamTest, Basic) {
31   auto cr = std::make_unique<grpc::testing::MockClientReader<EchoResponse>>();
32   ASSERT_NE(cr, nullptr);
33 
34   auto cw = std::make_unique<grpc::testing::MockClientWriter<EchoResponse>>();
35   ASSERT_NE(cw, nullptr);
36 
37   auto crw = std::make_unique<
38       grpc::testing::MockClientReaderWriter<EchoResponse, EchoResponse>>();
39   ASSERT_NE(crw, nullptr);
40 
41   auto carr = std::make_unique<
42       grpc::testing::MockClientAsyncResponseReader<EchoResponse>>();
43   ASSERT_NE(carr, nullptr);
44 
45   auto car =
46       std::make_unique<grpc::testing::MockClientAsyncReader<EchoResponse>>();
47   ASSERT_NE(car, nullptr);
48 
49   auto caw =
50       std::make_unique<grpc::testing::MockClientAsyncWriter<EchoResponse>>();
51   ASSERT_NE(caw, nullptr);
52 
53   auto carw = std::make_unique<
54       grpc::testing::MockClientAsyncReaderWriter<EchoRequest, EchoResponse>>();
55   ASSERT_NE(carw, nullptr);
56 
57   auto sr = std::make_unique<grpc::testing::MockServerReader<EchoRequest>>();
58   ASSERT_NE(sr, nullptr);
59 
60   auto sw = std::make_unique<grpc::testing::MockServerWriter<EchoResponse>>();
61   ASSERT_NE(sw, nullptr);
62 
63   auto srw = std::make_unique<
64       grpc::testing::MockServerReaderWriter<EchoResponse, EchoRequest>>();
65   ASSERT_NE(srw, nullptr);
66 }
67 
main(int argc,char ** argv)68 int main(int argc, char** argv) {
69   ::testing::InitGoogleTest(&argc, argv);
70   return RUN_ALL_TESTS();
71 }
72