Migrate certificates, icons, logs to XDG dirs
[pidgin-git.git] / libpurple / tests / test_md4.c
blob52be1302bb7fa2e81a149c9673a82b93eee7adcc
1 #include <glib.h>
3 #include <purple.h>
5 #include "ciphers/md4hash.h"
7 static void
8 test_md4hash(gchar *data, gchar *digest) {
9 PurpleHash *hash = NULL;
10 gchar cdigest[33];
11 gboolean ret = FALSE;
13 hash = purple_md4_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_md4hash_empty_string(void) {
25 test_md4hash("",
26 "31d6cfe0d16ae931b73c59d7e0c089c0");
29 static void
30 test_md4hash_a(void) {
31 test_md4hash("a",
32 "bde52cb31de33e46245e05fbdbd6fb24");
35 static void
36 test_md4hash_abc(void) {
37 test_md4hash("abc",
38 "a448017aaf21d8525fc10ae87aa6729d");
41 static void
42 test_md4hash_message_digest(void) {
43 test_md4hash("message digest",
44 "d9130a8164549fe818874806e1c7014b");
47 static void
48 test_md4hash_a_to_z(void) {
49 test_md4hash("abcdefghijklmnopqrstuvwxyz",
50 "d79e1c308aa5bbcdeea8ed63df412da9");
53 static void
54 test_md4hash_A_to_Z_a_to_z_0_to_9(void) {
55 test_md4hash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
56 "043f8582f241db351ce627e153e7f0e4");
59 static void
60 test_md4hash_1_to_0_eight_times(void) {
61 test_md4hash("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
62 "e33b4ddc9c38f2199c3e7b164fcc0536");
65 gint
66 main(gint argc, gchar **argv) {
67 g_test_init(&argc, &argv, NULL);
69 g_test_add_func("/hash/md4/empty-string",
70 test_md4hash_empty_string);
71 g_test_add_func("/hash/md4/a",
72 test_md4hash_a);
73 g_test_add_func("/hash/md4/abc",
74 test_md4hash_abc);
75 g_test_add_func("/hash/md4/message digest",
76 test_md4hash_message_digest);
77 g_test_add_func("/hash/md4/a to z",
78 test_md4hash_a_to_z);
79 g_test_add_func("/hash/md4/A to Z, a to z, 0 to 9" ,
80 test_md4hash_A_to_Z_a_to_z_0_to_9);
81 g_test_add_func("/hash/md4/1 to 0 eight times",
82 test_md4hash_1_to_0_eight_times);
84 return g_test_run();