aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/compression
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2015-12-09 10:46:14 -0800
committerGravatar David Garcia Quintas <dgq@google.com>2015-12-09 10:46:14 -0800
commit0a08791bce6fc59e855de06d48d818ac588d6d12 (patch)
tree051082a3b158c49f7e3297874e0f727273524d33 /test/core/compression
parent248904afadfc8eb987d51abbb7f8ea216f548891 (diff)
Increased message_compress.c coverage
Diffstat (limited to 'test/core/compression')
-rw-r--r--test/core/compression/message_compress_test.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c
index 4b45d22885..70359a3f69 100644
--- a/test/core/compression/message_compress_test.c
+++ b/test/core/compression/message_compress_test.c
@@ -168,6 +168,49 @@ static void test_bad_data(void) {
gpr_slice_buffer_destroy(&output);
}
+static void test_bad_compression_algorithm(void) {
+ gpr_slice_buffer input;
+ gpr_slice_buffer output;
+ int was_compressed;
+
+ gpr_slice_buffer_init(&input);
+ gpr_slice_buffer_init(&output);
+ gpr_slice_buffer_add(&input, gpr_slice_from_copied_string(
+ "Never gonna give you up"));
+ was_compressed =
+ grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ GPR_ASSERT(0 == was_compressed);
+
+ was_compressed =
+ grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output);
+ GPR_ASSERT(0 == was_compressed);
+
+ gpr_slice_buffer_destroy(&input);
+ gpr_slice_buffer_destroy(&output);
+}
+
+static void test_bad_decompression_algorithm(void) {
+ gpr_slice_buffer input;
+ gpr_slice_buffer output;
+ int was_decompressed;
+
+ gpr_slice_buffer_init(&input);
+ gpr_slice_buffer_init(&output);
+ gpr_slice_buffer_add(&input,
+ gpr_slice_from_copied_string(
+ "I'm not really compressed but it doesn't matter"));
+ was_decompressed =
+ grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ GPR_ASSERT(0 == was_decompressed);
+
+ was_decompressed =
+ grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output);
+ GPR_ASSERT(0 == was_decompressed);
+
+ gpr_slice_buffer_destroy(&input);
+ gpr_slice_buffer_destroy(&output);
+}
+
int main(int argc, char **argv) {
unsigned i, j, k, m;
grpc_slice_split_mode uncompressed_split_modes[] = {
@@ -192,6 +235,8 @@ int main(int argc, char **argv) {
}
test_bad_data();
+ test_bad_compression_algorithm();
+ test_bad_decompression_algorithm();
grpc_shutdown();
return 0;