5 #include "ciphers/md5hash.h"
8 test_md5hash(gchar
*data
, gchar
*digest
) {
9 PurpleHash
*hash
= NULL
;
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
));
20 g_assert_cmpstr(digest
, ==, cdigest
);
24 test_md5hash_empty_string(void) {
26 "d41d8cd98f00b204e9800998ecf8427e");
30 test_md5hash_a(void) {
32 "0cc175b9c0f1b6a831c399e269772661");
36 test_md5hash_abc(void) {
38 "900150983cd24fb0d6963f7d28e17f72");
42 test_md5hash_message_digest(void) {
43 test_md5hash("message digest",
44 "f96b697d7cb7938d525a2f31aaf161d0");
48 test_md5hash_a_to_z(void) {
49 test_md5hash("abcdefghijklmnopqrstuvwxyz",
50 "c3fcd3d76192e4007dfb496cca67e13b");
54 test_md5hash_A_to_Z_a_to_z_0_to_9(void) {
55 test_md5hash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
56 "d174ab98d277d9f5a5611c2c9f419d9f");
60 test_md5hash_1_to_0_eight_times(void) {
61 test_md5hash("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
62 "57edf4a22be3c955ac49da2e2107b67a");
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",
73 g_test_add_func("/hash/md5/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",
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
);