From: Nick Mathewson Date: Mon, 17 Sep 2012 14:34:08 +0000 (-0400) Subject: Add unit test for crypto_pk_cmp_keys and NULL X-Git-Tag: tor-0.2.4.3-alpha~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=757b3b259eba27881a8b5616ba45d42798c1ade8;p=thirdparty%2Ftor.git Add unit test for crypto_pk_cmp_keys and NULL --- diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c index 7f4347a41c..fd983de002 100644 --- a/src/test/test_crypto.c +++ b/src/test/test_crypto.c @@ -427,6 +427,11 @@ test_crypto_pk(void) test_assert(! crypto_pk_read_public_key_from_string(pk2, encoded, size)); test_eq(0, crypto_pk_cmp_keys(pk1, pk2)); + /* comparison between keys and NULL */ + tt_int_op(crypto_pk_cmp_keys(NULL, pk1), <, 0); + tt_int_op(crypto_pk_cmp_keys(NULL, NULL), ==, 0); + tt_int_op(crypto_pk_cmp_keys(pk1, NULL), >, 0); + test_eq(128, crypto_pk_keysize(pk1)); test_eq(1024, crypto_pk_num_bits(pk1)); test_eq(128, crypto_pk_keysize(pk2));