summaryrefslogtreecommitdiffstats
path: root/tests/nghttp2_alpn_test.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/nghttp2_alpn_test.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/tests/nghttp2_alpn_test.c b/tests/nghttp2_alpn_test.c
index d471d5f..805a23e 100644
--- a/tests/nghttp2_alpn_test.c
+++ b/tests/nghttp2_alpn_test.c
@@ -27,25 +27,36 @@
#include <stdio.h>
#include <string.h>
-#include <CUnit/CUnit.h>
+#include "munit.h"
+
#include <nghttp2/nghttp2.h>
+static const MunitTest tests[] = {
+ munit_void_test(test_nghttp2_alpn),
+ munit_test_end(),
+};
+
+const MunitSuite alpn_suite = {
+ "/alpn", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE,
+};
+
static void http2(void) {
const unsigned char p[] = {8, 'h', 't', 't', 'p', '/', '1', '.', '1', 2,
'h', '2', 6, 's', 'p', 'd', 'y', '/', '3'};
unsigned char outlen;
const unsigned char *out;
- CU_ASSERT(1 == nghttp2_select_next_protocol((unsigned char **)&out, &outlen,
- p, sizeof(p)));
- CU_ASSERT(NGHTTP2_PROTO_VERSION_ID_LEN == outlen);
- CU_ASSERT(memcmp(NGHTTP2_PROTO_VERSION_ID, out, outlen) == 0);
+ assert_int(1, ==,
+ nghttp2_select_next_protocol((unsigned char **)&out, &outlen, p,
+ sizeof(p)));
+ assert_uchar(NGHTTP2_PROTO_VERSION_ID_LEN, ==, outlen);
+ assert_memory_equal(outlen, NGHTTP2_PROTO_VERSION_ID, out);
outlen = 0;
out = NULL;
- CU_ASSERT(1 == nghttp2_select_alpn(&out, &outlen, p, sizeof(p)));
- CU_ASSERT(NGHTTP2_PROTO_VERSION_ID_LEN == outlen);
- CU_ASSERT(memcmp(NGHTTP2_PROTO_VERSION_ID, out, outlen) == 0);
+ assert_int(1, ==, nghttp2_select_alpn(&out, &outlen, p, sizeof(p)));
+ assert_uchar(NGHTTP2_PROTO_VERSION_ID_LEN, ==, outlen);
+ assert_memory_equal(outlen, NGHTTP2_PROTO_VERSION_ID, out);
}
static void http11(void) {
@@ -55,17 +66,18 @@ static void http11(void) {
};
unsigned char outlen;
const unsigned char *out;
- CU_ASSERT(0 == nghttp2_select_next_protocol((unsigned char **)&out, &outlen,
- spdy, sizeof(spdy)));
- CU_ASSERT(8 == outlen);
- CU_ASSERT(memcmp("http/1.1", out, outlen) == 0);
+ assert_int(0, ==,
+ nghttp2_select_next_protocol((unsigned char **)&out, &outlen, spdy,
+ sizeof(spdy)));
+ assert_uchar(8, ==, outlen);
+ assert_memory_equal(outlen, "http/1.1", out);
outlen = 0;
out = NULL;
- CU_ASSERT(0 == nghttp2_select_alpn(&out, &outlen, spdy, sizeof(spdy)));
- CU_ASSERT(8 == outlen);
- CU_ASSERT(memcmp("http/1.1", out, outlen) == 0);
+ assert_int(0, ==, nghttp2_select_alpn(&out, &outlen, spdy, sizeof(spdy)));
+ assert_uchar(8, ==, outlen);
+ assert_memory_equal(outlen, "http/1.1", out);
}
static void no_overlap(void) {
@@ -75,17 +87,18 @@ static void no_overlap(void) {
};
unsigned char outlen = 0;
const unsigned char *out = NULL;
- CU_ASSERT(-1 == nghttp2_select_next_protocol((unsigned char **)&out, &outlen,
- spdy, sizeof(spdy)));
- CU_ASSERT(0 == outlen);
- CU_ASSERT(NULL == out);
+ assert_int(-1, ==,
+ nghttp2_select_next_protocol((unsigned char **)&out, &outlen, spdy,
+ sizeof(spdy)));
+ assert_uchar(0, ==, outlen);
+ assert_null(out);
outlen = 0;
out = NULL;
- CU_ASSERT(-1 == nghttp2_select_alpn(&out, &outlen, spdy, sizeof(spdy)));
- CU_ASSERT(0 == outlen);
- CU_ASSERT(NULL == out);
+ assert_int(-1, ==, nghttp2_select_alpn(&out, &outlen, spdy, sizeof(spdy)));
+ assert_uchar(0, ==, outlen);
+ assert_null(out);
}
void test_nghttp2_alpn(void) {