3 * Copyright 2017 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "src/core/lib/transport/transport.h"
21 #include "test/core/util/test_config.h"
23 #include <grpc/grpc.h>
24 #include <grpc/support/log.h>
26 static void do_nothing(void* arg, grpc_error* error) {}
28 int main(int argc, char** argv) {
29 grpc::testing::TestEnvironment env(argc, argv);
32 uint8_t buffer[] = "abc123";
33 grpc_stream_refcount r;
34 GRPC_STREAM_REF_INIT(&r, 1, do_nothing, nullptr, "test");
35 GPR_ASSERT(r.refs.count == 1);
37 grpc_slice_from_stream_owned_buffer(&r, buffer, sizeof(buffer));
38 GPR_ASSERT(GRPC_SLICE_START_PTR(slice) == buffer);
39 GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == sizeof(buffer));
40 GPR_ASSERT(r.refs.count == 2);
41 grpc_slice_unref(slice);
42 GPR_ASSERT(r.refs.count == 1);