summaryrefslogtreecommitdiffstats
path: root/tests/nghttp2_hd_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/nghttp2_hd_test.c')
-rw-r--r--tests/nghttp2_hd_test.c722
1 files changed, 385 insertions, 337 deletions
diff --git a/tests/nghttp2_hd_test.c b/tests/nghttp2_hd_test.c
index 657d895..d57127f 100644
--- a/tests/nghttp2_hd_test.c
+++ b/tests/nghttp2_hd_test.c
@@ -27,11 +27,42 @@
#include <stdio.h>
#include <assert.h>
-#include <CUnit/CUnit.h>
+#include "munit.h"
#include "nghttp2_hd.h"
#include "nghttp2_frame.h"
#include "nghttp2_test_helper.h"
+#include "nghttp2_assertion.h"
+
+static const MunitTest tests[] = {
+ munit_void_test(test_nghttp2_hd_deflate),
+ munit_void_test(test_nghttp2_hd_deflate_same_indexed_repr),
+ munit_void_test(test_nghttp2_hd_inflate_indexed),
+ munit_void_test(test_nghttp2_hd_inflate_indname_noinc),
+ munit_void_test(test_nghttp2_hd_inflate_indname_inc),
+ munit_void_test(test_nghttp2_hd_inflate_indname_inc_eviction),
+ munit_void_test(test_nghttp2_hd_inflate_newname_noinc),
+ munit_void_test(test_nghttp2_hd_inflate_newname_inc),
+ munit_void_test(test_nghttp2_hd_inflate_clearall_inc),
+ munit_void_test(test_nghttp2_hd_inflate_zero_length_huffman),
+ munit_void_test(test_nghttp2_hd_inflate_expect_table_size_update),
+ munit_void_test(test_nghttp2_hd_inflate_unexpected_table_size_update),
+ munit_void_test(test_nghttp2_hd_ringbuf_reserve),
+ munit_void_test(test_nghttp2_hd_change_table_size),
+ munit_void_test(test_nghttp2_hd_deflate_inflate),
+ munit_void_test(test_nghttp2_hd_no_index),
+ munit_void_test(test_nghttp2_hd_deflate_bound),
+ munit_void_test(test_nghttp2_hd_public_api),
+ munit_void_test(test_nghttp2_hd_deflate_hd_vec),
+ munit_void_test(test_nghttp2_hd_decode_length),
+ munit_void_test(test_nghttp2_hd_huff_encode),
+ munit_void_test(test_nghttp2_hd_huff_decode),
+ munit_test_end(),
+};
+
+const MunitSuite hd_suite = {
+ "/hd", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE,
+};
void test_nghttp2_hd_deflate(void) {
nghttp2_hd_deflater deflater;
@@ -47,7 +78,7 @@ void test_nghttp2_hd_deflate(void) {
nghttp2_nv nva5[] = {MAKE_NV(":path", "/style.css"),
MAKE_NV("x-nghttp2", "")};
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nva_out out;
int rv;
nghttp2_mem *mem;
@@ -56,17 +87,17 @@ void test_nghttp2_hd_deflate(void) {
frame_pack_bufs_init(&bufs);
nva_out_init(&out);
- CU_ASSERT(0 == nghttp2_hd_deflate_init(&deflater, mem));
- CU_ASSERT(0 == nghttp2_hd_inflate_init(&inflater, mem));
+ assert_int(0, ==, nghttp2_hd_deflate_init(&deflater, mem));
+ assert_int(0, ==, nghttp2_hd_inflate_init(&inflater, mem));
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva1, ARRLEN(nva1));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(3 == out.nvlen);
+ assert_size(3, ==, out.nvlen);
assert_nv_equal(nva1, out.nva, 3, mem);
nva_out_reset(&out, mem);
@@ -74,13 +105,13 @@ void test_nghttp2_hd_deflate(void) {
/* Second headers */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva2, ARRLEN(nva2));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(2 == out.nvlen);
+ assert_size(2, ==, out.nvlen);
assert_nv_equal(nva2, out.nva, 2, mem);
nva_out_reset(&out, mem);
@@ -89,13 +120,13 @@ void test_nghttp2_hd_deflate(void) {
/* Third headers, including same header field name, but value is not
the same. */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva3, ARRLEN(nva3));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(3 == out.nvlen);
+ assert_size(3, ==, out.nvlen);
assert_nv_equal(nva3, out.nva, 3, mem);
nva_out_reset(&out, mem);
@@ -103,13 +134,13 @@ void test_nghttp2_hd_deflate(void) {
/* Fourth headers, including duplicate header fields. */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva4, ARRLEN(nva4));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(3 == out.nvlen);
+ assert_size(3, ==, out.nvlen);
assert_nv_equal(nva4, out.nva, 3, mem);
nva_out_reset(&out, mem);
@@ -117,13 +148,13 @@ void test_nghttp2_hd_deflate(void) {
/* Fifth headers includes empty value */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva5, ARRLEN(nva5));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(2 == out.nvlen);
+ assert_size(2, ==, out.nvlen);
assert_nv_equal(nva5, out.nva, 2, mem);
nva_out_reset(&out, mem);
@@ -142,7 +173,7 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
nghttp2_nv nva2[] = {MAKE_NV("host", "alpha"), MAKE_NV("host", "alpha"),
MAKE_NV("host", "alpha")};
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nva_out out;
int rv;
nghttp2_mem *mem;
@@ -151,18 +182,18 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
frame_pack_bufs_init(&bufs);
nva_out_init(&out);
- CU_ASSERT(0 == nghttp2_hd_deflate_init(&deflater, mem));
- CU_ASSERT(0 == nghttp2_hd_inflate_init(&inflater, mem));
+ assert_int(0, ==, nghttp2_hd_deflate_init(&deflater, mem));
+ assert_int(0, ==, nghttp2_hd_inflate_init(&inflater, mem));
/* Encode 2 same headers. Emit 1 literal reprs and 1 index repr. */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva1, ARRLEN(nva1));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(2 == out.nvlen);
+ assert_size(2, ==, out.nvlen);
assert_nv_equal(nva1, out.nva, 2, mem);
nva_out_reset(&out, mem);
@@ -170,13 +201,13 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
/* Encode 3 same headers. This time, emits 3 index reprs. */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva2, ARRLEN(nva2));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen == 3);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_int(0, ==, rv);
+ assert_ptrdiff(3, ==, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(3 == out.nvlen);
+ assert_size(3, ==, out.nvlen);
assert_nv_equal(nva2, out.nva, 3, mem);
nva_out_reset(&out, mem);
@@ -191,7 +222,7 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
void test_nghttp2_hd_inflate_indexed(void) {
nghttp2_hd_inflater inflater;
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_nv nv = MAKE_NV(":path", "/");
nva_out out;
nghttp2_mem *mem;
@@ -204,12 +235,12 @@ void test_nghttp2_hd_inflate_indexed(void) {
nghttp2_bufs_addb(&bufs, (1 << 7) | 4);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(1 == blocklen);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(1, ==, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
+ assert_size(1, ==, out.nvlen);
assert_nv_equal(&nv, out.nva, 1, mem);
@@ -219,11 +250,11 @@ void test_nghttp2_hd_inflate_indexed(void) {
/* index = 0 is error */
nghttp2_bufs_addb(&bufs, 1 << 7);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(1 == blocklen);
- CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
- inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(1, ==, blocklen);
+ assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==,
+ inflate_hd(&inflater, &out, &bufs, 0, mem));
nghttp2_bufs_free(&bufs);
nghttp2_hd_inflate_free(&inflater);
@@ -232,7 +263,7 @@ void test_nghttp2_hd_inflate_indexed(void) {
void test_nghttp2_hd_inflate_indname_noinc(void) {
nghttp2_hd_inflater inflater;
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_nv nv[] = {/* Huffman */
MAKE_NV("user-agent", "nghttp2"),
/* Expecting no huffman */
@@ -248,18 +279,19 @@ void test_nghttp2_hd_inflate_indname_noinc(void) {
nghttp2_hd_inflate_init(&inflater, mem);
for (i = 0; i < ARRLEN(nv); ++i) {
- CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 57, &nv[i],
- NGHTTP2_HD_WITHOUT_INDEXING));
+ assert_int(0, ==,
+ nghttp2_hd_emit_indname_block(&bufs, 57, &nv[i],
+ NGHTTP2_HD_WITHOUT_INDEXING));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
+ assert_size(1, ==, out.nvlen);
assert_nv_equal(&nv[i], out.nva, 1, mem);
- CU_ASSERT(0 == inflater.ctx.hd_table.len);
- CU_ASSERT(61 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
+ assert_size(0, ==, inflater.ctx.hd_table.len);
+ assert_size(61, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater));
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -272,7 +304,7 @@ void test_nghttp2_hd_inflate_indname_noinc(void) {
void test_nghttp2_hd_inflate_indname_inc(void) {
nghttp2_hd_inflater inflater;
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_nv nv = MAKE_NV("user-agent", "nghttp2");
nva_out out;
nghttp2_mem *mem;
@@ -283,18 +315,19 @@ void test_nghttp2_hd_inflate_indname_inc(void) {
nva_out_init(&out);
nghttp2_hd_inflate_init(&inflater, mem);
- CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 57, &nv,
- NGHTTP2_HD_WITH_INDEXING));
+ assert_int(
+ 0, ==,
+ nghttp2_hd_emit_indname_block(&bufs, 57, &nv, NGHTTP2_HD_WITH_INDEXING));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
+ assert_size(1, ==, out.nvlen);
assert_nv_equal(&nv, out.nva, 1, mem);
- CU_ASSERT(1 == inflater.ctx.hd_table.len);
- CU_ASSERT(62 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
+ assert_size(1, ==, inflater.ctx.hd_table.len);
+ assert_size(62, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater));
assert_nv_equal(
&nv,
nghttp2_hd_inflate_get_table_entry(
@@ -309,7 +342,7 @@ void test_nghttp2_hd_inflate_indname_inc(void) {
void test_nghttp2_hd_inflate_indname_inc_eviction(void) {
nghttp2_hd_inflater inflater;
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
uint8_t value[1025];
nva_out out;
nghttp2_nv nv;
@@ -328,31 +361,35 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void) {
nv.flags = NGHTTP2_NV_FLAG_NONE;
- CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 14, &nv,
- NGHTTP2_HD_WITH_INDEXING));
- CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 15, &nv,
- NGHTTP2_HD_WITH_INDEXING));
- CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 16, &nv,
- NGHTTP2_HD_WITH_INDEXING));
- CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 17, &nv,
- NGHTTP2_HD_WITH_INDEXING));
+ assert_int(
+ 0, ==,
+ nghttp2_hd_emit_indname_block(&bufs, 14, &nv, NGHTTP2_HD_WITH_INDEXING));
+ assert_int(
+ 0, ==,
+ nghttp2_hd_emit_indname_block(&bufs, 15, &nv, NGHTTP2_HD_WITH_INDEXING));
+ assert_int(
+ 0, ==,
+ nghttp2_hd_emit_indname_block(&bufs, 16, &nv, NGHTTP2_HD_WITH_INDEXING));
+ assert_int(
+ 0, ==,
+ nghttp2_hd_emit_indname_block(&bufs, 17, &nv, NGHTTP2_HD_WITH_INDEXING));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(blocklen > 0);
+ assert_ptrdiff(0, <, blocklen);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(4 == out.nvlen);
- CU_ASSERT(14 == out.nva[0].namelen);
- CU_ASSERT(0 == memcmp("accept-charset", out.nva[0].name, out.nva[0].namelen));
- CU_ASSERT(sizeof(value) - 1 == out.nva[0].valuelen);
+ assert_size(4, ==, out.nvlen);
+ assert_size(14, ==, out.nva[0].namelen);
+ assert_memory_equal(out.nva[0].namelen, "accept-charset", out.nva[0].name);
+ assert_size(sizeof(value) - 1, ==, out.nva[0].valuelen);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
- CU_ASSERT(3 == inflater.ctx.hd_table.len);
- CU_ASSERT(64 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
+ assert_size(3, ==, inflater.ctx.hd_table.len);
+ assert_size(64, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater));
nghttp2_bufs_free(&bufs);
nghttp2_hd_inflate_free(&inflater);
@@ -361,7 +398,7 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void) {
void test_nghttp2_hd_inflate_newname_noinc(void) {
nghttp2_hd_inflater inflater;
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_nv nv[] = {/* Expecting huffman for both */
MAKE_NV("my-long-content-length", "nghttp2"),
/* Expecting no huffman for both */
@@ -380,17 +417,18 @@ void test_nghttp2_hd_inflate_newname_noinc(void) {
nva_out_init(&out);
nghttp2_hd_inflate_init(&inflater, mem);
for (i = 0; i < ARRLEN(nv); ++i) {
- CU_ASSERT(0 == nghttp2_hd_emit_newname_block(&bufs, &nv[i],
- NGHTTP2_HD_WITHOUT_INDEXING));
+ assert_int(0, ==,
+ nghttp2_hd_emit_newname_block(&bufs, &nv[i],
+ NGHTTP2_HD_WITHOUT_INDEXING));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
+ assert_size(1, ==, out.nvlen);
assert_nv_equal(&nv[i], out.nva, 1, mem);
- CU_ASSERT(0 == inflater.ctx.hd_table.len);
+ assert_size(0, ==, inflater.ctx.hd_table.len);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -403,7 +441,7 @@ void test_nghttp2_hd_inflate_newname_noinc(void) {
void test_nghttp2_hd_inflate_newname_inc(void) {
nghttp2_hd_inflater inflater;
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_nv nv = MAKE_NV("x-rel", "nghttp2");
nva_out out;
nghttp2_mem *mem;
@@ -414,17 +452,18 @@ void test_nghttp2_hd_inflate_newname_inc(void) {
nva_out_init(&out);
nghttp2_hd_inflate_init(&inflater, mem);
- CU_ASSERT(
- 0 == nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING));
+ assert_int(
+ 0, ==,
+ nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
+ assert_size(1, ==, out.nvlen);
assert_nv_equal(&nv, out.nva, 1, mem);
- CU_ASSERT(1 == inflater.ctx.hd_table.len);
+ assert_size(1, ==, inflater.ctx.hd_table.len);
assert_nv_equal(
&nv,
nghttp2_hd_inflate_get_table_entry(
@@ -439,7 +478,7 @@ void test_nghttp2_hd_inflate_newname_inc(void) {
void test_nghttp2_hd_inflate_clearall_inc(void) {
nghttp2_hd_inflater inflater;
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_nv nv;
uint8_t value[4061];
nva_out out;
@@ -461,26 +500,27 @@ void test_nghttp2_hd_inflate_clearall_inc(void) {
nghttp2_hd_inflate_init(&inflater, mem);
- CU_ASSERT(
- 0 == nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING));
+ assert_int(
+ 0, ==,
+ nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
+ assert_size(1, ==, out.nvlen);
assert_nv_equal(&nv, out.nva, 1, mem);
- CU_ASSERT(0 == inflater.ctx.hd_table.len);
+ assert_size(0, ==, inflater.ctx.hd_table.len);
nva_out_reset(&out, mem);
/* Do it again */
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
+ assert_size(1, ==, out.nvlen);
assert_nv_equal(&nv, out.nva, 1, mem);
- CU_ASSERT(0 == inflater.ctx.hd_table.len);
+ assert_size(0, ==, inflater.ctx.hd_table.len);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -489,17 +529,18 @@ void test_nghttp2_hd_inflate_clearall_inc(void) {
header table */
nv.valuelen = sizeof(value) - 2;
- CU_ASSERT(
- 0 == nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING));
+ assert_int(
+ 0, ==,
+ nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
+ assert_size(1, ==, out.nvlen);
assert_nv_equal(&nv, out.nva, 1, mem);
- CU_ASSERT(1 == inflater.ctx.hd_table.len);
+ assert_size(1, ==, inflater.ctx.hd_table.len);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -530,13 +571,13 @@ void test_nghttp2_hd_inflate_zero_length_huffman(void) {
/* ptr[3] = 0x80; */
nghttp2_hd_inflate_init(&inflater, mem);
- CU_ASSERT(4 == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(4, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
- CU_ASSERT(1 == out.nva[0].namelen);
- CU_ASSERT('x' == out.nva[0].name[0]);
- CU_ASSERT(NULL == out.nva[0].value);
- CU_ASSERT(0 == out.nva[0].valuelen);
+ assert_size(1, ==, out.nvlen);
+ assert_size(1, ==, out.nva[0].namelen);
+ assert_uint8('x', ==, out.nva[0].name[0]);
+ assert_null(out.nva[0].value);
+ assert_size(0, ==, out.nva[0].valuelen);
nva_out_reset(&out, mem);
nghttp2_bufs_free(&bufs);
@@ -561,8 +602,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) {
inflation. */
nghttp2_hd_inflate_change_table_size(&inflater, 4095);
nghttp2_hd_inflate_change_table_size(&inflater, 4096);
- CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
- inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==,
+ inflate_hd(&inflater, &out, &bufs, 0, mem));
nva_out_reset(&out, mem);
nghttp2_hd_inflate_free(&inflater);
@@ -571,8 +612,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) {
* size is not changed. */
nghttp2_hd_inflate_init(&inflater, mem);
nghttp2_hd_inflate_change_table_size(&inflater, 4096);
- CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) ==
- inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==,
+ inflate_hd(&inflater, &out, &bufs, 0, mem));
nva_out_reset(&out, mem);
nghttp2_hd_inflate_free(&inflater);
@@ -581,8 +622,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) {
new size is larger than current size. */
nghttp2_hd_inflate_init(&inflater, mem);
nghttp2_hd_inflate_change_table_size(&inflater, 4097);
- CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) ==
- inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==,
+ inflate_hd(&inflater, &out, &bufs, 0, mem));
nva_out_reset(&out, mem);
nghttp2_hd_inflate_free(&inflater);
@@ -595,8 +636,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) {
nghttp2_bufs_reset(&bufs);
nghttp2_hd_emit_table_size(&bufs, 112);
- CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
- inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==,
+ inflate_hd(&inflater, &out, &bufs, 0, mem));
nva_out_reset(&out, mem);
nghttp2_hd_inflate_free(&inflater);
@@ -610,8 +651,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) {
nghttp2_hd_emit_table_size(&bufs, 111);
nghttp2_hd_emit_table_size(&bufs, 4096);
- CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) ==
- inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==,
+ inflate_hd(&inflater, &out, &bufs, 0, mem));
nva_out_reset(&out, mem);
nghttp2_hd_inflate_free(&inflater);
@@ -625,8 +666,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) {
nghttp2_hd_emit_table_size(&bufs, 111);
nghttp2_hd_emit_table_size(&bufs, 4096);
- CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
- inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==,
+ inflate_hd(&inflater, &out, &bufs, 0, mem));
nva_out_reset(&out, mem);
nghttp2_hd_inflate_free(&inflater);
@@ -649,8 +690,8 @@ void test_nghttp2_hd_inflate_unexpected_table_size_update(void) {
nghttp2_bufs_add(&bufs, data, sizeof(data));
nghttp2_hd_inflate_init(&inflater, mem);
- CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
- inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==,
+ inflate_hd(&inflater, &out, &bufs, 0, mem));
nva_out_reset(&out, mem);
nghttp2_bufs_free(&bufs);
@@ -664,8 +705,8 @@ void test_nghttp2_hd_ringbuf_reserve(void) {
nghttp2_bufs bufs;
nva_out out;
int i;
- ssize_t rv;
- ssize_t blocklen;
+ nghttp2_ssize rv;
+ nghttp2_ssize blocklen;
nghttp2_mem *mem;
mem = nghttp2_mem_default();
@@ -688,14 +729,14 @@ void test_nghttp2_hd_ringbuf_reserve(void) {
for (i = 0; i < 150; ++i) {
memcpy(nv.value, &i, sizeof(i));
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, &nv, 1);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
+ assert_ptrdiff(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(1 == out.nvlen);
+ assert_size(1, ==, out.nvlen);
assert_nv_equal(&nv, out.nva, 1, mem);
nva_out_reset(&out, mem);
@@ -715,9 +756,9 @@ void test_nghttp2_hd_change_table_size(void) {
nghttp2_nv nva[] = {MAKE_NV("alpha", "bravo"), MAKE_NV("charlie", "delta")};
nghttp2_nv nva2[] = {MAKE_NV(":path", "/")};
nghttp2_bufs bufs;
- ssize_t rv;
+ int rv;
nva_out out;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_mem *mem;
mem = nghttp2_mem_default();
@@ -729,87 +770,87 @@ void test_nghttp2_hd_change_table_size(void) {
nghttp2_hd_inflate_init(&inflater, mem);
/* inflater changes notifies 8000 max header table size */
- CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 8000));
- CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 8000));
+ assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 8000));
+ assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 8000));
- CU_ASSERT(4096 == deflater.ctx.hd_table_bufsize_max);
+ assert_size(4096, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(4096 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
+ assert_size(4096, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(8000, ==, inflater.settings_hd_table_bufsize_max);
/* This will emit encoding context update with header table size 4096 */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(2 == deflater.ctx.hd_table.len);
- CU_ASSERT(63 == nghttp2_hd_deflate_get_num_table_entries(&deflater));
- CU_ASSERT(4096 == deflater.ctx.hd_table_bufsize_max);
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_size(2, ==, deflater.ctx.hd_table.len);
+ assert_size(63, ==, nghttp2_hd_deflate_get_num_table_entries(&deflater));
+ assert_size(4096, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(2 == inflater.ctx.hd_table.len);
- CU_ASSERT(63 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
- CU_ASSERT(4096 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_size(2, ==, inflater.ctx.hd_table.len);
+ assert_size(63, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater));
+ assert_size(4096, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(8000, ==, inflater.settings_hd_table_bufsize_max);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
/* inflater changes header table size to 1024 */
- CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 1024));
- CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 1024));
+ assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 1024));
+ assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 1024));
- CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max);
+ assert_size(1024, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(1024 == inflater.settings_hd_table_bufsize_max);
+ assert_size(1024, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(1024, ==, inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(2 == deflater.ctx.hd_table.len);
- CU_ASSERT(63 == nghttp2_hd_deflate_get_num_table_entries(&deflater));
- CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max);
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_size(2, ==, deflater.ctx.hd_table.len);
+ assert_size(63, ==, nghttp2_hd_deflate_get_num_table_entries(&deflater));
+ assert_size(1024, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(2 == inflater.ctx.hd_table.len);
- CU_ASSERT(63 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
- CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(1024 == inflater.settings_hd_table_bufsize_max);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_size(2, ==, inflater.ctx.hd_table.len);
+ assert_size(63, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater));
+ assert_size(1024, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(1024, ==, inflater.settings_hd_table_bufsize_max);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
/* inflater changes header table size to 0 */
- CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 0));
- CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 0));
+ assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 0));
+ assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 0));
- CU_ASSERT(0 == deflater.ctx.hd_table.len);
- CU_ASSERT(61 == nghttp2_hd_deflate_get_num_table_entries(&deflater));
- CU_ASSERT(0 == deflater.ctx.hd_table_bufsize_max);
+ assert_size(0, ==, deflater.ctx.hd_table.len);
+ assert_size(61, ==, nghttp2_hd_deflate_get_num_table_entries(&deflater));
+ assert_size(0, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(0 == inflater.ctx.hd_table.len);
- CU_ASSERT(61 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
- CU_ASSERT(0 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(0 == inflater.settings_hd_table_bufsize_max);
+ assert_size(0, ==, inflater.ctx.hd_table.len);
+ assert_size(61, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater));
+ assert_size(0, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(0, ==, inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(0 == deflater.ctx.hd_table.len);
- CU_ASSERT(61 == nghttp2_hd_deflate_get_num_table_entries(&deflater));
- CU_ASSERT(0 == deflater.ctx.hd_table_bufsize_max);
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_size(0, ==, deflater.ctx.hd_table.len);
+ assert_size(61, ==, nghttp2_hd_deflate_get_num_table_entries(&deflater));
+ assert_size(0, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(0 == inflater.ctx.hd_table.len);
- CU_ASSERT(61 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
- CU_ASSERT(0 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(0 == inflater.settings_hd_table_bufsize_max);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_size(0, ==, inflater.ctx.hd_table.len);
+ assert_size(61, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater));
+ assert_size(0, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(0, ==, inflater.settings_hd_table_bufsize_max);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -825,53 +866,57 @@ void test_nghttp2_hd_change_table_size(void) {
nghttp2_hd_inflate_init(&inflater, mem);
/* First inflater changes header table size to 8000 */
- CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 8000));
- CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 8000));
+ assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 8000));
+ assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 8000));
- CU_ASSERT(8000 == deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(8000 == nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater));
- CU_ASSERT(4096 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(4096 == nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater));
- CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
+ assert_size(8000, ==, deflater.ctx.hd_table_bufsize_max);
+ assert_size(8000, ==,
+ nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater));
+ assert_size(4096, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(4096, ==,
+ nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater));
+ assert_size(8000, ==, inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(2 == deflater.ctx.hd_table.len);
- CU_ASSERT(8000 == deflater.ctx.hd_table_bufsize_max);
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_size(2, ==, deflater.ctx.hd_table.len);
+ assert_size(8000, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(2 == inflater.ctx.hd_table.len);
- CU_ASSERT(8000 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_size(2, ==, inflater.ctx.hd_table.len);
+ assert_size(8000, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(8000, ==, inflater.settings_hd_table_bufsize_max);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
- CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 16383));
- CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 16383));
+ assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 16383));
+ assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 16383));
- CU_ASSERT(8192 == deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(8192 == nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater));
+ assert_size(8192, ==, deflater.ctx.hd_table_bufsize_max);
+ assert_size(8192, ==,
+ nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater));
- CU_ASSERT(8000 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(8000 == nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater));
- CU_ASSERT(16383 == inflater.settings_hd_table_bufsize_max);
+ assert_size(8000, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(8000, ==,
+ nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater));
+ assert_size(16383, ==, inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(2 == deflater.ctx.hd_table.len);
- CU_ASSERT(8192 == deflater.ctx.hd_table_bufsize_max);
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_size(2, ==, deflater.ctx.hd_table.len);
+ assert_size(8192, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(2 == inflater.ctx.hd_table.len);
- CU_ASSERT(8192 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(16383 == inflater.settings_hd_table_bufsize_max);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_size(2, ==, inflater.ctx.hd_table.len);
+ assert_size(8192, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(16383, ==, inflater.settings_hd_table_bufsize_max);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -879,9 +924,9 @@ void test_nghttp2_hd_change_table_size(void) {
/* Lastly, check the error condition */
rv = nghttp2_hd_emit_table_size(&bufs, 25600);
- CU_ASSERT(rv == 0);
- CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
- inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_int(0, ==, rv);
+ assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==,
+ inflate_hd(&inflater, &out, &bufs, 0, mem));
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -894,21 +939,21 @@ void test_nghttp2_hd_change_table_size(void) {
nghttp2_hd_deflate_init2(&deflater, 1024, mem);
nghttp2_hd_inflate_init(&inflater, mem);
- CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max);
+ assert_size(1024, ==, deflater.ctx.hd_table_bufsize_max);
/* This emits context update with buffer size 1024 */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(2 == deflater.ctx.hd_table.len);
- CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max);
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_size(2, ==, deflater.ctx.hd_table.len);
+ assert_size(1024, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(2 == inflater.ctx.hd_table.len);
- CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(4096 == inflater.settings_hd_table_bufsize_max);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_size(2, ==, inflater.ctx.hd_table.len);
+ assert_size(1024, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(4096, ==, inflater.settings_hd_table_bufsize_max);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -920,18 +965,20 @@ void test_nghttp2_hd_change_table_size(void) {
nghttp2_hd_deflate_init2(&deflater, UINT32_MAX, mem);
nghttp2_hd_inflate_init(&inflater, mem);
- CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, UINT32_MAX));
- CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, UINT32_MAX));
+ assert_int(0, ==,
+ nghttp2_hd_inflate_change_table_size(&inflater, UINT32_MAX));
+ assert_int(0, ==,
+ nghttp2_hd_deflate_change_table_size(&deflater, UINT32_MAX));
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(UINT32_MAX == deflater.ctx.hd_table_bufsize_max);
+ assert_int(0, ==, rv);
+ assert_size(UINT32_MAX, ==, deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(UINT32_MAX == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(UINT32_MAX == inflater.settings_hd_table_bufsize_max);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_size(UINT32_MAX, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(UINT32_MAX, ==, inflater.settings_hd_table_bufsize_max);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -943,25 +990,25 @@ void test_nghttp2_hd_change_table_size(void) {
nghttp2_hd_deflate_init2(&deflater, 4096, mem);
nghttp2_hd_inflate_init(&inflater, mem);
- CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 0));
- CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 3000));
- CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 0));
- CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 3000));
+ assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 0));
+ assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 3000));
+ assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 0));
+ assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 3000));
- CU_ASSERT(0 == deflater.min_hd_table_bufsize_max);
- CU_ASSERT(3000 == deflater.ctx.hd_table_bufsize_max);
+ assert_size(0, ==, deflater.min_hd_table_bufsize_max);
+ assert_size(3000, ==, deflater.ctx.hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva2, 1);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(3 < blocklen);
- CU_ASSERT(3000 == deflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(UINT32_MAX == deflater.min_hd_table_bufsize_max);
+ assert_int(0, ==, rv);
+ assert_ptrdiff(3, <, blocklen);
+ assert_size(3000, ==, deflater.ctx.hd_table_bufsize_max);
+ assert_size(UINT32_MAX, ==, deflater.min_hd_table_bufsize_max);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(3000 == inflater.ctx.hd_table_bufsize_max);
- CU_ASSERT(3000 == inflater.settings_hd_table_bufsize_max);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_size(3000, ==, inflater.ctx.hd_table_bufsize_max);
+ assert_size(3000, ==, inflater.settings_hd_table_bufsize_max);
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@@ -977,7 +1024,7 @@ static void check_deflate_inflate(nghttp2_hd_deflater *deflater,
nghttp2_nv *nva, size_t nvlen,
nghttp2_mem *mem) {
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nva_out out;
int rv;
@@ -985,14 +1032,14 @@ static void check_deflate_inflate(nghttp2_hd_deflater *deflater,
nva_out_init(&out);
rv = nghttp2_hd_deflate_hd_bufs(deflater, &bufs, nva, nvlen);
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen >= 0);
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <=, blocklen);
- CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0, mem));
+ assert_ptrdiff(blocklen, ==, inflate_hd(inflater, &out, &bufs, 0, mem));
- CU_ASSERT(nvlen == out.nvlen);
+ assert_size(nvlen, ==, out.nvlen);
assert_nv_equal(nva, out.nva, nvlen, mem);
nva_out_reset(&out, mem);
@@ -1161,7 +1208,7 @@ void test_nghttp2_hd_no_index(void) {
nghttp2_hd_deflater deflater;
nghttp2_hd_inflater inflater;
nghttp2_bufs bufs;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_nv nva[] = {
MAKE_NV(":method", "GET"), MAKE_NV(":method", "POST"),
MAKE_NV(":path", "/foo"), MAKE_NV("version", "HTTP/1.1"),
@@ -1187,18 +1234,18 @@ void test_nghttp2_hd_no_index(void) {
nghttp2_hd_inflate_init(&inflater, mem);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, ARRLEN(nva));
- blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
+ blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs);
- CU_ASSERT(0 == rv);
- CU_ASSERT(blocklen > 0);
- CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
+ assert_int(0, ==, rv);
+ assert_ptrdiff(0, <, blocklen);
+ assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem));
- CU_ASSERT(ARRLEN(nva) == out.nvlen);
+ assert_size(ARRLEN(nva), ==, out.nvlen);
assert_nv_equal(nva, out.nva, ARRLEN(nva), mem);
- CU_ASSERT(out.nva[0].flags == NGHTTP2_NV_FLAG_NONE);
+ assert_uint8(NGHTTP2_NV_FLAG_NONE, ==, out.nva[0].flags);
for (i = 1; i < ARRLEN(nva); ++i) {
- CU_ASSERT(out.nva[i].flags == NGHTTP2_NV_FLAG_NO_INDEX);
+ assert_uint8(NGHTTP2_NV_FLAG_NO_INDEX, ==, out.nva[i].flags);
}
nva_out_reset(&out, mem);
@@ -1222,17 +1269,17 @@ void test_nghttp2_hd_deflate_bound(void) {
bound = nghttp2_hd_deflate_bound(&deflater, nva, ARRLEN(nva));
- CU_ASSERT(12 + 6 * 2 * 2 + nva[0].namelen + nva[0].valuelen + nva[1].namelen +
- nva[1].valuelen ==
- bound);
+ assert_size(12 + 6 * 2 * 2 + nva[0].namelen + nva[0].valuelen +
+ nva[1].namelen + nva[1].valuelen,
+ ==, bound);
nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, ARRLEN(nva));
- CU_ASSERT(bound > (size_t)nghttp2_bufs_len(&bufs));
+ assert_size((size_t)nghttp2_bufs_len(&bufs), <, bound);
bound2 = nghttp2_hd_deflate_bound(&deflater, nva, ARRLEN(nva));
- CU_ASSERT(bound == bound2);
+ assert_size(bound, ==, bound2);
nghttp2_bufs_free(&bufs);
nghttp2_hd_deflate_free(&deflater);
@@ -1244,25 +1291,25 @@ void test_nghttp2_hd_public_api(void) {
nghttp2_nv nva[] = {MAKE_NV("alpha", "bravo"), MAKE_NV("charlie", "delta")};
uint8_t buf[4096];
size_t buflen;
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_bufs bufs;
nghttp2_mem *mem;
mem = nghttp2_mem_default();
- CU_ASSERT(0 == nghttp2_hd_deflate_new(&deflater, 4096));
- CU_ASSERT(0 == nghttp2_hd_inflate_new(&inflater));
+ assert_int(0, ==, nghttp2_hd_deflate_new(&deflater, 4096));
+ assert_int(0, ==, nghttp2_hd_inflate_new(&inflater));
buflen = nghttp2_hd_deflate_bound(deflater, nva, ARRLEN(nva));
- blocklen = nghttp2_hd_deflate_hd(deflater, buf, buflen, nva, ARRLEN(nva));
+ blocklen = nghttp2_hd_deflate_hd2(deflater, buf, buflen, nva, ARRLEN(nva));
- CU_ASSERT(blocklen > 0);
+ assert_ptrdiff(0, <, blocklen);
nghttp2_bufs_wrap_init(&bufs, buf, (size_t)blocklen, mem);
bufs.head->buf.last += blocklen;
- CU_ASSERT(blocklen == inflate_hd(inflater, NULL, &bufs, 0, mem));
+ assert_ptrdiff(blocklen, ==, inflate_hd(inflater, NULL, &bufs, 0, mem));
nghttp2_bufs_wrap_free(&bufs);
@@ -1270,12 +1317,12 @@ void test_nghttp2_hd_public_api(void) {
nghttp2_hd_deflate_del(deflater);
/* See NGHTTP2_ERR_INSUFF_BUFSIZE */
- CU_ASSERT(0 == nghttp2_hd_deflate_new(&deflater, 4096));
+ assert_int(0, ==, nghttp2_hd_deflate_new(&deflater, 4096));
- blocklen = nghttp2_hd_deflate_hd(deflater, buf, (size_t)(blocklen - 1), nva,
- ARRLEN(nva));
+ blocklen = nghttp2_hd_deflate_hd2(deflater, buf, (size_t)(blocklen - 1), nva,
+ ARRLEN(nva));
- CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == blocklen);
+ assert_ptrdiff(NGHTTP2_ERR_INSUFF_BUFSIZE, ==, blocklen);
nghttp2_hd_deflate_del(deflater);
}
@@ -1292,7 +1339,7 @@ void test_nghttp2_hd_deflate_hd_vec(void) {
MAKE_NV("content-length", "1000000007"),
};
uint8_t buf[4096];
- ssize_t blocklen;
+ nghttp2_ssize blocklen;
nghttp2_mem *mem;
nghttp2_vec vec[256];
size_t buflen;
@@ -1314,16 +1361,16 @@ 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, 2, nva, ARRLEN(nva));
+ blocklen = nghttp2_hd_deflate_hd_vec2(deflater, vec, 2, nva, ARRLEN(nva));
- CU_ASSERT(blocklen > 0);
+ assert_ptrdiff(0, <, blocklen);
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));
+ assert_ptrdiff(blocklen, ==, inflate_hd(inflater, &out, &bufs, 0, mem));
- CU_ASSERT(ARRLEN(nva) == out.nvlen);
+ assert_size(ARRLEN(nva), ==, out.nvlen);
assert_nv_equal(nva, out.nva, ARRLEN(nva), mem);
nghttp2_bufs_wrap_free(&bufs);
@@ -1336,9 +1383,9 @@ 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, NULL, 0, nva, ARRLEN(nva));
+ blocklen = nghttp2_hd_deflate_hd_vec2(deflater, NULL, 0, nva, ARRLEN(nva));
- CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == blocklen);
+ assert_ptrdiff(NGHTTP2_ERR_INSUFF_BUFSIZE, ==, blocklen);
nghttp2_hd_inflate_del(inflater);
nghttp2_hd_deflate_del(deflater);
@@ -1352,9 +1399,9 @@ 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, 2, nva, ARRLEN(nva));
+ blocklen = nghttp2_hd_deflate_hd_vec2(deflater, vec, 2, nva, ARRLEN(nva));
- CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == blocklen);
+ assert_ptrdiff(NGHTTP2_ERR_INSUFF_BUFSIZE, ==, blocklen);
nghttp2_hd_inflate_del(inflater);
nghttp2_hd_deflate_del(deflater);
@@ -1370,15 +1417,15 @@ 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, 2, nva, ARRLEN(nva));
+ blocklen = nghttp2_hd_deflate_hd_vec2(deflater, vec, 2, nva, ARRLEN(nva));
- CU_ASSERT(blocklen > 0);
+ assert_ptrdiff(0, <, blocklen);
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_ptrdiff(blocklen, ==, inflate_hd(inflater, &out, &bufs, 0, mem));
+ assert_size(ARRLEN(nva), ==, out.nvlen);
assert_nv_equal(nva, out.nva, ARRLEN(nva), mem);
nghttp2_bufs_wrap_free(&bufs);
@@ -1400,15 +1447,16 @@ void test_nghttp2_hd_deflate_hd_vec(void) {
vec[i].len = 1;
}
- blocklen = nghttp2_hd_deflate_hd_vec(deflater, vec, buflen, nva, ARRLEN(nva));
+ blocklen =
+ nghttp2_hd_deflate_hd_vec2(deflater, vec, buflen, nva, ARRLEN(nva));
- CU_ASSERT(blocklen > 0);
+ assert_ptrdiff(0, <, blocklen);
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_ptrdiff(blocklen, ==, inflate_hd(inflater, &out, &bufs, 0, mem));
+ assert_size(ARRLEN(nva), ==, out.nvlen);
assert_nv_equal(nva, out.nva, ARRLEN(nva), mem);
nghttp2_bufs_wrap_free(&bufs);
@@ -1453,7 +1501,7 @@ void test_nghttp2_hd_decode_length(void) {
uint8_t buf[16];
uint8_t *bufp;
size_t len;
- ssize_t rv;
+ nghttp2_ssize rv;
size_t i;
memset(buf, 0, sizeof(buf));
@@ -1461,9 +1509,9 @@ void test_nghttp2_hd_decode_length(void) {
rv = nghttp2_hd_decode_length(&out, &shift, &fin, 0, 0, buf, buf + len, 7);
- CU_ASSERT((ssize_t)len == rv);
- CU_ASSERT(0 != fin);
- CU_ASSERT(UINT32_MAX == out);
+ assert_ptrdiff((nghttp2_ssize)len, ==, rv);
+ assert_true(fin);
+ assert_uint32(UINT32_MAX, ==, out);
/* Make sure that we can decode integer if we feed 1 byte at a
time */
@@ -1476,16 +1524,16 @@ void test_nghttp2_hd_decode_length(void) {
rv = nghttp2_hd_decode_length(&out, &shift, &fin, out, shift, bufp,
bufp + 1, 7);
- CU_ASSERT(rv == 1);
+ assert_ptrdiff(1, ==, rv);
if (fin) {
break;
}
}
- CU_ASSERT(i == len - 1);
- CU_ASSERT(0 != fin);
- CU_ASSERT(UINT32_MAX == out);
+ assert_size(len - 1, ==, i);
+ assert_true(fin);
+ assert_size(UINT32_MAX, ==, out);
/* Check overflow case */
memset(buf, 0, sizeof(buf));
@@ -1493,7 +1541,7 @@ void test_nghttp2_hd_decode_length(void) {
rv = nghttp2_hd_decode_length(&out, &shift, &fin, 0, 0, buf, buf + len, 7);
- CU_ASSERT(-1 == rv);
+ assert_ptrdiff(-1, ==, rv);
/* Check the case that shift goes beyond 32 bits */
buf[0] = 255;
@@ -1506,12 +1554,12 @@ void test_nghttp2_hd_decode_length(void) {
rv = nghttp2_hd_decode_length(&out, &shift, &fin, 0, 0, buf, buf + 7, 8);
- CU_ASSERT(-1 == rv);
+ assert_ptrdiff(-1, ==, rv);
}
void test_nghttp2_hd_huff_encode(void) {
int rv;
- ssize_t len;
+ nghttp2_ssize len;
nghttp2_buf outbuf;
nghttp2_bufs bufs;
nghttp2_hd_huff_decode_context ctx;
@@ -1524,17 +1572,17 @@ void test_nghttp2_hd_huff_encode(void) {
rv = nghttp2_hd_huff_encode(&bufs, t1, sizeof(t1));
- CU_ASSERT(rv == 0);
+ assert_int(0, ==, rv);
nghttp2_hd_huff_decode_context_init(&ctx);
len = nghttp2_hd_huff_decode(&ctx, &outbuf, bufs.cur->buf.pos,
nghttp2_bufs_len(&bufs), 1);
- CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == len);
- CU_ASSERT((ssize_t)sizeof(t1) == nghttp2_buf_len(&outbuf));
+ assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, len);
+ assert_size(sizeof(t1), ==, nghttp2_buf_len(&outbuf));
- CU_ASSERT(0 == memcmp(t1, outbuf.pos, sizeof(t1)));
+ assert_memory_equal(sizeof(t1), t1, outbuf.pos);
nghttp2_bufs_free(&bufs);
}
@@ -1544,34 +1592,34 @@ void test_nghttp2_hd_huff_decode(void) {
nghttp2_hd_huff_decode_context ctx;
nghttp2_buf outbuf;
uint8_t b[256];
- ssize_t len;
+ nghttp2_ssize len;
nghttp2_buf_wrap_init(&outbuf, b, sizeof(b));
nghttp2_hd_huff_decode_context_init(&ctx);
len = nghttp2_hd_huff_decode(&ctx, &outbuf, e, 1, 1);
- CU_ASSERT(1 == len);
- CU_ASSERT(0 == memcmp("a", outbuf.pos, 1));
+ assert_ptrdiff(1, ==, len);
+ assert_memory_equal(1, "a", outbuf.pos);
/* Premature sequence must elicit decoding error */
nghttp2_buf_wrap_init(&outbuf, b, sizeof(b));
nghttp2_hd_huff_decode_context_init(&ctx);
len = nghttp2_hd_huff_decode(&ctx, &outbuf, e, 2, 1);
- CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == len);
+ assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, len);
/* Fully decoding EOS is error */
nghttp2_buf_wrap_init(&outbuf, b, sizeof(b));
nghttp2_hd_huff_decode_context_init(&ctx);
len = nghttp2_hd_huff_decode(&ctx, &outbuf, e, 2, 6);
- CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == len);
+ assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, len);
/* Check failure state */
nghttp2_buf_wrap_init(&outbuf, b, sizeof(b));
nghttp2_hd_huff_decode_context_init(&ctx);
len = nghttp2_hd_huff_decode(&ctx, &outbuf, e, 5, 0);
- CU_ASSERT(5 == len);
- CU_ASSERT(nghttp2_hd_huff_decode_failure_state(&ctx));
+ assert_ptrdiff(5, ==, len);
+ assert_true(nghttp2_hd_huff_decode_failure_state(&ctx));
}