aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/slice
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/slice')
-rw-r--r--test/core/slice/b64_test.c46
-rw-r--r--test/core/slice/slice_hash_table_test.c40
2 files changed, 42 insertions, 44 deletions
diff --git a/test/core/slice/b64_test.c b/test/core/slice/b64_test.c
index bd375aa6a7..0740315195 100644
--- a/test/core/slice/b64_test.c
+++ b/test/core/slice/b64_test.c
@@ -44,14 +44,14 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) {
const char *hello = "hello";
char *hello_b64 =
grpc_base64_encode(hello, strlen(hello), url_safe, multiline);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice hello_slice = grpc_base64_decode(&exec_ctx, hello_b64, url_safe);
+ exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello));
GPR_ASSERT(strncmp((const char *)GRPC_SLICE_START_PTR(hello_slice), hello,
GRPC_SLICE_LENGTH(hello_slice)) == 0);
- grpc_slice_unref_internal(&exec_ctx, hello_slice);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(hello_slice);
+ grpc_exec_ctx_finish();
gpr_free(hello_b64);
}
@@ -64,15 +64,15 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
/* Try all the different paddings. */
for (i = 0; i < 3; i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ exec_ctx = GRPC_EXEC_CTX_INIT;
b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
+ orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i));
GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded),
sizeof(orig) - i));
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
+ grpc_slice_unref_internal(orig_decoded);
gpr_free(b64);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_exec_ctx_finish();
}
}
@@ -116,19 +116,19 @@ static void test_url_safe_unsafe_mismatch_failure(void) {
int url_safe = 1;
for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ exec_ctx = GRPC_EXEC_CTX_INIT;
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, !url_safe);
+ orig_decoded = grpc_base64_decode(b64, !url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
+ grpc_slice_unref_internal(orig_decoded);
b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
+ orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(orig_decoded);
+ grpc_exec_ctx_finish();
}
static void test_rfc4648_test_vectors(void) {
@@ -166,40 +166,40 @@ static void test_rfc4648_test_vectors(void) {
static void test_unpadded_decode(void) {
grpc_slice decoded;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmFy", 0);
+ exec_ctx = GRPC_EXEC_CTX_INIT;
+ decoded = grpc_base64_decode("Zm9vYmFy", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmE", 0);
+ decoded = grpc_base64_decode("Zm9vYmE", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYg", 0);
+ decoded = grpc_base64_decode("Zm9vYg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9v", 0);
+ decoded = grpc_base64_decode("Zm9v", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm8", 0);
+ decoded = grpc_base64_decode("Zm8", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zg", 0);
+ decoded = grpc_base64_decode("Zg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "", 0);
+ decoded = grpc_base64_decode("", 0);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_exec_ctx_finish();
}
int main(int argc, char **argv) {
diff --git a/test/core/slice/slice_hash_table_test.c b/test/core/slice/slice_hash_table_test.c
index f3689aac64..67748433b1 100644
--- a/test/core/slice/slice_hash_table_test.c
+++ b/test/core/slice/slice_hash_table_test.c
@@ -58,9 +58,7 @@ static void check_non_existent_value(const char* key_string,
grpc_slice_unref(key);
}
-static void destroy_string(grpc_exec_ctx* exec_ctx, void* value) {
- gpr_free(value);
-}
+static void destroy_string(void* value) { gpr_free(value); }
static grpc_slice_hash_table* create_table_from_entries(
const test_entry* test_entries, size_t num_test_entries,
@@ -119,9 +117,9 @@ static void test_slice_hash_table() {
check_values(test_entries, num_entries, table);
check_non_existent_value("XX", table);
// Clean up.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table);
- grpc_exec_ctx_finish(&exec_ctx);
+ exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_slice_hash_table_unref(table);
+ grpc_exec_ctx_finish();
}
static int value_cmp_fn(void* a, void* b) {
@@ -147,10 +145,10 @@ static void test_slice_hash_table_eq() {
create_table_from_entries(test_entries_b, num_entries_b, value_cmp_fn);
GPR_ASSERT(grpc_slice_hash_table_cmp(table_a, table_b) == 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table_a);
- grpc_slice_hash_table_unref(&exec_ctx, table_b);
- grpc_exec_ctx_finish(&exec_ctx);
+ exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_slice_hash_table_unref(table_a);
+ grpc_slice_hash_table_unref(table_b);
+ grpc_exec_ctx_finish();
}
static void test_slice_hash_table_not_eq() {
@@ -219,17 +217,17 @@ static void test_slice_hash_table_not_eq() {
create_table_from_entries(test_entries_h, num_entries_h, pointer_cmp_fn);
GPR_ASSERT(grpc_slice_hash_table_cmp(table_g, table_h) != 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table_a);
- grpc_slice_hash_table_unref(&exec_ctx, table_b_larger);
- grpc_slice_hash_table_unref(&exec_ctx, table_b_smaller);
- grpc_slice_hash_table_unref(&exec_ctx, table_c);
- grpc_slice_hash_table_unref(&exec_ctx, table_d);
- grpc_slice_hash_table_unref(&exec_ctx, table_e);
- grpc_slice_hash_table_unref(&exec_ctx, table_f);
- grpc_slice_hash_table_unref(&exec_ctx, table_g);
- grpc_slice_hash_table_unref(&exec_ctx, table_h);
- grpc_exec_ctx_finish(&exec_ctx);
+ exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_slice_hash_table_unref(table_a);
+ grpc_slice_hash_table_unref(table_b_larger);
+ grpc_slice_hash_table_unref(table_b_smaller);
+ grpc_slice_hash_table_unref(table_c);
+ grpc_slice_hash_table_unref(table_d);
+ grpc_slice_hash_table_unref(table_e);
+ grpc_slice_hash_table_unref(table_f);
+ grpc_slice_hash_table_unref(table_g);
+ grpc_slice_hash_table_unref(table_h);
+ grpc_exec_ctx_finish();
}
int main(int argc, char** argv) {