diff options
author | David Garcia Quintas <dgq@google.com> | 2015-08-24 12:33:05 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2015-08-24 12:33:05 -0700 |
commit | fe5f25490d4e290ecf2fc52de64c1230429fd0a3 (patch) | |
tree | cc515354f572c29e02deee5d953e99094d660307 /test/core | |
parent | a4c4f02a63eb70fcd21a102cde9aa536dcd17f67 (diff) |
Improvements to the grpc_channel_args_compression_algorithm_set_state api
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/channel/channel_args_test.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/test/core/channel/channel_args_test.c b/test/core/channel/channel_args_test.c index 227cc1f415..87f006acde 100644 --- a/test/core/channel/channel_args_test.c +++ b/test/core/channel/channel_args_test.c @@ -45,7 +45,7 @@ static void test_create(void) { grpc_arg arg_string; grpc_arg to_add[2]; grpc_channel_args *ch_args; - + arg_int.key = "int_arg"; arg_int.type = GRPC_ARG_INTEGER; arg_int.value.integer = 123; @@ -57,7 +57,7 @@ static void test_create(void) { to_add[0] = arg_int; to_add[1] = arg_string; ch_args = grpc_channel_args_copy_and_add(NULL, to_add, 2); - + GPR_ASSERT(ch_args->num_args == 2); GPR_ASSERT(strcmp(ch_args->args[0].key, arg_int.key) == 0); GPR_ASSERT(ch_args->args[0].type == arg_int.type); @@ -84,7 +84,7 @@ static void test_set_compression_algorithm(void) { } static void test_compression_algorithm_states(void) { - grpc_channel_args *ch_args; + grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate; int states_bitset; size_t i; @@ -97,12 +97,15 @@ static void test_compression_algorithm_states(void) { } /* disable gzip and deflate */ - ch_args = grpc_channel_args_compression_algorithm_set_state( - ch_args, GRPC_COMPRESS_GZIP, 0); - ch_args = grpc_channel_args_compression_algorithm_set_state( - ch_args, GRPC_COMPRESS_DEFLATE, 0); - - states_bitset = grpc_channel_args_compression_algorithm_get_states(ch_args); + ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state( + &ch_args, GRPC_COMPRESS_GZIP, 0); + GPR_ASSERT(ch_args == ch_args_wo_gzip); + ch_args_wo_gzip_deflate = grpc_channel_args_compression_algorithm_set_state( + &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0); + GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate); + + states_bitset = grpc_channel_args_compression_algorithm_get_states( + ch_args_wo_gzip_deflate); for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE) { GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0); @@ -112,10 +115,12 @@ static void test_compression_algorithm_states(void) { } /* re-enabled gzip only */ - ch_args = grpc_channel_args_compression_algorithm_set_state( - ch_args, GRPC_COMPRESS_GZIP, 1); + ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state( + &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1); + GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate); - states_bitset = grpc_channel_args_compression_algorithm_get_states(ch_args); + states_bitset = + grpc_channel_args_compression_algorithm_get_states(ch_args_wo_gzip); for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { if (i == GRPC_COMPRESS_DEFLATE) { GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0); |