summaryrefslogtreecommitdiff
path: root/test.c
blob: 6a8bcd7d6121d0fca90f6f9560804b19024fc2d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>

#include "hash.h"

void test_pearson(const void *d, size_t len)
{
	unsigned char h = pearson(d, len);
	uint64_t h64 = pearson_64(d, len);
	printf("pearson:	%02x\n", h);
	printf("pearson_64:	%016lx\n", h64);
}

void test_fnv(const void *d, size_t len)
{
	uint64_t h = fnv1_64(d, len);
	printf("fnv1_64:	%016lx\n", h);
	h = fnv1a_64(d, len);
	printf("fnv1a_64:	%016lx\n", h);
}

int main(int argc, char **argv)
{
	const char *d;
	size_t len;
	if (argc < 2) {
		fprintf(stderr, "usage: %s input\n", argv[0]);
		exit(1);
	}
	d = argv[1];
	len = strlen(d);
	test_pearson(d, len);
	test_fnv(d, len);
}