[slice] Remove dead code (#30139)

* Remove dead code

* More dead code

* Automated change: Fix sanity tests

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/30142/head
Craig Tiller 3 years ago committed by GitHub
parent 05fcd826f4
commit 6648dd7447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      BUILD
  2. 30
      CMakeLists.txt
  3. 2
      Makefile
  4. 13
      build_autogenerated.yaml
  5. 1
      config.m4
  6. 1
      config.w32
  7. 2
      gRPC-C++.podspec
  8. 3
      gRPC-Core.podspec
  9. 2
      grpc.gemspec
  10. 2
      grpc.gyp
  11. 2
      package.xml
  12. 103
      src/core/lib/slice/slice_split.cc
  13. 36
      src/core/lib/slice/slice_split.h
  14. 20
      src/core/lib/slice/slice_string_helpers.cc
  15. 4
      src/core/lib/slice/slice_string_helpers.h
  16. 1
      src/python/grpcio/grpc_core_dependencies.py
  17. 13
      test/core/slice/BUILD
  18. 175
      test/core/slice/slice_split_test.cc
  19. 2
      tools/doxygen/Doxyfile.c++.internal
  20. 2
      tools/doxygen/Doxyfile.core.internal
  21. 24
      tools/run_tests/generated/tests.json

@ -2590,7 +2590,6 @@ grpc_cc_library(
"src/core/lib/slice/b64.cc",
"src/core/lib/slice/slice_api.cc",
"src/core/lib/slice/slice_buffer_api.cc",
"src/core/lib/slice/slice_split.cc",
"src/core/lib/surface/api_trace.cc",
"src/core/lib/surface/builtins.cc",
"src/core/lib/surface/byte_buffer.cc",
@ -2691,7 +2690,6 @@ grpc_cc_library(
"src/core/lib/iomgr/wakeup_fd_posix.h",
"src/core/lib/iomgr/work_serializer.h",
"src/core/lib/slice/b64.h",
"src/core/lib/slice/slice_split.h",
"src/core/lib/surface/api_trace.h",
"src/core/lib/surface/builtins.h",
"src/core/lib/surface/call.h",

30
CMakeLists.txt generated

@ -893,7 +893,6 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_c server_ssl_test)
endif()
add_dependencies(buildtests_c server_test)
add_dependencies(buildtests_c slice_split_test)
add_dependencies(buildtests_c slice_string_helpers_test)
add_dependencies(buildtests_c sockaddr_resolver_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
@ -2242,7 +2241,6 @@ add_library(grpc
src/core/lib/slice/slice_buffer.cc
src/core/lib/slice/slice_buffer_api.cc
src/core/lib/slice/slice_refcount.cc
src/core/lib/slice/slice_split.cc
src/core/lib/slice/slice_string_helpers.cc
src/core/lib/surface/api_trace.cc
src/core/lib/surface/builtins.cc
@ -2834,7 +2832,6 @@ add_library(grpc_unsecure
src/core/lib/slice/slice_buffer.cc
src/core/lib/slice/slice_buffer_api.cc
src/core/lib/slice/slice_refcount.cc
src/core/lib/slice/slice_split.cc
src/core/lib/slice/slice_string_helpers.cc
src/core/lib/surface/api_trace.cc
src/core/lib/surface/builtins.cc
@ -6671,33 +6668,6 @@ target_link_libraries(server_test
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(slice_split_test
test/core/slice/slice_split_test.cc
)
target_include_directories(slice_split_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
)
target_link_libraries(slice_split_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif()
if(gRPC_BUILD_TESTS)

2
Makefile generated

@ -1624,7 +1624,6 @@ LIBGRPC_SRC = \
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_buffer_api.cc \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_split.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/builtins.cc \
@ -2056,7 +2055,6 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_buffer_api.cc \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_split.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/builtins.cc \

@ -935,7 +935,6 @@ libs:
- src/core/lib/slice/slice_internal.h
- src/core/lib/slice/slice_refcount.h
- src/core/lib/slice/slice_refcount_base.h
- src/core/lib/slice/slice_split.h
- src/core/lib/slice/slice_string_helpers.h
- src/core/lib/surface/api_trace.h
- src/core/lib/surface/builtins.h
@ -1601,7 +1600,6 @@ libs:
- src/core/lib/slice/slice_buffer.cc
- src/core/lib/slice/slice_buffer_api.cc
- src/core/lib/slice/slice_refcount.cc
- src/core/lib/slice/slice_split.cc
- src/core/lib/slice/slice_string_helpers.cc
- src/core/lib/surface/api_trace.cc
- src/core/lib/surface/builtins.cc
@ -2121,7 +2119,6 @@ libs:
- src/core/lib/slice/slice_internal.h
- src/core/lib/slice/slice_refcount.h
- src/core/lib/slice/slice_refcount_base.h
- src/core/lib/slice/slice_split.h
- src/core/lib/slice/slice_string_helpers.h
- src/core/lib/surface/api_trace.h
- src/core/lib/surface/builtins.h
@ -2430,7 +2427,6 @@ libs:
- src/core/lib/slice/slice_buffer.cc
- src/core/lib/slice/slice_buffer_api.cc
- src/core/lib/slice/slice_refcount.cc
- src/core/lib/slice/slice_split.cc
- src/core/lib/slice/slice_string_helpers.cc
- src/core/lib/surface/api_trace.cc
- src/core/lib/surface/builtins.cc
@ -4121,15 +4117,6 @@ targets:
- test/core/surface/server_test.cc
deps:
- grpc_test_util
- name: slice_split_test
build: test
language: c
headers: []
src:
- test/core/slice/slice_split_test.cc
deps:
- grpc_test_util
uses_polling: false
- name: slice_string_helpers_test
build: test
language: c

1
config.m4 generated

@ -685,7 +685,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_buffer_api.cc \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_split.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/builtins.cc \

1
config.w32 generated

@ -651,7 +651,6 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\slice\\slice_buffer.cc " +
"src\\core\\lib\\slice\\slice_buffer_api.cc " +
"src\\core\\lib\\slice\\slice_refcount.cc " +
"src\\core\\lib\\slice\\slice_split.cc " +
"src\\core\\lib\\slice\\slice_string_helpers.cc " +
"src\\core\\lib\\surface\\api_trace.cc " +
"src\\core\\lib\\surface\\builtins.cc " +

2
gRPC-C++.podspec generated

@ -894,7 +894,6 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_internal.h',
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_refcount_base.h',
'src/core/lib/slice/slice_split.h',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/builtins.h',
@ -1720,7 +1719,6 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_internal.h',
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_refcount_base.h',
'src/core/lib/slice/slice_split.h',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/builtins.h',

3
gRPC-Core.podspec generated

@ -1477,8 +1477,6 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_refcount_base.h',
'src/core/lib/slice/slice_split.cc',
'src/core/lib/slice/slice_split.h',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/surface/api_trace.cc',
@ -2324,7 +2322,6 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_internal.h',
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_refcount_base.h',
'src/core/lib/slice/slice_split.h',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/builtins.h',

2
grpc.gemspec generated

@ -1391,8 +1391,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/slice/slice_refcount.cc )
s.files += %w( src/core/lib/slice/slice_refcount.h )
s.files += %w( src/core/lib/slice/slice_refcount_base.h )
s.files += %w( src/core/lib/slice/slice_split.cc )
s.files += %w( src/core/lib/slice/slice_split.h )
s.files += %w( src/core/lib/slice/slice_string_helpers.cc )
s.files += %w( src/core/lib/slice/slice_string_helpers.h )
s.files += %w( src/core/lib/surface/api_trace.cc )

2
grpc.gyp generated

@ -974,7 +974,6 @@
'src/core/lib/slice/slice_buffer.cc',
'src/core/lib/slice/slice_buffer_api.cc',
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_split.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/builtins.cc',
@ -1398,7 +1397,6 @@
'src/core/lib/slice/slice_buffer.cc',
'src/core/lib/slice/slice_buffer_api.cc',
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_split.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/builtins.cc',

2
package.xml generated

@ -1373,8 +1373,6 @@
<file baseinstalldir="/" name="src/core/lib/slice/slice_refcount.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_refcount.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_refcount_base.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_split.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_split.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/api_trace.cc" role="src" />

@ -1,103 +0,0 @@
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <grpc/support/port_platform.h>
#include "src/core/lib/slice/slice_split.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/log.h>
/** Finds the initial (\a begin) and final (\a end) offsets of the next
* substring from \a str + \a read_offset until the next \a sep or the end of \a
* str.
*
* Returns 1 and updates \a begin and \a end. Returns 0 otherwise. */
static int slice_find_separator_offset(const grpc_slice str, const char* sep,
const size_t read_offset, size_t* begin,
size_t* end) {
size_t i;
const uint8_t* str_ptr = GRPC_SLICE_START_PTR(str) + read_offset;
const size_t str_len = GRPC_SLICE_LENGTH(str) - read_offset;
const size_t sep_len = strlen(sep);
if (str_len < sep_len) {
return 0;
}
for (i = 0; i <= str_len - sep_len; i++) {
if (memcmp(str_ptr + i, sep, sep_len) == 0) {
*begin = read_offset;
*end = read_offset + i;
return 1;
}
}
return 0;
}
static void skip_leading_trailing_spaces(const uint8_t* str_buffer,
size_t* begin, size_t* end) {
while (*begin < *end && str_buffer[*begin] == ' ') {
(*begin)++;
}
while (*begin < *end && str_buffer[*end - 1] == ' ') {
(*end)--;
}
}
static void grpc_slice_split_inner(grpc_slice str, const char* sep,
grpc_slice_buffer* dst, bool no_space) {
const size_t sep_len = strlen(sep);
size_t begin, end;
const uint8_t* str_buffer = GRPC_SLICE_START_PTR(str);
size_t sep_pos;
GPR_ASSERT(sep_len > 0);
if (slice_find_separator_offset(str, sep, 0, &begin, &end) != 0) {
do {
sep_pos = end;
if (no_space) {
skip_leading_trailing_spaces(str_buffer, &begin, &end);
}
grpc_slice_buffer_add_indexed(dst, grpc_slice_sub(str, begin, end));
} while (slice_find_separator_offset(str, sep, sep_pos + sep_len, &begin,
&end) != 0);
begin = sep_pos + sep_len;
end = GRPC_SLICE_LENGTH(str);
if (no_space) {
skip_leading_trailing_spaces(str_buffer, &begin, &end);
}
grpc_slice_buffer_add_indexed(dst, grpc_slice_sub(str, begin, end));
} else { /* no sep found, add whole input */
begin = 0;
end = GRPC_SLICE_LENGTH(str);
if (no_space) {
skip_leading_trailing_spaces(str_buffer, &begin, &end);
}
grpc_slice_buffer_add_indexed(dst, grpc_slice_sub(str, begin, end));
}
}
void grpc_slice_split(grpc_slice str, const char* sep, grpc_slice_buffer* dst) {
grpc_slice_split_inner(str, sep, dst, false);
}
void grpc_slice_split_without_space(grpc_slice str, const char* sep,
grpc_slice_buffer* dst) {
grpc_slice_split_inner(str, sep, dst, true);
}

@ -1,36 +0,0 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_LIB_SLICE_SLICE_SPLIT_H
#define GRPC_CORE_LIB_SLICE_SLICE_SPLIT_H
#include <grpc/support/port_platform.h>
#include <grpc/slice.h>
/** Split \a str by the separator \a sep. Results are stored in \a dst, which
* should be a properly initialized instance. */
void grpc_slice_split(grpc_slice str, const char* sep, grpc_slice_buffer* dst);
/** Split \a str by the separator \a sep and remove the leading and trailing
* spaces of each resulting token. Results are stored in \a dst, which should be
* a properly initialized instance. */
void grpc_slice_split_without_space(grpc_slice str, const char* sep,
grpc_slice_buffer* dst);
#endif /* GRPC_CORE_LIB_SLICE_SLICE_SPLIT_H */

@ -20,29 +20,9 @@
#include "src/core/lib/slice/slice_string_helpers.h"
#include <stddef.h>
#include <utility>
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/slice/slice_internal.h"
char* grpc_dump_slice(const grpc_slice& s, uint32_t flags) {
return gpr_dump(reinterpret_cast<const char*> GRPC_SLICE_START_PTR(s),
GRPC_SLICE_LENGTH(s), flags);
}
grpc_slice grpc_dump_slice_to_slice(const grpc_slice& s, uint32_t flags) {
size_t len;
grpc_core::UniquePtr<char> ptr(
gpr_dump_return_len(reinterpret_cast<const char*> GRPC_SLICE_START_PTR(s),
GRPC_SLICE_LENGTH(s), flags, &len));
return grpc_slice_from_moved_buffer(std::move(ptr), len);
}
bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t* result) {
return gpr_parse_bytes_to_uint32(
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(str),
GRPC_SLICE_LENGTH(str), result) != 0;
}

@ -27,9 +27,5 @@
/* Calls gpr_dump on a slice. */
char* grpc_dump_slice(const grpc_slice& slice, uint32_t flags);
/* Calls gpr_dump on a slice and returns the result as a slice. */
grpc_slice grpc_dump_slice_to_slice(const grpc_slice& slice, uint32_t flags);
bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t* result);
#endif /* GRPC_CORE_LIB_SLICE_SLICE_STRING_HELPERS_H */

@ -660,7 +660,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/slice/slice_buffer.cc',
'src/core/lib/slice/slice_buffer_api.cc',
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_split.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/builtins.cc',

@ -113,19 +113,6 @@ grpc_cc_test(
],
)
grpc_cc_test(
name = "slice_split_test",
srcs = ["slice_split_test.cc"],
language = "C++",
uses_event_engine = False,
uses_polling = False,
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:grpc_test_util",
],
)
grpc_cc_test(
name = "slice_buffer_test",
srcs = ["slice_buffer_test.cc"],

@ -1,175 +0,0 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "src/core/lib/slice/slice_split.h"
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
static void test_strsplit(void) {
grpc_slice_buffer* parts;
grpc_slice str;
LOG_TEST_NAME("test_strsplit");
parts =
static_cast<grpc_slice_buffer*>(gpr_malloc(sizeof(grpc_slice_buffer)));
grpc_slice_buffer_init(parts);
str = grpc_slice_from_copied_string("one, two, three, four");
grpc_slice_split(str, ", ", parts);
GPR_ASSERT(4 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one"));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "two"));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[2], "three"));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[3], "four"));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* separator not present in string */
str = grpc_slice_from_copied_string("one two three four");
grpc_slice_split(str, ", ", parts);
GPR_ASSERT(1 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one two three four"));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* separator at the end */
str = grpc_slice_from_copied_string("foo,");
grpc_slice_split(str, ",", parts);
GPR_ASSERT(2 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "foo"));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], ""));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* separator at the beginning */
str = grpc_slice_from_copied_string(",foo");
grpc_slice_split(str, ",", parts);
GPR_ASSERT(2 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], ""));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "foo"));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* standalone separator */
str = grpc_slice_from_copied_string(",");
grpc_slice_split(str, ",", parts);
GPR_ASSERT(2 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], ""));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], ""));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* empty input */
str = grpc_slice_from_copied_string("");
grpc_slice_split(str, ", ", parts);
GPR_ASSERT(1 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], ""));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
grpc_slice_buffer_destroy(parts);
gpr_free(parts);
}
static void test_strsplit_nospace(void) {
grpc_slice_buffer* parts;
grpc_slice str;
LOG_TEST_NAME("test_strsplit_nospace");
parts =
static_cast<grpc_slice_buffer*>(gpr_malloc(sizeof(grpc_slice_buffer)));
grpc_slice_buffer_init(parts);
str = grpc_slice_from_copied_string("one ,two, three , four");
grpc_slice_split_without_space(str, ",", parts);
GPR_ASSERT(4 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one"));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "two"));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[2], "three"));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[3], "four"));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* separator not present in string */
str = grpc_slice_from_copied_string("one two three four ");
grpc_slice_split_without_space(str, ",", parts);
GPR_ASSERT(1 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one two three four"));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* separator at the end */
str = grpc_slice_from_copied_string("foo,");
grpc_slice_split_without_space(str, ",", parts);
GPR_ASSERT(2 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "foo"));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], ""));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* separator at the beginning */
str = grpc_slice_from_copied_string(" , foo");
grpc_slice_split_without_space(str, ",", parts);
GPR_ASSERT(2 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], ""));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "foo"));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* standalone separator */
str = grpc_slice_from_copied_string(", ");
grpc_slice_split_without_space(str, ", ", parts);
GPR_ASSERT(2 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], ""));
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], ""));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
/* empty input */
str = grpc_slice_from_copied_string("");
grpc_slice_split_without_space(str, ",", parts);
GPR_ASSERT(1 == parts->count);
GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], ""));
grpc_slice_buffer_reset_and_unref(parts);
grpc_slice_unref(str);
grpc_slice_buffer_destroy(parts);
gpr_free(parts);
}
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(&argc, argv);
test_strsplit();
test_strsplit_nospace();
return 0;
}

@ -2374,8 +2374,6 @@ src/core/lib/slice/slice_internal.h \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_refcount.h \
src/core/lib/slice/slice_refcount_base.h \
src/core/lib/slice/slice_split.cc \
src/core/lib/slice/slice_split.h \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/slice_string_helpers.h \
src/core/lib/surface/api_trace.cc \

@ -2168,8 +2168,6 @@ src/core/lib/slice/slice_internal.h \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_refcount.h \
src/core/lib/slice/slice_refcount_base.h \
src/core/lib/slice/slice_split.cc \
src/core/lib/slice/slice_split.h \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/slice_string_helpers.h \
src/core/lib/surface/README.md \

@ -1961,30 +1961,6 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "slice_split_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": false
},
{
"args": [],
"benchmark": false,

Loading…
Cancel
Save