aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/support
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-12-29 01:38:26 +0100
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2017-01-04 22:10:14 +0100
commit203860ac23b6229096c0e9d9c04f12cd607c1938 (patch)
tree43cdba091ef2ea2421a0633b4241e40135ec551a /test/core/support
parent19014deb841f25d14827147d4812b1ddcce2b693 (diff)
parentddebfa65f2bdff332902adf73606bc050014b498 (diff)
Merge remote-tracking branch 'google/master' into bazel-take-2
Diffstat (limited to 'test/core/support')
-rw-r--r--test/core/support/BUILD37
-rw-r--r--test/core/support/backoff_test.c91
-rw-r--r--test/core/support/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae61
-rw-r--r--test/core/support/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b5371
-rw-r--r--test/core/support/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba32
-rw-r--r--test/core/support/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d6951
-rw-r--r--test/core/support/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb1
-rw-r--r--test/core/support/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b91
-rw-r--r--test/core/support/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a1
-rw-r--r--test/core/support/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc2481
-rw-r--r--test/core/support/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b51
-rw-r--r--test/core/support/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe6881
-rw-r--r--test/core/support/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae91
-rw-r--r--test/core/support/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d1
-rw-r--r--test/core/support/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e7592
-rw-r--r--test/core/support/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f1
-rw-r--r--test/core/support/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba11
-rw-r--r--test/core/support/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b41
-rw-r--r--test/core/support/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c631
-rw-r--r--test/core/support/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e42231
-rw-r--r--test/core/support/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae1
-rw-r--r--test/core/support/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae6811
-rw-r--r--test/core/support/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b2
-rw-r--r--test/core/support/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e727582
-rw-r--r--test/core/support/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c54331132
-rw-r--r--test/core/support/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a1
-rw-r--r--test/core/support/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a1
-rw-r--r--test/core/support/percent_decode_corpus/xyz1
-rw-r--r--test/core/support/percent_decode_fuzzer.c66
-rw-r--r--test/core/support/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f3
-rw-r--r--test/core/support/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c2261
-rw-r--r--test/core/support/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf1
-rw-r--r--test/core/support/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d931
-rw-r--r--test/core/support/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e73
-rw-r--r--test/core/support/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a3
-rw-r--r--test/core/support/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e4
-rw-r--r--test/core/support/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb9691
-rw-r--r--test/core/support/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c063
-rw-r--r--test/core/support/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b3
-rw-r--r--test/core/support/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd452
-rw-r--r--test/core/support/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec31
-rw-r--r--test/core/support/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b44
-rw-r--r--test/core/support/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd215
-rw-r--r--test/core/support/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a543
-rw-r--r--test/core/support/percent_encode_corpus/xyz1
-rw-r--r--test/core/support/percent_encode_fuzzer.c73
-rw-r--r--test/core/support/percent_encoding_test.c157
-rw-r--r--test/core/support/slice_buffer_test.c129
-rw-r--r--test/core/support/slice_test.c265
-rw-r--r--test/core/support/string_test.c112
50 files changed, 87 insertions, 913 deletions
diff --git a/test/core/support/BUILD b/test/core/support/BUILD
index ac33176f00..77f0a9a048 100644
--- a/test/core/support/BUILD
+++ b/test/core/support/BUILD
@@ -107,27 +107,6 @@ cc_test(
)
cc_test(
- name = "percent_encoding_test",
- srcs = ["percent_encoding_test.c"],
- deps = ["//:gpr", "//test/core/util:gpr_test_util"],
- copts = ['-std=c99']
-)
-
-cc_test(
- name = "slice_buffer_test",
- srcs = ["slice_buffer_test.c"],
- deps = ["//:gpr", "//test/core/util:gpr_test_util"],
- copts = ['-std=c99']
-)
-
-cc_test(
- name = "slice_test",
- srcs = ["slice_test.c"],
- deps = ["//:gpr", "//test/core/util:gpr_test_util"],
- copts = ['-std=c99']
-)
-
-cc_test(
name = "stack_lockfree_test",
srcs = ["stack_lockfree_test.c"],
deps = ["//:gpr", "//test/core/util:gpr_test_util"],
@@ -175,19 +154,3 @@ cc_test(
deps = ["//:gpr", "//test/core/util:gpr_test_util"],
copts = ['-std=c99']
)
-
-grpc_fuzzer(
- name = "percent_encode_fuzzer",
- srcs = ["percent_encode_fuzzer.c"],
- deps = ["//:gpr"],
- corpus = "percent_encode_corpus"
-)
-
-
-grpc_fuzzer(
- name = "percent_decode_fuzzer",
- srcs = ["percent_decode_fuzzer.c"],
- deps = ["//:gpr"],
- corpus = "percent_decode_corpus"
-)
-
diff --git a/test/core/support/backoff_test.c b/test/core/support/backoff_test.c
index 13cba7d750..ad6e5a98f2 100644
--- a/test/core/support/backoff_test.c
+++ b/test/core/support/backoff_test.c
@@ -39,61 +39,110 @@
static void test_constant_backoff(void) {
gpr_backoff backoff;
- gpr_backoff_init(&backoff, 1.0, 0.0, 1000, 1000);
+ gpr_backoff_init(&backoff, 200 /* initial timeout */, 1.0 /* multiplier */,
+ 0.0 /* jitter */, 100 /* min timeout */,
+ 1000 /* max timeout */);
gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
gpr_timespec next = gpr_backoff_begin(&backoff, now);
- GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 1000);
+ GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
for (int i = 0; i < 10000; i++) {
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 1000);
+ GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
now = next;
}
}
-static void test_no_jitter_backoff(void) {
+static void test_min_connect(void) {
gpr_backoff backoff;
- gpr_backoff_init(&backoff, 2.0, 0.0, 1, 513);
+ gpr_backoff_init(&backoff, 100 /* initial timeout */, 1.0 /* multiplier */,
+ 0.0 /* jitter */, 200 /* min timeout */,
+ 1000 /* max timeout */);
gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
gpr_timespec next = gpr_backoff_begin(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1, GPR_TIMESPAN), next) == 0);
- now = next;
- next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(3, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
+}
+
+static void test_no_jitter_backoff(void) {
+ gpr_backoff backoff;
+ gpr_backoff_init(&backoff, 2 /* initial timeout */, 2.0 /* multiplier */,
+ 0.0 /* jitter */, 1 /* min timeout */,
+ 513 /* max timeout */);
+ // x_1 = 2
+ // x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
+ gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
+ gpr_timespec next = gpr_backoff_begin(&backoff, now);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(7, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(6, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(15, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(14, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(31, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(30, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(63, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(62, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(127, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(126, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(255, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(254, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(511, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(510, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1023, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1022, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1536, GPR_TIMESPAN), next) == 0);
+ // Hit the maximum timeout. From this point onwards, retries will increase
+ // only by max timeout.
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1535, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2049, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2048, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2562, GPR_TIMESPAN), next) == 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2561, GPR_TIMESPAN), next) == 0);
+}
+
+static void test_jitter_backoff(void) {
+ const int64_t initial_timeout = 500;
+ const double jitter = 0.1;
+ gpr_backoff backoff;
+ gpr_backoff_init(&backoff, initial_timeout, 1.0 /* multiplier */, jitter,
+ 100 /* min timeout */, 1000 /* max timeout */);
+
+ backoff.rng_state = 0; // force consistent PRNG
+
+ gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
+ gpr_timespec next = gpr_backoff_begin(&backoff, now);
+ GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 500);
+
+ int64_t expected_next_lower_bound =
+ (int64_t)((double)initial_timeout * (1 - jitter));
+ int64_t expected_next_upper_bound =
+ (int64_t)((double)initial_timeout * (1 + jitter));
+
+ for (int i = 0; i < 10000; i++) {
+ next = gpr_backoff_step(&backoff, now);
+
+ // next-now must be within (jitter*100)% of the previous timeout.
+ const int64_t timeout_millis = gpr_time_to_millis(gpr_time_sub(next, now));
+ GPR_ASSERT(timeout_millis >= expected_next_lower_bound);
+ GPR_ASSERT(timeout_millis <= expected_next_upper_bound);
+
+ expected_next_lower_bound =
+ (int64_t)((double)timeout_millis * (1 - jitter));
+ expected_next_upper_bound =
+ (int64_t)((double)timeout_millis * (1 + jitter));
+ now = next;
+ }
}
int main(int argc, char **argv) {
@@ -101,7 +150,9 @@ int main(int argc, char **argv) {
gpr_time_init();
test_constant_backoff();
+ test_min_connect();
test_no_jitter_backoff();
+ test_jitter_backoff();
return 0;
}
diff --git a/test/core/support/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 b/test/core/support/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6
deleted file mode 100644
index a0c7605580..0000000000
--- a/test/core/support/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6
+++ /dev/null
@@ -1 +0,0 @@
-:Ê%cE'yzŠ \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537 b/test/core/support/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537
deleted file mode 100644
index 8b36124b3f..0000000000
--- a/test/core/support/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537
+++ /dev/null
@@ -1 +0,0 @@
-x;x_%C88 \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3 b/test/core/support/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3
deleted file mode 100644
index ea02afac49..0000000000
--- a/test/core/support/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3
+++ /dev/null
@@ -1,2 +0,0 @@
-xxyyz%øyzŠ[zxy'z
-
diff --git a/test/core/support/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695 b/test/core/support/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695
deleted file mode 100644
index 9e9b466b2f..0000000000
--- a/test/core/support/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695
+++ /dev/null
@@ -1 +0,0 @@
-xx;x_%;:Ê%C)x_%C88c8E'yzŠ8 \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb b/test/core/support/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb
deleted file mode 100644
index 88c739ecaa..0000000000
--- a/test/core/support/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb
+++ /dev/null
@@ -1 +0,0 @@
-))'x;x_%C88xy(Pyz) \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 b/test/core/support/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9
deleted file mode 100644
index 5e6f546ff5..0000000000
--- a/test/core/support/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9
+++ /dev/null
@@ -1 +0,0 @@
-_x;x)x;x_x;x_%88%8888: \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a b/test/core/support/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a
deleted file mode 100644
index 71d688b694..0000000000
--- a/test/core/support/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a
+++ /dev/null
@@ -1 +0,0 @@
-x8 \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248 b/test/core/support/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248
deleted file mode 100644
index 5a89a07ba7..0000000000
--- a/test/core/support/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248
+++ /dev/null
@@ -1 +0,0 @@
-x);x(_%88x;x_%88 \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5 b/test/core/support/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5
deleted file mode 100644
index cfa2be994f..0000000000
--- a/test/core/support/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5
+++ /dev/null
@@ -1 +0,0 @@
-)x;x_x;x_%88%88: \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688 b/test/core/support/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688
deleted file mode 100644
index c1ddf65acd..0000000000
--- a/test/core/support/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688
+++ /dev/null
@@ -1 +0,0 @@
-%cyzŠ \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9 b/test/core/support/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9
deleted file mode 100644
index dc427d1e12..0000000000
--- a/test/core/support/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9
+++ /dev/null
@@ -1 +0,0 @@
-%øyzŠ \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d b/test/core/support/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d
deleted file mode 100644
index 154449d0ef..0000000000
--- a/test/core/support/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d
+++ /dev/null
@@ -1 +0,0 @@
-Ê:%Ec \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 b/test/core/support/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759
deleted file mode 100644
index 841ced83c3..0000000000
--- a/test/core/support/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759
+++ /dev/null
@@ -1,2 +0,0 @@
-xxyyz!úyzŠ[zxy'zyz
diff --git a/test/core/support/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f b/test/core/support/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f
deleted file mode 100644
index 6790bc2798..0000000000
--- a/test/core/support/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f
+++ /dev/null
@@ -1 +0,0 @@
-x;:Ê%)x_%C8cE'yzŠ8 \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1 b/test/core/support/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1
deleted file mode 100644
index 1625d0a1ae..0000000000
--- a/test/core/support/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1
+++ /dev/null
@@ -1 +0,0 @@
-x;x_%88 \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4 b/test/core/support/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4
deleted file mode 100644
index 125c330b3e..0000000000
--- a/test/core/support/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4
+++ /dev/null
@@ -1 +0,0 @@
-)))'x;x_%C88)'x;x_%C89xyyzxyyz) \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63 b/test/core/support/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63
deleted file mode 100644
index 6e6f08cb07..0000000000
--- a/test/core/support/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63
+++ /dev/null
@@ -1 +0,0 @@
-))'x;x_%C88xyyz) \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223 b/test/core/support/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223
deleted file mode 100644
index ab4a1c7657..0000000000
--- a/test/core/support/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223
+++ /dev/null
@@ -1 +0,0 @@
-x%8 \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae b/test/core/support/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae
deleted file mode 100644
index 4ac1945a84..0000000000
--- a/test/core/support/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae
+++ /dev/null
@@ -1 +0,0 @@
-x);x(_%88x;x_xxyyz \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681 b/test/core/support/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681
deleted file mode 100644
index 5c673ae28a..0000000000
--- a/test/core/support/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681
+++ /dev/null
@@ -1 +0,0 @@
-Ê%ccyzyzŠ \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b b/test/core/support/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b
deleted file mode 100644
index e478275ed4..0000000000
--- a/test/core/support/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b
+++ /dev/null
@@ -1,2 +0,0 @@
-)'xyyz!úyzŠ[zxÊ%ccyzyzy'z*zŠ
diff --git a/test/core/support/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 b/test/core/support/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758
deleted file mode 100644
index c73cbfe8af..0000000000
--- a/test/core/support/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758
+++ /dev/null
@@ -1,2 +0,0 @@
-)'xyyz)úyzŠ[zxÊ%cCyzyzy'z*zŠ
diff --git a/test/core/support/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113 b/test/core/support/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113
deleted file mode 100644
index f9f7246e9c..0000000000
--- a/test/core/support/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113
+++ /dev/null
@@ -1,2 +0,0 @@
-xxyyz%%øyzŠ[zxy'zyz
diff --git a/test/core/support/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a b/test/core/support/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a
deleted file mode 100644
index 83ac46d833..0000000000
--- a/test/core/support/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a
+++ /dev/null
@@ -1 +0,0 @@
-Ê:%Dx;:Ê%)x_%C8cc \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a b/test/core/support/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a
deleted file mode 100644
index e8a0f87653..0000000000
--- a/test/core/support/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a
+++ /dev/null
@@ -1 +0,0 @@
-) \ No newline at end of file
diff --git a/test/core/support/percent_decode_corpus/xyz b/test/core/support/percent_decode_corpus/xyz
deleted file mode 100644
index cd470e6190..0000000000
--- a/test/core/support/percent_decode_corpus/xyz
+++ /dev/null
@@ -1 +0,0 @@
-xyz
diff --git a/test/core/support/percent_decode_fuzzer.c b/test/core/support/percent_decode_fuzzer.c
deleted file mode 100644
index 3e02980e05..0000000000
--- a/test/core/support/percent_decode_fuzzer.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-
-#include "src/core/lib/support/percent_encoding.h"
-#include "test/core/util/memory_counters.h"
-
-bool squelch = true;
-bool leak_check = true;
-
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- struct grpc_memory_counters counters;
- grpc_memory_counters_init();
- gpr_slice input = gpr_slice_from_copied_buffer((const char *)data, size);
- gpr_slice output;
- if (gpr_strict_percent_decode_slice(
- input, gpr_url_percent_encoding_unreserved_bytes, &output)) {
- gpr_slice_unref(output);
- }
- if (gpr_strict_percent_decode_slice(
- input, gpr_compatible_percent_encoding_unreserved_bytes, &output)) {
- gpr_slice_unref(output);
- }
- gpr_slice_unref(gpr_permissive_percent_decode_slice(input));
- gpr_slice_unref(input);
- counters = grpc_memory_counters_snapshot();
- grpc_memory_counters_destroy();
- GPR_ASSERT(counters.total_size_relative == 0);
- return 0;
-}
diff --git a/test/core/support/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f b/test/core/support/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f
deleted file mode 100644
index d09c4a039c..0000000000
--- a/test/core/support/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f
+++ /dev/null
@@ -1,3 +0,0 @@
-_x;7y
-xyz')S)xy-zý
-Æ* \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 b/test/core/support/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226
deleted file mode 100644
index 4d0c38d0e2..0000000000
--- a/test/core/support/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226
+++ /dev/null
@@ -1 +0,0 @@
-xyx \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf b/test/core/support/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf
deleted file mode 100644
index fc6e93342a..0000000000
--- a/test/core/support/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf
+++ /dev/null
@@ -1 +0,0 @@
-.yx.yxxxyzxyyzxy \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93 b/test/core/support/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93
deleted file mode 100644
index 6823c73f76..0000000000
--- a/test/core/support/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93
+++ /dev/null
@@ -1 +0,0 @@
-xyrxyxyzxxyzxyzxyxyy \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 b/test/core/support/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7
deleted file mode 100644
index a65cbb4d5b..0000000000
--- a/test/core/support/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7
+++ /dev/null
@@ -1,3 +0,0 @@
-xy
-xyz
-)S-Æþ \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a b/test/core/support/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a
deleted file mode 100644
index 8d031d7e2d..0000000000
--- a/test/core/support/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a
+++ /dev/null
@@ -1,3 +0,0 @@
-xy
-xyz
-)S)Æ* \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e b/test/core/support/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e
deleted file mode 100644
index 4d82ca3953..0000000000
--- a/test/core/support/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e
+++ /dev/null
@@ -1,4 +0,0 @@
-x;7y
-xyz
-)S)xyz
-Æ* \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969 b/test/core/support/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969
deleted file mode 100644
index bb7f4ae07e..0000000000
--- a/test/core/support/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969
+++ /dev/null
@@ -1 +0,0 @@
-xyzxy \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06 b/test/core/support/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06
deleted file mode 100644
index 50879d0f37..0000000000
--- a/test/core/support/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06
+++ /dev/null
@@ -1,3 +0,0 @@
-xy
-xz
-)Sxy-Æzx_yþ \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b b/test/core/support/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b
deleted file mode 100644
index dc1ab9bfc2..0000000000
--- a/test/core/support/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b
+++ /dev/null
@@ -1,3 +0,0 @@
-_x;7y
-xyz')S)xyz
-Æ* \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 b/test/core/support/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45
deleted file mode 100644
index 3476e0b70b..0000000000
--- a/test/core/support/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45
+++ /dev/null
@@ -1,2 +0,0 @@
-xyz
-)S \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 b/test/core/support/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3
deleted file mode 100644
index 822d50abf8..0000000000
--- a/test/core/support/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3
+++ /dev/null
@@ -1 +0,0 @@
-.yx \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4 b/test/core/support/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4
deleted file mode 100644
index 101639c93d..0000000000
--- a/test/core/support/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4
+++ /dev/null
@@ -1,4 +0,0 @@
-x;y
-xyz
-)S)xyz
-Æ* \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21 b/test/core/support/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21
deleted file mode 100644
index 6e07ab342f..0000000000
--- a/test/core/support/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21
+++ /dev/null
@@ -1,5 +0,0 @@
-x;y
-xøyz
-)S)xyz
-Æ.y~
-)S \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54 b/test/core/support/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54
deleted file mode 100644
index 13d7fab596..0000000000
--- a/test/core/support/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54
+++ /dev/null
@@ -1,3 +0,0 @@
-xy
-xyz
-)S)S \ No newline at end of file
diff --git a/test/core/support/percent_encode_corpus/xyz b/test/core/support/percent_encode_corpus/xyz
deleted file mode 100644
index cd470e6190..0000000000
--- a/test/core/support/percent_encode_corpus/xyz
+++ /dev/null
@@ -1 +0,0 @@
-xyz
diff --git a/test/core/support/percent_encode_fuzzer.c b/test/core/support/percent_encode_fuzzer.c
deleted file mode 100644
index c9548232b5..0000000000
--- a/test/core/support/percent_encode_fuzzer.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-
-#include "src/core/lib/support/percent_encoding.h"
-#include "test/core/util/memory_counters.h"
-
-bool squelch = true;
-bool leak_check = true;
-
-static void test(const uint8_t *data, size_t size, const uint8_t *dict) {
- struct grpc_memory_counters counters;
- grpc_memory_counters_init();
- gpr_slice input = gpr_slice_from_copied_buffer((const char *)data, size);
- gpr_slice output = gpr_percent_encode_slice(input, dict);
- gpr_slice decoded_output;
- // encoder must always produce decodable output
- GPR_ASSERT(gpr_strict_percent_decode_slice(output, dict, &decoded_output));
- gpr_slice permissive_decoded_output =
- gpr_permissive_percent_decode_slice(output);
- // and decoded output must always match the input
- GPR_ASSERT(gpr_slice_cmp(input, decoded_output) == 0);
- GPR_ASSERT(gpr_slice_cmp(input, permissive_decoded_output) == 0);
- gpr_slice_unref(input);
- gpr_slice_unref(output);
- gpr_slice_unref(decoded_output);
- gpr_slice_unref(permissive_decoded_output);
- counters = grpc_memory_counters_snapshot();
- grpc_memory_counters_destroy();
- GPR_ASSERT(counters.total_size_relative == 0);
-}
-
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- test(data, size, gpr_url_percent_encoding_unreserved_bytes);
- test(data, size, gpr_compatible_percent_encoding_unreserved_bytes);
- return 0;
-}
diff --git a/test/core/support/percent_encoding_test.c b/test/core/support/percent_encoding_test.c
deleted file mode 100644
index ab5f3f2d14..0000000000
--- a/test/core/support/percent_encoding_test.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- *
- * Copyright 2016, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include "src/core/lib/support/percent_encoding.h"
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-
-#include "src/core/lib/support/string.h"
-#include "test/core/util/test_config.h"
-
-#define TEST_VECTOR(raw, encoded, dict) \
- test_vector(raw, sizeof(raw) - 1, encoded, sizeof(encoded) - 1, dict)
-
-#define TEST_NONCONFORMANT_VECTOR(encoded, permissive_unencoded, dict) \
- test_nonconformant_vector(encoded, sizeof(encoded) - 1, \
- permissive_unencoded, \
- sizeof(permissive_unencoded) - 1, dict)
-
-static void test_vector(const char *raw, size_t raw_length, const char *encoded,
- size_t encoded_length, const uint8_t *dict) {
- char *raw_msg = gpr_dump(raw, raw_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *encoded_msg =
- gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", raw_msg, encoded_msg);
- gpr_free(raw_msg);
- gpr_free(encoded_msg);
-
- gpr_slice raw_slice = gpr_slice_from_copied_buffer(raw, raw_length);
- gpr_slice encoded_slice =
- gpr_slice_from_copied_buffer(encoded, encoded_length);
- gpr_slice raw2encoded_slice = gpr_percent_encode_slice(raw_slice, dict);
- gpr_slice encoded2raw_slice;
- GPR_ASSERT(
- gpr_strict_percent_decode_slice(encoded_slice, dict, &encoded2raw_slice));
- gpr_slice encoded2raw_permissive_slice =
- gpr_permissive_percent_decode_slice(encoded_slice);
-
- char *raw2encoded_msg =
- gpr_dump_slice(raw2encoded_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *encoded2raw_msg =
- gpr_dump_slice(encoded2raw_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *encoded2raw_permissive_msg = gpr_dump_slice(
- encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_DEBUG,
- "Result:\nraw2encoded = %s\nencoded2raw = %s\nencoded2raw_permissive "
- "= %s",
- raw2encoded_msg, encoded2raw_msg, encoded2raw_permissive_msg);
- gpr_free(raw2encoded_msg);
- gpr_free(encoded2raw_msg);
- gpr_free(encoded2raw_permissive_msg);
-
- GPR_ASSERT(0 == gpr_slice_cmp(raw_slice, encoded2raw_slice));
- GPR_ASSERT(0 == gpr_slice_cmp(raw_slice, encoded2raw_permissive_slice));
- GPR_ASSERT(0 == gpr_slice_cmp(encoded_slice, raw2encoded_slice));
-
- gpr_slice_unref(encoded2raw_slice);
- gpr_slice_unref(encoded2raw_permissive_slice);
- gpr_slice_unref(raw2encoded_slice);
- gpr_slice_unref(raw_slice);
- gpr_slice_unref(encoded_slice);
-}
-
-static void test_nonconformant_vector(const char *encoded,
- size_t encoded_length,
- const char *permissive_unencoded,
- size_t permissive_unencoded_length,
- const uint8_t *dict) {
- char *permissive_unencoded_msg =
- gpr_dump(permissive_unencoded, permissive_unencoded_length,
- GPR_DUMP_HEX | GPR_DUMP_ASCII);
- char *encoded_msg =
- gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", permissive_unencoded_msg,
- encoded_msg);
- gpr_free(permissive_unencoded_msg);
- gpr_free(encoded_msg);
-
- gpr_slice permissive_unencoded_slice = gpr_slice_from_copied_buffer(
- permissive_unencoded, permissive_unencoded_length);
- gpr_slice encoded_slice =
- gpr_slice_from_copied_buffer(encoded, encoded_length);
- gpr_slice encoded2raw_slice;
- GPR_ASSERT(!gpr_strict_percent_decode_slice(encoded_slice, dict,
- &encoded2raw_slice));
- gpr_slice encoded2raw_permissive_slice =
- gpr_permissive_percent_decode_slice(encoded_slice);
-
- char *encoded2raw_permissive_msg = gpr_dump_slice(
- encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
- gpr_log(GPR_DEBUG, "Result:\nencoded2raw_permissive = %s",
- encoded2raw_permissive_msg);
- gpr_free(encoded2raw_permissive_msg);
-
- GPR_ASSERT(0 == gpr_slice_cmp(permissive_unencoded_slice,
- encoded2raw_permissive_slice));
-
- gpr_slice_unref(permissive_unencoded_slice);
- gpr_slice_unref(encoded2raw_permissive_slice);
- gpr_slice_unref(encoded_slice);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- TEST_VECTOR(
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~",
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~",
- gpr_url_percent_encoding_unreserved_bytes);
- TEST_VECTOR("\x00", "%00", gpr_url_percent_encoding_unreserved_bytes);
- TEST_VECTOR("\x01", "%01", gpr_url_percent_encoding_unreserved_bytes);
- TEST_VECTOR("a b", "a%20b", gpr_url_percent_encoding_unreserved_bytes);
- TEST_VECTOR(" b", "%20b", gpr_url_percent_encoding_unreserved_bytes);
- TEST_VECTOR("a b", "a b", gpr_compatible_percent_encoding_unreserved_bytes);
- TEST_VECTOR(" b", " b", gpr_compatible_percent_encoding_unreserved_bytes);
- TEST_VECTOR("\x0f", "%0F", gpr_url_percent_encoding_unreserved_bytes);
- TEST_VECTOR("\xff", "%FF", gpr_url_percent_encoding_unreserved_bytes);
- TEST_VECTOR("\xee", "%EE", gpr_url_percent_encoding_unreserved_bytes);
- TEST_NONCONFORMANT_VECTOR("%", "%",
- gpr_url_percent_encoding_unreserved_bytes);
- TEST_NONCONFORMANT_VECTOR("%A", "%A",
- gpr_url_percent_encoding_unreserved_bytes);
- TEST_NONCONFORMANT_VECTOR("%AG", "%AG",
- gpr_url_percent_encoding_unreserved_bytes);
- TEST_NONCONFORMANT_VECTOR("\0", "\0",
- gpr_url_percent_encoding_unreserved_bytes);
- return 0;
-}
diff --git a/test/core/support/slice_buffer_test.c b/test/core/support/slice_buffer_test.c
deleted file mode 100644
index cf2da84c2b..0000000000
--- a/test/core/support/slice_buffer_test.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *
- * Copyright 2015, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <grpc/support/log.h>
-#include <grpc/support/slice_buffer.h>
-#include "test/core/util/test_config.h"
-
-void test_slice_buffer_add() {
- gpr_slice_buffer buf;
- gpr_slice aaa = gpr_slice_from_copied_string("aaa");
- gpr_slice bb = gpr_slice_from_copied_string("bb");
- size_t i;
-
- gpr_slice_buffer_init(&buf);
- for (i = 0; i < 10; i++) {
- gpr_slice_ref(aaa);
- gpr_slice_ref(bb);
- gpr_slice_buffer_add(&buf, aaa);
- gpr_slice_buffer_add(&buf, bb);
- }
- GPR_ASSERT(buf.count > 0);
- GPR_ASSERT(buf.length == 50);
- gpr_slice_buffer_reset_and_unref(&buf);
- GPR_ASSERT(buf.count == 0);
- GPR_ASSERT(buf.length == 0);
- for (i = 0; i < 10; i++) {
- gpr_slice_ref(aaa);
- gpr_slice_ref(bb);
- gpr_slice_buffer_add(&buf, aaa);
- gpr_slice_buffer_add(&buf, bb);
- }
- GPR_ASSERT(buf.count > 0);
- GPR_ASSERT(buf.length == 50);
- for (i = 0; i < 10; i++) {
- gpr_slice_buffer_pop(&buf);
- gpr_slice_unref(aaa);
- gpr_slice_unref(bb);
- }
- GPR_ASSERT(buf.count == 0);
- GPR_ASSERT(buf.length == 0);
- gpr_slice_buffer_destroy(&buf);
-}
-
-void test_slice_buffer_move_first() {
- gpr_slice slices[3];
- gpr_slice_buffer src;
- gpr_slice_buffer dst;
- int idx = 0;
- size_t src_len = 0;
- size_t dst_len = 0;
-
- slices[0] = gpr_slice_from_copied_string("aaa");
- slices[1] = gpr_slice_from_copied_string("bbbb");
- slices[2] = gpr_slice_from_copied_string("ccc");
-
- gpr_slice_buffer_init(&src);
- gpr_slice_buffer_init(&dst);
- for (idx = 0; idx < 3; idx++) {
- gpr_slice_ref(slices[idx]);
- /* For this test, it is important that we add each slice at a new
- slice index */
- gpr_slice_buffer_add_indexed(&src, slices[idx]);
- gpr_slice_buffer_add_indexed(&dst, slices[idx]);
- }
-
- /* Case 1: Move more than the first slice's length from src to dst */
- src_len = src.length;
- dst_len = dst.length;
- gpr_slice_buffer_move_first(&src, 4, &dst);
- src_len -= 4;
- dst_len += 4;
- GPR_ASSERT(src.length == src_len);
- GPR_ASSERT(dst.length == dst_len);
-
- /* src now has two slices ["bbb"] and ["ccc"] */
- /* Case 2: Move the first slice from src to dst */
- gpr_slice_buffer_move_first(&src, 3, &dst);
- src_len -= 3;
- dst_len += 3;
- GPR_ASSERT(src.length == src_len);
- GPR_ASSERT(dst.length == dst_len);
-
- /* src now has one slice ["ccc"] */
- /* Case 3: Move less than the first slice's length from src to dst*/
- gpr_slice_buffer_move_first(&src, 2, &dst);
- src_len -= 2;
- dst_len += 2;
- GPR_ASSERT(src.length == src.length);
- GPR_ASSERT(dst.length == dst.length);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
-
- test_slice_buffer_add();
- test_slice_buffer_move_first();
-
- return 0;
-}
diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c
deleted file mode 100644
index 06c364b368..0000000000
--- a/test/core/support/slice_test.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- *
- * Copyright 2015, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <grpc/support/slice.h>
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include "test/core/util/test_config.h"
-
-#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x);
-
-static void test_slice_malloc_returns_something_sensible(void) {
- /* Calls gpr_slice_create for various lengths and verifies the internals for
- consistency. */
- size_t length;
- size_t i;
- gpr_slice slice;
-
- LOG_TEST_NAME("test_slice_malloc_returns_something_sensible");
-
- for (length = 0; length <= 1024; length++) {
- slice = gpr_slice_malloc(length);
- /* If there is a length, slice.data must be non-NULL. If length is zero
- we don't care. */
- if (length) {
- GPR_ASSERT(GPR_SLICE_START_PTR(slice));
- }
- /* Returned slice length must be what was requested. */
- GPR_ASSERT(GPR_SLICE_LENGTH(slice) == length);
- /* If the slice has a refcount, it must be destroyable. */
- if (slice.refcount) {
- GPR_ASSERT(slice.refcount->ref != NULL);
- GPR_ASSERT(slice.refcount->unref != NULL);
- }
- /* We must be able to write to every byte of the data */
- for (i = 0; i < length; i++) {
- GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i;
- }
- /* And finally we must succeed in destroying the slice */
- gpr_slice_unref(slice);
- }
-}
-
-static void do_nothing(void *ignored) {}
-
-static void test_slice_new_returns_something_sensible(void) {
- uint8_t x;
-
- gpr_slice slice = gpr_slice_new(&x, 1, do_nothing);
- GPR_ASSERT(slice.refcount);
- GPR_ASSERT(slice.data.refcounted.bytes == &x);
- GPR_ASSERT(slice.data.refcounted.length == 1);
- gpr_slice_unref(slice);
-}
-
-/* destroy function that sets a mark to indicate it was called. */
-static void set_mark(void *p) { *((int *)p) = 1; }
-
-static void test_slice_new_with_user_data(void) {
- int marker = 0;
- uint8_t buf[2];
- gpr_slice slice;
-
- buf[0] = 0;
- buf[1] = 1;
- slice = gpr_slice_new_with_user_data(buf, 2, set_mark, &marker);
- GPR_ASSERT(marker == 0);
- GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 2);
- GPR_ASSERT(GPR_SLICE_START_PTR(slice)[0] == 0);
- GPR_ASSERT(GPR_SLICE_START_PTR(slice)[1] == 1);
-
- /* unref should cause destroy function to run. */
- gpr_slice_unref(slice);
- GPR_ASSERT(marker == 1);
-}
-
-static int do_nothing_with_len_1_calls = 0;
-
-static void do_nothing_with_len_1(void *ignored, size_t len) {
- GPR_ASSERT(len == 1);
- do_nothing_with_len_1_calls++;
-}
-
-static void test_slice_new_with_len_returns_something_sensible(void) {
- uint8_t x;
- int num_refs = 5; /* To test adding/removing an arbitrary number of refs */
- int i;
-
- gpr_slice slice = gpr_slice_new_with_len(&x, 1, do_nothing_with_len_1);
- GPR_ASSERT(slice.refcount); /* ref count is initialized to 1 at this point */
- GPR_ASSERT(slice.data.refcounted.bytes == &x);
- GPR_ASSERT(slice.data.refcounted.length == 1);
- GPR_ASSERT(do_nothing_with_len_1_calls == 0);
-
- /* Add an arbitrary number of refs to the slice and remoe the refs. This is to
- make sure that that the destroy callback (i.e do_nothing_with_len_1()) is
- not called until the last unref operation */
- for (i = 0; i < num_refs; i++) {
- gpr_slice_ref(slice);
- }
- for (i = 0; i < num_refs; i++) {
- gpr_slice_unref(slice);
- }
- GPR_ASSERT(do_nothing_with_len_1_calls == 0); /* Shouldn't be called yet */
-
- /* last unref */
- gpr_slice_unref(slice);
- GPR_ASSERT(do_nothing_with_len_1_calls == 1);
-}
-
-static void test_slice_sub_works(unsigned length) {
- gpr_slice slice;
- gpr_slice sub;
- unsigned i, j, k;
-
- LOG_TEST_NAME("test_slice_sub_works");
- gpr_log(GPR_INFO, "length=%d", length);
-
- /* Create a slice in which each byte is equal to the distance from it to the
- beginning of the slice. */
- slice = gpr_slice_malloc(length);
- for (i = 0; i < length; i++) {
- GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i;
- }
-
- /* Ensure that for all subsets length is correct and that we start on the
- correct byte. Additionally check that no copies were made. */
- for (i = 0; i < length; i++) {
- for (j = i; j < length; j++) {
- sub = gpr_slice_sub(slice, i, j);
- GPR_ASSERT(GPR_SLICE_LENGTH(sub) == j - i);
- for (k = 0; k < j - i; k++) {
- GPR_ASSERT(GPR_SLICE_START_PTR(sub)[k] == (uint8_t)(i + k));
- }
- gpr_slice_unref(sub);
- }
- }
- gpr_slice_unref(slice);
-}
-
-static void check_head_tail(gpr_slice slice, gpr_slice head, gpr_slice tail) {
- GPR_ASSERT(GPR_SLICE_LENGTH(slice) ==
- GPR_SLICE_LENGTH(head) + GPR_SLICE_LENGTH(tail));
- GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice), GPR_SLICE_START_PTR(head),
- GPR_SLICE_LENGTH(head)));
- GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice) + GPR_SLICE_LENGTH(head),
- GPR_SLICE_START_PTR(tail), GPR_SLICE_LENGTH(tail)));
-}
-
-static void test_slice_split_head_works(size_t length) {
- gpr_slice slice;
- gpr_slice head, tail;
- size_t i;
-
- LOG_TEST_NAME("test_slice_split_head_works");
- gpr_log(GPR_INFO, "length=%" PRIuPTR, length);
-
- /* Create a slice in which each byte is equal to the distance from it to the
- beginning of the slice. */
- slice = gpr_slice_malloc(length);
- for (i = 0; i < length; i++) {
- GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i;
- }
-
- /* Ensure that for all subsets length is correct and that we start on the
- correct byte. Additionally check that no copies were made. */
- for (i = 0; i < length; i++) {
- tail = gpr_slice_ref(slice);
- head = gpr_slice_split_head(&tail, i);
- check_head_tail(slice, head, tail);
- gpr_slice_unref(tail);
- gpr_slice_unref(head);
- }
-
- gpr_slice_unref(slice);
-}
-
-static void test_slice_split_tail_works(size_t length) {
- gpr_slice slice;
- gpr_slice head, tail;
- size_t i;
-
- LOG_TEST_NAME("test_slice_split_tail_works");
- gpr_log(GPR_INFO, "length=%" PRIuPTR, length);
-
- /* Create a slice in which each byte is equal to the distance from it to the
- beginning of the slice. */
- slice = gpr_slice_malloc(length);
- for (i = 0; i < length; i++) {
- GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i;
- }
-
- /* Ensure that for all subsets length is correct and that we start on the
- correct byte. Additionally check that no copies were made. */
- for (i = 0; i < length; i++) {
- head = gpr_slice_ref(slice);
- tail = gpr_slice_split_tail(&head, i);
- check_head_tail(slice, head, tail);
- gpr_slice_unref(tail);
- gpr_slice_unref(head);
- }
-
- gpr_slice_unref(slice);
-}
-
-static void test_slice_from_copied_string_works(void) {
- static const char *text = "HELLO WORLD!";
- gpr_slice slice;
-
- LOG_TEST_NAME("test_slice_from_copied_string_works");
-
- slice = gpr_slice_from_copied_string(text);
- GPR_ASSERT(strlen(text) == GPR_SLICE_LENGTH(slice));
- GPR_ASSERT(0 ==
- memcmp(text, GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice)));
- gpr_slice_unref(slice);
-}
-
-int main(int argc, char **argv) {
- unsigned length;
- grpc_test_init(argc, argv);
- test_slice_malloc_returns_something_sensible();
- test_slice_new_returns_something_sensible();
- test_slice_new_with_user_data();
- test_slice_new_with_len_returns_something_sensible();
- for (length = 0; length < 128; length++) {
- test_slice_sub_works(length);
- test_slice_split_head_works(length);
- test_slice_split_tail_works(length);
- }
- test_slice_from_copied_string_works();
- return 0;
-}
diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c
index 378e45a942..af232db350 100644
--- a/test/core/support/string_test.c
+++ b/test/core/support/string_test.c
@@ -76,34 +76,6 @@ static void test_dump(void) {
expect_dump("ab", 2, GPR_DUMP_HEX | GPR_DUMP_ASCII, "61 62 'ab'");
}
-static void expect_slice_dump(gpr_slice slice, uint32_t flags,
- const char *result) {
- char *got = gpr_dump_slice(slice, flags);
- GPR_ASSERT(0 == strcmp(got, result));
- gpr_free(got);
- gpr_slice_unref(slice);
-}
-
-static void test_dump_slice(void) {
- static const char *text = "HELLO WORLD!";
- static const char *long_text =
- "It was a bright cold day in April, and the clocks were striking "
- "thirteen. Winston Smith, his chin nuzzled into his breast in an effort "
- "to escape the vile wind, slipped quickly through the glass doors of "
- "Victory Mansions, though not quickly enough to prevent a swirl of "
- "gritty dust from entering along with him.";
-
- LOG_TEST_NAME("test_dump_slice");
-
- expect_slice_dump(gpr_slice_from_copied_string(text), GPR_DUMP_ASCII, text);
- expect_slice_dump(gpr_slice_from_copied_string(long_text), GPR_DUMP_ASCII,
- long_text);
- expect_slice_dump(gpr_slice_from_copied_buffer("\x01", 1), GPR_DUMP_HEX,
- "01");
- expect_slice_dump(gpr_slice_from_copied_buffer("\x01", 1),
- GPR_DUMP_HEX | GPR_DUMP_ASCII, "01 '.'");
-}
-
static void test_pu32_fail(const char *s) {
uint32_t out;
GPR_ASSERT(!gpr_parse_bytes_to_uint32(s, strlen(s), &out));
@@ -221,72 +193,6 @@ static void test_strjoin_sep(void) {
gpr_free(joined);
}
-static void test_strsplit(void) {
- gpr_slice_buffer *parts;
- gpr_slice str;
-
- LOG_TEST_NAME("test_strsplit");
-
- parts = gpr_malloc(sizeof(gpr_slice_buffer));
- gpr_slice_buffer_init(parts);
-
- str = gpr_slice_from_copied_string("one, two, three, four");
- gpr_slice_split(str, ", ", parts);
- GPR_ASSERT(4 == parts->count);
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "one"));
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "two"));
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[2], "three"));
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[3], "four"));
- gpr_slice_buffer_reset_and_unref(parts);
- gpr_slice_unref(str);
-
- /* separator not present in string */
- str = gpr_slice_from_copied_string("one two three four");
- gpr_slice_split(str, ", ", parts);
- GPR_ASSERT(1 == parts->count);
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "one two three four"));
- gpr_slice_buffer_reset_and_unref(parts);
- gpr_slice_unref(str);
-
- /* separator at the end */
- str = gpr_slice_from_copied_string("foo,");
- gpr_slice_split(str, ",", parts);
- GPR_ASSERT(2 == parts->count);
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "foo"));
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], ""));
- gpr_slice_buffer_reset_and_unref(parts);
- gpr_slice_unref(str);
-
- /* separator at the beginning */
- str = gpr_slice_from_copied_string(",foo");
- gpr_slice_split(str, ",", parts);
- GPR_ASSERT(2 == parts->count);
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], ""));
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "foo"));
- gpr_slice_buffer_reset_and_unref(parts);
- gpr_slice_unref(str);
-
- /* standalone separator */
- str = gpr_slice_from_copied_string(",");
- gpr_slice_split(str, ",", parts);
- GPR_ASSERT(2 == parts->count);
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], ""));
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], ""));
- gpr_slice_buffer_reset_and_unref(parts);
- gpr_slice_unref(str);
-
- /* empty input */
- str = gpr_slice_from_copied_string("");
- gpr_slice_split(str, ", ", parts);
- GPR_ASSERT(1 == parts->count);
- GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], ""));
- gpr_slice_buffer_reset_and_unref(parts);
- gpr_slice_unref(str);
-
- gpr_slice_buffer_destroy(parts);
- gpr_free(parts);
-}
-
static void test_ltoa() {
char *str;
char buf[GPR_LTOA_MIN_BUFSIZE];
@@ -337,6 +243,8 @@ static void test_int64toa() {
static void test_leftpad() {
char *padded;
+ LOG_TEST_NAME("test_leftpad");
+
padded = gpr_leftpad("foo", ' ', 5);
GPR_ASSERT(0 == strcmp(" foo", padded));
gpr_free(padded);
@@ -367,25 +275,37 @@ static void test_leftpad() {
}
static void test_stricmp(void) {
+ LOG_TEST_NAME("test_stricmp");
+
GPR_ASSERT(0 == gpr_stricmp("hello", "hello"));
GPR_ASSERT(0 == gpr_stricmp("HELLO", "hello"));
GPR_ASSERT(gpr_stricmp("a", "b") < 0);
GPR_ASSERT(gpr_stricmp("b", "a") > 0);
}
+static void test_memrchr(void) {
+ LOG_TEST_NAME("test_memrchr");
+
+ GPR_ASSERT(NULL == gpr_memrchr(NULL, 'a', 0));
+ GPR_ASSERT(NULL == gpr_memrchr("", 'a', 0));
+ GPR_ASSERT(NULL == gpr_memrchr("hello", 'b', 5));
+ GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'h', 5), "hello"));
+ GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'o', 5), "o"));
+ GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'l', 5), "lo"));
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
test_strdup();
test_dump();
- test_dump_slice();
test_parse_uint32();
test_asprintf();
test_strjoin();
test_strjoin_sep();
- test_strsplit();
test_ltoa();
test_int64toa();
test_leftpad();
test_stricmp();
+ test_memrchr();
return 0;
}