Commit 508c88f6 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Add test for nghttp2_hd_deflate_hd_vec with 1 byte chunk

parent 40d217be
......@@ -1278,10 +1278,11 @@ void test_nghttp2_hd_deflate_hd_vec(void) {
uint8_t buf[4096];
ssize_t blocklen;
nghttp2_mem *mem;
nghttp2_vec vec[2];
nghttp2_vec vec[256];
size_t buflen;
nghttp2_bufs bufs;
nva_out out;
size_t i;
mem = nghttp2_mem_default();
......@@ -1297,8 +1298,7 @@ void test_nghttp2_hd_deflate_hd_vec(void) {
vec[1].base = &buf[buflen / 2];
vec[1].len = buflen / 2;
blocklen =
nghttp2_hd_deflate_hd_vec(deflater, vec, ARRLEN(vec), nva, ARRLEN(nva));
blocklen = nghttp2_hd_deflate_hd_vec(deflater, vec, 2, nva, ARRLEN(nva));
CU_ASSERT(blocklen > 0);
......@@ -1336,8 +1336,7 @@ void test_nghttp2_hd_deflate_hd_vec(void) {
nghttp2_hd_deflate_new(&deflater, 4096);
nghttp2_hd_inflate_new(&inflater);
blocklen =
nghttp2_hd_deflate_hd_vec(deflater, vec, ARRLEN(vec), nva, ARRLEN(nva));
blocklen = nghttp2_hd_deflate_hd_vec(deflater, vec, 2, nva, ARRLEN(nva));
CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == blocklen);
......@@ -1355,13 +1354,42 @@ void test_nghttp2_hd_deflate_hd_vec(void) {
vec[1].base = &buf[buflen / 2];
vec[1].len = (buflen / 2) - 1;
blocklen =
nghttp2_hd_deflate_hd_vec(deflater, vec, ARRLEN(vec), nva, ARRLEN(nva));
blocklen = nghttp2_hd_deflate_hd_vec(deflater, vec, 2, nva, ARRLEN(nva));
CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == blocklen);
nghttp2_hd_inflate_del(inflater);
nghttp2_hd_deflate_del(deflater);
/* check the case where chunk size is 1 */
nghttp2_hd_deflate_new(&deflater, 4096);
nghttp2_hd_inflate_new(&inflater);
buflen = nghttp2_hd_deflate_bound(deflater, nva, ARRLEN(nva));
assert(buflen <= ARRLEN(vec));
for (i = 0; i < buflen; ++i) {
vec[i].base = &buf[i];
vec[i].len = 1;
}
blocklen = nghttp2_hd_deflate_hd_vec(deflater, vec, buflen, nva, ARRLEN(nva));
CU_ASSERT(blocklen > 0);
nghttp2_bufs_wrap_init(&bufs, buf, (size_t)blocklen, mem);
bufs.head->buf.last += blocklen;
CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0, mem));
CU_ASSERT(ARRLEN(nva) == out.nvlen);
assert_nv_equal(nva, out.nva, ARRLEN(nva), mem);
nghttp2_bufs_wrap_free(&bufs);
nghttp2_hd_inflate_del(inflater);
nghttp2_hd_deflate_del(deflater);
nva_out_reset(&out, mem);
}
static size_t encode_length(uint8_t *buf, uint64_t n, size_t prefix) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment