diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-07-16 20:47:28 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-07-16 20:48:41 -0400 |
commit | b4878dec3a777f4a01c1d16ca85a6fe52b1152d6 (patch) | |
tree | 42fc8abe45e25bcc93e68e9793fc795eec886746 | |
parent | 183ed8a3f8e663c149b2a48add3b60eff3a1a71e (diff) | |
download | glib-b4878dec3a777f4a01c1d16ca85a6fe52b1152d6.tar.gz |
Add a test for g_hmac_for_bytes
-rw-r--r-- | glib/tests/hmac.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/glib/tests/hmac.c b/glib/tests/hmac.c index 269c3e460..6b6076d76 100644 --- a/glib/tests/hmac.c +++ b/glib/tests/hmac.c @@ -417,6 +417,28 @@ test_hmac_for_string (void) g_free (string); } +static void +test_hmac_for_bytes (void) +{ + gchar *string; + GHmac *hmac; + GBytes *key, *data; + + key = g_bytes_new ("aaa", 3); + data = g_bytes_new ("bcdef", 5); + + string = g_compute_hmac_for_bytes (G_CHECKSUM_SHA1, key, data); + + hmac = g_hmac_new (G_CHECKSUM_SHA1, (guchar*)"aaa", 3); + g_hmac_update (hmac, (guchar*)"bcdef", 5); + g_assert_cmpstr (string, ==, g_hmac_get_string (hmac)); + g_hmac_unref (hmac); + g_free (string); + + g_bytes_unref (key); + g_bytes_unref (data); +} + int main (int argc, char **argv) @@ -460,6 +482,7 @@ main (int argc, g_test_add_func ("/hmac/copy", test_hmac_copy); g_test_add_func ("/hmac/for-data", test_hmac_for_data); g_test_add_func ("/hmac/for-string", test_hmac_for_string); + g_test_add_func ("/hmac/for-bytes", test_hmac_for_bytes); return g_test_run (); } |