• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 
15 #include "pw_rpc/internal/method_info.h"
16 
17 #include "gtest/gtest.h"
18 #include "pw_rpc/internal/method_info_tester.h"
19 #include "pw_rpc_test_protos/test.rpc.pb.h"
20 
21 namespace pw::rpc::internal {
22 namespace {
23 
24 using GeneratedService = pw::rpc::test::pw_rpc::nanopb::TestService;
25 
26 class TestService final : public GeneratedService::Service<TestService> {
27  public:
TestUnaryRpc(const pw_rpc_test_TestRequest &,pw_rpc_test_TestResponse &)28   Status TestUnaryRpc(const pw_rpc_test_TestRequest&,
29                       pw_rpc_test_TestResponse&) {
30     return OkStatus();
31   }
32 
TestAnotherUnaryRpc(const pw_rpc_test_TestRequest &,NanopbUnaryResponder<pw_rpc_test_TestResponse> &)33   void TestAnotherUnaryRpc(const pw_rpc_test_TestRequest&,
34                            NanopbUnaryResponder<pw_rpc_test_TestResponse>&) {}
35 
TestServerStreamRpc(const pw_rpc_test_TestRequest &,ServerWriter<pw_rpc_test_TestStreamResponse> &)36   static void TestServerStreamRpc(
37       const pw_rpc_test_TestRequest&,
38       ServerWriter<pw_rpc_test_TestStreamResponse>&) {}
39 
TestClientStreamRpc(ServerReader<pw_rpc_test_TestRequest,pw_rpc_test_TestStreamResponse> &)40   void TestClientStreamRpc(
41       ServerReader<pw_rpc_test_TestRequest, pw_rpc_test_TestStreamResponse>&) {}
42 
TestBidirectionalStreamRpc(ServerReaderWriter<pw_rpc_test_TestRequest,pw_rpc_test_TestStreamResponse> &)43   void TestBidirectionalStreamRpc(
44       ServerReaderWriter<pw_rpc_test_TestRequest,
45                          pw_rpc_test_TestStreamResponse>&) {}
46 };
47 
48 static_assert(MethodInfoTests<GeneratedService, TestService>().Pass());
49 
50 }  // namespace
51 }  // namespace pw::rpc::internal
52