• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 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.pwpb.h"
20 #include "pw_status/status.h"
21 
22 namespace pw::rpc {
23 
24 namespace test {
25 
26 namespace TestRequest = ::pw::rpc::test::pwpb::TestRequest;
27 namespace TestResponse = ::pw::rpc::test::pwpb::TestResponse;
28 namespace TestStreamResponse = ::pw::rpc::test::pwpb::TestStreamResponse;
29 
30 }  // namespace test
31 
32 namespace {
33 
34 class TestService final
35     : public test::pw_rpc::pwpb::TestService::Service<TestService> {
36  public:
TestUnaryRpc(const test::TestRequest::Message &,test::TestResponse::Message &)37   Status TestUnaryRpc(const test::TestRequest::Message&,
38                       test::TestResponse::Message&) {
39     return OkStatus();
40   }
41 
TestAnotherUnaryRpc(const test::TestRequest::Message &,PwpbUnaryResponder<test::TestResponse::Message> &)42   void TestAnotherUnaryRpc(const test::TestRequest::Message&,
43                            PwpbUnaryResponder<test::TestResponse::Message>&) {}
44 
TestServerStreamRpc(const test::TestRequest::Message &,ServerWriter<test::TestStreamResponse::Message> &)45   static void TestServerStreamRpc(
46       const test::TestRequest::Message&,
47       ServerWriter<test::TestStreamResponse::Message>&) {}
48 
TestClientStreamRpc(ServerReader<test::TestRequest::Message,test::TestStreamResponse::Message> &)49   void TestClientStreamRpc(ServerReader<test::TestRequest::Message,
50                                         test::TestStreamResponse::Message>&) {}
51 
TestBidirectionalStreamRpc(ServerReaderWriter<test::TestRequest::Message,test::TestStreamResponse::Message> &)52   void TestBidirectionalStreamRpc(
53       ServerReaderWriter<test::TestRequest::Message,
54                          test::TestStreamResponse::Message>&) {}
55 };
56 
57 static_assert(
58     internal::MethodInfoTests<test::pw_rpc::pwpb::TestService, TestService>()
59         .Pass());
60 
61 }  // namespace
62 }  // namespace pw::rpc
63