Debian Codegraph @

test/cpp/common/channel_filter_test.cc

raw
1 //
2 // Copyright 2016 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #include "src/cpp/common/channel_filter.h"
18
19 #include <limits.h>
20
21 #include <gtest/gtest.h>
22
23 #include <grpc/grpc.h>
24
25 namespace grpc {
26 namespace testing {
27
28 class MyChannelData : public ChannelData {
29 public:
30 MyChannelData() {}
31
32 grpc_error_handle Init(grpc_channel_element* /*elem*/,
33 grpc_channel_element_args* args) override {
34 (void)args->channel_args; // Make sure field is available.
35 return absl::OkStatus();
36 }
37 };
38
39 class MyCallData : public CallData {
40 public:
41 MyCallData() {}
42
43 grpc_error_handle Init(grpc_call_element* /*elem*/,
44 const grpc_call_element_args* args) override {
45 (void)args->path; // Make sure field is available.
46 return absl::OkStatus();
47 }
48 };
49
50 // This test ensures that when we make changes to the filter API in
51 // C-core, we don't accidentally break the C++ filter API.
52 TEST(ChannelFilterTest, RegisterChannelFilter) {
53 grpc::RegisterChannelFilter<MyChannelData, MyCallData>(
54 "myfilter", GRPC_CLIENT_CHANNEL, INT_MAX, nullptr);
55 }
56
57 // TODO(roth): When we have time, add tests for all methods of the
58 // filter API.
59
60 } // namespace testing
61 } // namespace grpc
62
63 int main(int argc, char** argv) {
64 ::testing::InitGoogleTest(&argc, argv);
65 return RUN_ALL_TESTS();
66 }