static void test_compression_enable_disable_algorithm(void) { grpc_compression_options options; grpc_compression_algorithm algorithm; gpr_log(GPR_DEBUG, "test_compression_enable_disable_algorithm"); grpc_compression_options_init(&options); for (algorithm = GRPC_COMPRESS_NONE; algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) { /* all algorithms are enabled by default */ GPR_ASSERT(grpc_compression_options_is_algorithm_enabled(&options, algorithm) != 0); } /* disable one by one */ for (algorithm = GRPC_COMPRESS_NONE; algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) { grpc_compression_options_disable_algorithm(&options, algorithm); GPR_ASSERT(grpc_compression_options_is_algorithm_enabled(&options, algorithm) == 0); } /* re-enable one by one */ for (algorithm = GRPC_COMPRESS_NONE; algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) { grpc_compression_options_enable_algorithm(&options, algorithm); GPR_ASSERT(grpc_compression_options_is_algorithm_enabled(&options, algorithm) != 0); } }
/* Disables an algorithm on the current instance, given the name of an * algorithm. * Fails if the algorithm name is invalid. */ void grpc_rb_compression_options_disable_algorithm( grpc_compression_options* compression_options, VALUE algorithm_name) { grpc_compression_algorithm internal_algorithm_value; grpc_rb_compression_options_algorithm_name_to_value_internal( &internal_algorithm_value, algorithm_name); grpc_compression_options_disable_algorithm(compression_options, internal_algorithm_value); }
/* Disables a compression algorithm, given the GRPC core internal number of a * compression algorithm. */ VALUE grpc_rb_compression_options_disable_compression_algorithm_internal( VALUE self, VALUE algorithm_to_disable) { grpc_compression_algorithm compression_algorithm = 0; grpc_rb_compression_options* wrapper = NULL; TypedData_Get_Struct(self, grpc_rb_compression_options, &grpc_rb_compression_options_data_type, wrapper); compression_algorithm = (grpc_compression_algorithm)NUM2INT(algorithm_to_disable); grpc_compression_options_disable_algorithm(wrapper->wrapped, compression_algorithm); return Qnil; }