summaryrefslogtreecommitdiff
path: root/common/tests
diff options
context:
space:
mode:
Diffstat (limited to 'common/tests')
-rw-r--r--common/tests/test-url.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/common/tests/test-url.c b/common/tests/test-url.c
index 4c62594..892bf3c 100644
--- a/common/tests/test-url.c
+++ b/common/tests/test-url.c
@@ -120,28 +120,34 @@ static void
test_encode (void)
{
const unsigned char *input = (unsigned char *)"TEST";
- char *encoded;
- size_t length;
+ p11_buffer buf;
+
+ if (!p11_buffer_init_null (&buf, 5))
+ assert_not_reached ();
- encoded = p11_url_encode (input, input + 5, "", &length);
- assert_str_eq ("%54%45%53%54%00", (char *)encoded);
- assert_num_eq (15, length);
+ p11_url_encode (input, input + 5, "", &buf);
+ assert (p11_buffer_ok (&buf));
+ assert_str_eq ("%54%45%53%54%00", (char *)buf.data);
+ assert_num_eq (15, buf.len);
- free (encoded);
+ p11_buffer_uninit (&buf);
}
static void
test_encode_verbatim (void)
{
const unsigned char *input = (unsigned char *)"TEST";
- char *encoded;
- size_t length;
+ p11_buffer buf;
+
+ if (!p11_buffer_init_null (&buf, 5))
+ assert_not_reached ();
- encoded = p11_url_encode (input, input + 5, "ES", &length);
- assert_str_eq ("%54ES%54%00", (char *)encoded);
- assert_num_eq (11, length);
+ p11_url_encode (input, input + 5, "ES", &buf);
+ assert (p11_buffer_ok (&buf));
+ assert_str_eq ("%54ES%54%00", (char *)buf.data);
+ assert_num_eq (11, buf.len);
- free (encoded);
+ p11_buffer_uninit (&buf);
}
int