5 #include "ciphers/sha1hash.h"
8 test_sha1hash(gchar
*data
, gchar
*digest
) {
9 PurpleHash
*hash
= NULL
;
13 hash
= purple_sha1_hash_new();
16 purple_hash_append(hash
, (guchar
*)data
, strlen(data
));
21 memset(buff
, 'a', 1000);
23 for(j
= 0; j
< 1000; j
++)
24 purple_hash_append(hash
, buff
, 1000);
27 ret
= purple_hash_digest_to_str(hash
, cdigest
, sizeof(cdigest
));
30 g_assert_cmpstr(digest
, ==, cdigest
);
34 test_sha1hash_empty_string(void) {
36 "da39a3ee5e6b4b0d3255bfef95601890afd80709");
40 test_sha1hash_a(void) {
42 "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8");
46 test_sha1hash_abc(void) {
48 "a9993e364706816aba3e25717850c26c9cd0d89d");
52 test_sha1hash_abcd_gibberish(void) {
53 test_sha1hash("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
54 "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
58 test_sha1hash_1000_as_1000_times(void) {
60 "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
64 main(gint argc
, gchar
**argv
) {
65 g_test_init(&argc
, &argv
, NULL
);
67 g_test_add_func("/hash/sha1/empty-string",
68 test_sha1hash_empty_string
);
69 g_test_add_func("/hash/sha1/a",
71 g_test_add_func("/hash/sha1/abc",
73 g_test_add_func("/hash/sha1/abcd_gibberish",
74 test_sha1hash_abcd_gibberish
);
75 g_test_add_func("/hash/sha1/1000 a's 1000 times",
76 test_sha1hash_1000_as_1000_times
);