diff options
author | Muxi Yan <mxyan@google.com> | 2017-09-25 12:38:35 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-09-25 12:38:35 -0700 |
commit | 68ee7ce732f7c45f0cf85d672ef38542639244c6 (patch) | |
tree | 5b3c083f9978c8c0efed408572f41dccdacb54f0 /test/core/compression | |
parent | 1c285b98122ef8fe31aa3325a4c10f5b05107ca8 (diff) |
clang-format
Diffstat (limited to 'test/core/compression')
-rw-r--r-- | test/core/compression/algorithm_test.c | 17 | ||||
-rw-r--r-- | test/core/compression/compression_test.c | 156 | ||||
-rw-r--r-- | test/core/compression/message_compress_test.c | 23 |
3 files changed, 104 insertions, 92 deletions
diff --git a/test/core/compression/algorithm_test.c b/test/core/compression/algorithm_test.c index 879664ea70..d637e2c0c2 100644 --- a/test/core/compression/algorithm_test.c +++ b/test/core/compression/algorithm_test.c @@ -53,15 +53,22 @@ static void test_algorithm_mesh(void) { if (parsed == 0) { continue; } else if (grpc_compression_algorithm_is_message(parsed)) { - mdelem = grpc_message_compression_encoding_mdelem(grpc_compression_algorithm_to_message_compression_algorithm(parsed)); + mdelem = grpc_message_compression_encoding_mdelem( + grpc_compression_algorithm_to_message_compression_algorithm(parsed)); grpc_slice value = GRPC_MDVALUE(mdelem); - GPR_ASSERT(0 == memcmp(&name[message_prefix_length], GRPC_SLICE_START_PTR(value), GRPC_SLICE_LENGTH(value))); + GPR_ASSERT(0 == memcmp(&name[message_prefix_length], + GRPC_SLICE_START_PTR(value), + GRPC_SLICE_LENGTH(value))); GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING)); } else { - mdelem = grpc_stream_compression_encoding_mdelem(grpc_compression_algorithm_to_stream_compression_algorithm(parsed)); + mdelem = grpc_stream_compression_encoding_mdelem( + grpc_compression_algorithm_to_stream_compression_algorithm(parsed)); grpc_slice value = GRPC_MDVALUE(mdelem); - GPR_ASSERT(0 == memcmp(&name[stream_prefix_length], GRPC_SLICE_START_PTR(value), GRPC_SLICE_LENGTH(value))); - GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_CONTENT_ENCODING)); + GPR_ASSERT(0 == memcmp(&name[stream_prefix_length], + GRPC_SLICE_START_PTR(value), + GRPC_SLICE_LENGTH(value))); + GPR_ASSERT( + grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_CONTENT_ENCODING)); } grpc_slice_unref_internal(&exec_ctx, mdstr); GRPC_MDELEM_UNREF(&exec_ctx, mdelem); diff --git a/test/core/compression/compression_test.c b/test/core/compression/compression_test.c index 10f7f07a44..fb5876a57a 100644 --- a/test/core/compression/compression_test.c +++ b/test/core/compression/compression_test.c @@ -28,9 +28,11 @@ static void test_compression_algorithm_parse(void) { size_t i; - const char *valid_names[] = {"identity", "message/gzip", "message/deflate", "stream/gzip"}; + const char *valid_names[] = {"identity", "message/gzip", "message/deflate", + "stream/gzip"}; const grpc_compression_algorithm valid_algorithms[] = { - GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP}; + GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP, + GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP}; const char *invalid_names[] = {"gzip2", "foo", "", "2gzip"}; gpr_log(GPR_DEBUG, "test_compression_algorithm_parse"); @@ -59,9 +61,11 @@ static void test_compression_algorithm_name(void) { int success; const char *name; size_t i; - const char *valid_names[] = {"identity", "message/gzip", "message/deflate", "stream/gzip"}; + const char *valid_names[] = {"identity", "message/gzip", "message/deflate", + "stream/gzip"}; const grpc_compression_algorithm valid_algorithms[] = { - GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP}; + GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP, + GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP}; gpr_log(GPR_DEBUG, "test_compression_algorithm_name"); @@ -90,28 +94,28 @@ static void test_compression_algorithm_for_level(void) { accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } { @@ -125,28 +129,28 @@ static void test_compression_algorithm_for_level(void) { accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } { @@ -160,28 +164,28 @@ static void test_compression_algorithm_for_level(void) { accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } { @@ -196,28 +200,28 @@ static void test_compression_algorithm_for_level(void) { accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } { @@ -231,28 +235,28 @@ static void test_compression_algorithm_for_level(void) { accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } { @@ -268,28 +272,28 @@ static void test_compression_algorithm_for_level(void) { accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, - accepted_encodings)); + grpc_compression_algorithm_for_level( + GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } } diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index 55267f4aa8..015664d281 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -51,7 +51,8 @@ static void assert_passthrough(grpc_slice value, int was_compressed; const char *algorithm_name; - GPR_ASSERT(grpc_message_compression_algorithm_name(algorithm, &algorithm_name) != 0); + GPR_ASSERT( + grpc_message_compression_algorithm_name(algorithm, &algorithm_name) != 0); gpr_log( GPR_INFO, "assert_passthrough: value_length=%" PRIuPTR " value_hash=0x%08x " @@ -93,8 +94,8 @@ static void assert_passthrough(grpc_slice value, { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(grpc_msg_decompress( - &exec_ctx, was_compressed ? algorithm : GRPC_MESSAGE_COMPRESS_NONE, &compressed, - &output)); + &exec_ctx, was_compressed ? algorithm : GRPC_MESSAGE_COMPRESS_NONE, + &compressed, &output)); grpc_exec_ctx_finish(&exec_ctx); } @@ -188,8 +189,8 @@ static void test_bad_decompression_data_crc(void) { memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4); /* try (and fail) to decompress the corrupted compresed buffer */ - GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_GZIP, &corrupted, - &output)); + GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_GZIP, + &corrupted, &output)); grpc_exec_ctx_finish(&exec_ctx); grpc_slice_buffer_destroy(&input); @@ -210,8 +211,8 @@ static void test_bad_decompression_data_trailing_garbage(void) { /* try (and fail) to decompress the invalid compresed buffer */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_DEFLATE, &input, - &output)); + GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_DEFLATE, + &input, &output)); grpc_exec_ctx_finish(&exec_ctx); grpc_slice_buffer_destroy(&input); @@ -229,8 +230,8 @@ static void test_bad_decompression_data_stream(void) { /* try (and fail) to decompress the invalid compresed buffer */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_DEFLATE, &input, - &output)); + GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_DEFLATE, + &input, &output)); grpc_exec_ctx_finish(&exec_ctx); grpc_slice_buffer_destroy(&input); @@ -248,8 +249,8 @@ static void test_bad_compression_algorithm(void) { &input, grpc_slice_from_copied_string("Never gonna give you up")); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - was_compressed = grpc_msg_compress(&exec_ctx, GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT, - &input, &output); + was_compressed = grpc_msg_compress( + &exec_ctx, GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT, &input, &output); GPR_ASSERT(0 == was_compressed); was_compressed = grpc_msg_compress( |