aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/compression/message_compress_test.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-12-09 15:34:27 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-12-09 15:34:27 -0800
commitb897337994a355d7d8aeca043b608fa1e100bf79 (patch)
tree779439f28e3f20bcd17acc6fa24c679e19fc58c7 /test/core/compression/message_compress_test.c
parentface446997e271107553a071c46f8ca0fde0bebb (diff)
parent9bfc2ce06cd700fcbaa701914b4b294b7d601948 (diff)
Merge github.com:grpc/grpc into connectivity-state
Diffstat (limited to 'test/core/compression/message_compress_test.c')
-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;