1 /*
2 *
3 * Copyright 2017 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 "src/core/lib/transport/transport.h"
20
21 #include "test/core/util/test_config.h"
22
23 #include <grpc/grpc.h>
24 #include <grpc/support/log.h>
25
do_nothing(void *,grpc_error *)26 static void do_nothing(void* /*arg*/, grpc_error* /*error*/) {}
27
main(int argc,char ** argv)28 int main(int argc, char** argv) {
29 grpc::testing::TestEnvironment env(argc, argv);
30 grpc_init();
31
32 uint8_t buffer[] = "abc123";
33 grpc_stream_refcount r;
34 GRPC_STREAM_REF_INIT(&r, 1, do_nothing, nullptr, "test");
35 grpc_slice slice =
36 grpc_slice_from_stream_owned_buffer(&r, buffer, sizeof(buffer));
37 GPR_ASSERT(GRPC_SLICE_START_PTR(slice) == buffer);
38 GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == sizeof(buffer));
39 grpc_slice_unref(slice);
40
41 grpc_shutdown();
42 return 0;
43 }
44