source: tests/check_md5.c @ 0b9daac

Last change on this file since 0b9daac was 0b9daac, checked in by dequis <dx@…>, at 2015-02-20T23:16:08Z

Reorganize include files to avoid conflicts with other libs

  • Change all header includes to be relative to the project root
  • Remove -I${includedir} from bitlbee.pc Cflags
  • Install lib and protocols headers to their own directories. So now it is:

/usr/include/bitlbee/*.h
/usr/include/bitlbee/lib/*.h
/usr/include/bitlbee/protocols/*.h

This breaks backwards compatibility of third party plugins, but now
they don't have to do ambiguous includes like #include <proxy.h>

This also fixes trac ticket 1170 - conflicts when libproxy and liboauth
are installed at the same time bitlbee is built, which the macports
project ran into several times.

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[6a90967]1#include <stdlib.h>
2#include <glib.h>
3#include <gmodule.h>
4#include <check.h>
5#include <string.h>
6#include <stdio.h>
[0b9daac]7#include "lib/md5.h"
[6a90967]8
9/* From RFC 1321 */
10struct md5_test {
11        const char *str;
12        md5_byte_t expected[16];
13} tests[] = {
[5ebff60]14        { "",
15          { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } },
[6a90967]16        { "a",
[5ebff60]17          { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } },
18        { "abc",
19          { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } },
20        { "message digest",
21          { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } },
22        { "abcdefghijklmnopqrstuvwxyz",
23          { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } },
[6a90967]24        { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
[5ebff60]25          { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } },
26        { "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
27          { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } },
[6a90967]28
29        { NULL },
30};
31
32static void check_sums(int l)
33{
34        int i;
[5ebff60]35
[6a90967]36        for (i = 0; tests[i].str; i++) {
37                md5_byte_t sum[16];
[5ebff60]38                tcase_fn_start(tests[i].str, __FILE__, __LINE__);
[6a90967]39                md5_state_t state;
40
41                md5_init(&state);
[5ebff60]42                md5_append(&state, (const md5_byte_t *) tests[i].str, strlen(tests[i].str));
[6a90967]43                md5_finish(&state, sum);
44
45                fail_if(memcmp(tests[i].expected, sum, 16) != 0, "%s failed", tests[i].str);
46        }
47}
48
[5ebff60]49Suite *md5_suite(void)
[6a90967]50{
51        Suite *s = suite_create("MD5");
52        TCase *tc_core = tcase_create("Core");
[5ebff60]53
54        suite_add_tcase(s, tc_core);
55        tcase_add_test(tc_core, check_sums);
[6a90967]56        return s;
57}
Note: See TracBrowser for help on using the repository browser.