Fix some functions descriptions
[pidgin-git.git] / libpurple / tests / test_md5.c
blob8765c3195d60622e1342fd6eb39aaec71796ee6f
1 #include <glib.h>
3 #include <purple.h>
5 #include "ciphers/md5hash.h"
7 static void
8 test_md5hash(gchar *data, gchar *digest) {
9 PurpleHash *hash = NULL;
10 gchar cdigest[33];
11 gboolean ret = FALSE;
13 hash = purple_md5_hash_new();
15 purple_hash_append(hash, (guchar *)data, strlen(data));
17 ret = purple_hash_digest_to_str(hash, cdigest, sizeof(cdigest));
19 g_assert(ret);
20 g_assert_cmpstr(digest, ==, cdigest);
23 static void
24 test_md5hash_empty_string(void) {
25 test_md5hash("",
26 "d41d8cd98f00b204e9800998ecf8427e");
29 static void
30 test_md5hash_a(void) {
31 test_md5hash("a",
32 "0cc175b9c0f1b6a831c399e269772661");
35 static void
36 test_md5hash_abc(void) {
37 test_md5hash("abc",
38 "900150983cd24fb0d6963f7d28e17f72");
41 static void
42 test_md5hash_message_digest(void) {
43 test_md5hash("message digest",
44 "f96b697d7cb7938d525a2f31aaf161d0");
47 static void
48 test_md5hash_a_to_z(void) {
49 test_md5hash("abcdefghijklmnopqrstuvwxyz",
50 "c3fcd3d76192e4007dfb496cca67e13b");
53 static void
54 test_md5hash_A_to_Z_a_to_z_0_to_9(void) {
55 test_md5hash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
56 "d174ab98d277d9f5a5611c2c9f419d9f");
59 static void
60 test_md5hash_1_to_0_eight_times(void) {
61 test_md5hash("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
62 "57edf4a22be3c955ac49da2e2107b67a");
65 gint
66 main(gint argc, gchar **argv) {
67 g_test_init(&argc, &argv, NULL);
69 g_test_add_func("/hash/md5/empty-string",
70 test_md5hash_empty_string);
71 g_test_add_func("/hash/md5/a",
72 test_md5hash_a);
73 g_test_add_func("/hash/md5/abc",
74 test_md5hash_abc);
75 g_test_add_func("/hash/md5/message digest",
76 test_md5hash_message_digest);
77 g_test_add_func("/hash/md5/a to z",
78 test_md5hash_a_to_z);
79 g_test_add_func("/hash/md5/A to Z, a to z, 0 to 9" ,
80 test_md5hash_A_to_Z_a_to_z_0_to_9);
81 g_test_add_func("/hash/md5/1 to 0 eight times",
82 test_md5hash_1_to_0_eight_times);
84 return g_test_run();