[glib] Add a test for g_hmac_for_bytes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add a test for g_hmac_for_bytes
- Date: Sun, 17 Jul 2016 00:49:00 +0000 (UTC)
commit b4878dec3a777f4a01c1d16ca85a6fe52b1152d6
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 16 20:47:28 2016 -0400
Add a test for g_hmac_for_bytes
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 269c3e4..6b6076d 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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]