From 56fec770071713bf800e7e9f3905973703105ec5 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 21 May 2013 17:33:22 +0200 Subject: pem: Write PEM data directly to a buffer --- common/tests/test-pem.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'common/tests/test-pem.c') diff --git a/common/tests/test-pem.c b/common/tests/test-pem.c index 7dd7fb2..0c7d60a 100644 --- a/common/tests/test-pem.c +++ b/common/tests/test-pem.c @@ -306,24 +306,27 @@ static void test_pem_write (void) { WriteFixture *fixture; - size_t length; - char *output; + p11_buffer buf; unsigned int count; int i; for (i = 0; write_fixtures[i].input != NULL; i++) { fixture = write_fixtures + i; - output = p11_pem_write ((unsigned char *)fixture->input, - fixture->length, - fixture->type, &length); - assert_str_eq (fixture->output, output); - assert_num_eq (strlen (fixture->output), length); + if (!p11_buffer_init_null (&buf, 0)) + assert_not_reached (); + + if (!p11_pem_write ((unsigned char *)fixture->input, + fixture->length, + fixture->type, &buf)) + assert_not_reached (); + assert_str_eq (fixture->output, buf.data); + assert_num_eq (strlen (fixture->output), buf.len); - count = p11_pem_parse (output, length, on_parse_written, fixture); + count = p11_pem_parse (buf.data, buf.len, on_parse_written, fixture); assert_num_eq (1, count); - free (output); + p11_buffer_uninit (&buf); } } -- cgit v1.1