slice_string_helpers_test.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 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 
20 
21 #include <limits.h>
22 #include <stddef.h>
23 #include <stdlib.h>
24 #include <string.h>
25 
26 #include <grpc/support/alloc.h>
27 #include <grpc/support/log.h>
29 
32 
33 #define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
34 
36  const char* result) {
37  char* got = grpc_dump_slice(slice, flags);
38  GPR_ASSERT(0 == strcmp(got, result));
39  gpr_free(got);
41 }
42 
43 static void test_dump_slice(void) {
44  static const char* text = "HELLO WORLD!";
45  static const char* long_text =
46  "It was a bright cold day in April, and the clocks were striking "
47  "thirteen. Winston Smith, his chin nuzzled into his breast in an effort "
48  "to escape the vile wind, slipped quickly through the glass doors of "
49  "Victory Mansions, though not quickly enough to prevent a swirl of "
50  "gritty dust from entering along with him.";
51 
52  LOG_TEST_NAME("test_dump_slice");
53 
56  long_text);
58  "01");
60  GPR_DUMP_HEX | GPR_DUMP_ASCII, "01 '.'");
61 }
62 
63 int main(int, char**) {
65  return 0;
66 }
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
log.h
expect_slice_dump
static void expect_slice_dump(grpc_slice slice, uint32_t flags, const char *result)
Definition: slice_string_helpers_test.cc:35
grpc_dump_slice
char * grpc_dump_slice(const grpc_slice &s, uint32_t flags)
Definition: slice_string_helpers.cc:25
grpc_slice_from_copied_string
GPRAPI grpc_slice grpc_slice_from_copied_string(const char *source)
Definition: slice/slice.cc:177
string.h
gpr_free
GPRAPI void gpr_free(void *ptr)
Definition: alloc.cc:51
GPR_DUMP_HEX
#define GPR_DUMP_HEX
Definition: string.h:34
GPR_DUMP_ASCII
#define GPR_DUMP_ASCII
Definition: string.h:35
main
int main(int, char **)
Definition: slice_string_helpers_test.cc:63
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
string_util.h
gen_server_registered_method_bad_client_test_body.text
def text
Definition: gen_server_registered_method_bad_client_test_body.py:50
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
slice_internal.h
test_dump_slice
static void test_dump_slice(void)
Definition: slice_string_helpers_test.cc:43
LOG_TEST_NAME
#define LOG_TEST_NAME(x)
Definition: slice_string_helpers_test.cc:33
grpc_slice_from_copied_buffer
GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len)
Definition: slice/slice.cc:170
absl::flags_internal
Definition: abseil-cpp/absl/flags/commandlineflag.h:40
alloc.h
slice_string_helpers.h
grpc_slice_unref_internal
void grpc_slice_unref_internal(const grpc_slice &slice)
Definition: slice_refcount.h:39


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:19