diff options
author | Stef Walter <stefw@gnome.org> | 2013-05-21 17:33:22 +0200 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2013-05-27 10:46:11 +0200 |
commit | 56fec770071713bf800e7e9f3905973703105ec5 (patch) | |
tree | 7b1cb7119299d966027f2c5c754a78d72a143bcb /common/tests | |
parent | cb8f2e3a04d9365121ffea0d76d8b3d47e2cc1ec (diff) |
pem: Write PEM data directly to a buffer
Diffstat (limited to 'common/tests')
-rw-r--r-- | common/tests/test-pem.c | 21 |
1 files changed, 12 insertions, 9 deletions
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); } } |