diff options
author | Craig Tiller <ctiller@google.com> | 2015-07-05 13:30:39 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-07-05 13:30:39 -0700 |
commit | d1dd3a68a2d4af56f1409327c197590dac6968cb (patch) | |
tree | b4269bb0f9aa0dbbdc2e906e4a2f405428e09b6a /test/core | |
parent | 05c97690630640ab41df37858ea23ffce870a509 (diff) | |
parent | c5444224538165ccabd005c5f7f50a4f4627a32a (diff) |
Merge pull request #2117 from dgquintas/bb_from_bbreader
Introduced function to create byte buffers from the output of a byte buffer reader.
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/surface/byte_buffer_reader_test.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.c index 7c2cb9484a..d9c60e4212 100644 --- a/test/core/surface/byte_buffer_reader_test.c +++ b/test/core/surface/byte_buffer_reader_test.c @@ -160,6 +160,30 @@ static void test_read_deflate_compressed_slice(void) { read_compressed_slice(GRPC_COMPRESS_DEFLATE, INPUT_SIZE); } +static void test_byte_buffer_from_reader(void) { + gpr_slice slice; + grpc_byte_buffer *buffer, *buffer_from_reader; + grpc_byte_buffer_reader reader; + + LOG_TEST("test_byte_buffer_from_reader"); + slice = gpr_slice_malloc(4); + memcpy(GPR_SLICE_START_PTR(slice), "test", 4); + buffer = grpc_raw_byte_buffer_create(&slice, 1); + gpr_slice_unref(slice); + grpc_byte_buffer_reader_init(&reader, buffer); + + buffer_from_reader = grpc_raw_byte_buffer_from_reader(&reader); + GPR_ASSERT(buffer->type == buffer_from_reader->type); + GPR_ASSERT(buffer_from_reader->data.raw.compression == GRPC_COMPRESS_NONE); + GPR_ASSERT(buffer_from_reader->data.raw.slice_buffer.count == 1); + GPR_ASSERT(memcmp(GPR_SLICE_START_PTR( + buffer_from_reader->data.raw.slice_buffer.slices[0]), + "test", 4) == 0); + + grpc_byte_buffer_destroy(buffer); + grpc_byte_buffer_destroy(buffer_from_reader); +} + int main(int argc, char **argv) { grpc_test_init(argc, argv); test_read_one_slice(); @@ -167,6 +191,7 @@ int main(int argc, char **argv) { test_read_none_compressed_slice(); test_read_gzip_compressed_slice(); test_read_deflate_compressed_slice(); + test_byte_buffer_from_reader(); return 0; } |