diff options
Diffstat (limited to 'test/core/compression')
-rw-r--r-- | test/core/compression/algorithm_test.c | 42 | ||||
-rw-r--r-- | test/core/compression/compression_test.c | 4 | ||||
-rw-r--r-- | test/core/compression/message_compress_test.c | 2 |
3 files changed, 26 insertions, 22 deletions
diff --git a/test/core/compression/algorithm_test.c b/test/core/compression/algorithm_test.c index ff17667b94..37397ced8d 100644 --- a/test/core/compression/algorithm_test.c +++ b/test/core/compression/algorithm_test.c @@ -40,6 +40,7 @@ #include <grpc/support/log.h> #include <grpc/support/useful.h> +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" @@ -51,32 +52,33 @@ static void test_algorithm_mesh(void) { for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { char *name; grpc_compression_algorithm parsed; - grpc_mdstr *mdstr; - grpc_mdelem *mdelem; + grpc_slice mdstr; + grpc_mdelem mdelem; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT( grpc_compression_algorithm_name((grpc_compression_algorithm)i, &name)); - GPR_ASSERT(grpc_compression_algorithm_parse(name, strlen(name), &parsed)); + GPR_ASSERT(grpc_compression_algorithm_parse( + grpc_slice_from_static_string(name), &parsed)); GPR_ASSERT((int)parsed == i); - mdstr = grpc_mdstr_from_string(name); - GPR_ASSERT(mdstr == grpc_compression_algorithm_mdstr(parsed)); - GPR_ASSERT(parsed == grpc_compression_algorithm_from_mdstr(mdstr)); + mdstr = grpc_slice_from_copied_string(name); + GPR_ASSERT(grpc_slice_eq(mdstr, grpc_compression_algorithm_slice(parsed))); + GPR_ASSERT(parsed == grpc_compression_algorithm_from_slice(mdstr)); mdelem = grpc_compression_encoding_mdelem(parsed); - GPR_ASSERT(mdelem->value == mdstr); - GPR_ASSERT(mdelem->key == GRPC_MDSTR_GRPC_ENCODING); - GRPC_MDSTR_UNREF(&exec_ctx, mdstr); + GPR_ASSERT(grpc_slice_eq(GRPC_MDVALUE(mdelem), mdstr)); + GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING)); + grpc_slice_unref_internal(&exec_ctx, mdstr); GRPC_MDELEM_UNREF(&exec_ctx, mdelem); grpc_exec_ctx_finish(&exec_ctx); } /* test failure */ - GPR_ASSERT(NULL == - grpc_compression_encoding_mdelem(GRPC_COMPRESS_ALGORITHMS_COUNT)); + GPR_ASSERT(GRPC_MDISNULL( + grpc_compression_encoding_mdelem(GRPC_COMPRESS_ALGORITHMS_COUNT))); } static void test_algorithm_failure(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_mdstr *mdstr; + grpc_slice mdstr; gpr_log(GPR_DEBUG, "test_algorithm_failure"); @@ -84,14 +86,16 @@ static void test_algorithm_failure(void) { NULL) == 0); GPR_ASSERT(grpc_compression_algorithm_name(GRPC_COMPRESS_ALGORITHMS_COUNT + 1, NULL) == 0); - mdstr = grpc_mdstr_from_string("this-is-an-invalid-algorithm"); - GPR_ASSERT(grpc_compression_algorithm_from_mdstr(mdstr) == + mdstr = grpc_slice_from_static_string("this-is-an-invalid-algorithm"); + GPR_ASSERT(grpc_compression_algorithm_from_slice(mdstr) == GRPC_COMPRESS_ALGORITHMS_COUNT); - GPR_ASSERT(grpc_compression_algorithm_mdstr(GRPC_COMPRESS_ALGORITHMS_COUNT) == - NULL); - GPR_ASSERT(grpc_compression_algorithm_mdstr(GRPC_COMPRESS_ALGORITHMS_COUNT + - 1) == NULL); - GRPC_MDSTR_UNREF(&exec_ctx, mdstr); + GPR_ASSERT(grpc_slice_eq( + grpc_compression_algorithm_slice(GRPC_COMPRESS_ALGORITHMS_COUNT), + grpc_empty_slice())); + GPR_ASSERT(grpc_slice_eq( + grpc_compression_algorithm_slice(GRPC_COMPRESS_ALGORITHMS_COUNT + 1), + grpc_empty_slice())); + grpc_slice_unref_internal(&exec_ctx, mdstr); grpc_exec_ctx_finish(&exec_ctx); } diff --git a/test/core/compression/compression_test.c b/test/core/compression/compression_test.c index 4c43746e33..7b2e56dc01 100644 --- a/test/core/compression/compression_test.c +++ b/test/core/compression/compression_test.c @@ -54,7 +54,7 @@ static void test_compression_algorithm_parse(void) { const char *valid_name = valid_names[i]; grpc_compression_algorithm algorithm; const int success = grpc_compression_algorithm_parse( - valid_name, strlen(valid_name), &algorithm); + grpc_slice_from_static_string(valid_name), &algorithm); GPR_ASSERT(success != 0); GPR_ASSERT(algorithm == valid_algorithms[i]); } @@ -64,7 +64,7 @@ static void test_compression_algorithm_parse(void) { grpc_compression_algorithm algorithm; int success; success = grpc_compression_algorithm_parse( - invalid_name, strlen(invalid_name), &algorithm); + grpc_slice_from_static_string(invalid_name), &algorithm); GPR_ASSERT(success == 0); /* the value of "algorithm" is undefined upon failure */ } diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index 2432ca768a..246a2b3a71 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -114,7 +114,7 @@ static void assert_passthrough(grpc_slice value, } final = grpc_slice_merge(output.slices, output.count); - GPR_ASSERT(0 == grpc_slice_cmp(value, final)); + GPR_ASSERT(grpc_slice_eq(value, final)); grpc_slice_buffer_destroy(&input); grpc_slice_buffer_destroy(&compressed); |