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