2011-11-04 16:56:25 +11:00
|
|
|
|
2013-07-13 14:40:13 +10:00
|
|
|
#include "hash/adler.hpp"
|
|
|
|
#include "hash/bsdsum.hpp"
|
2011-11-04 16:56:25 +11:00
|
|
|
#include "types.hpp"
|
2012-05-26 18:01:54 +10:00
|
|
|
#include "debug.hpp"
|
2011-11-04 16:56:25 +11:00
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
static const char *ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
uint32_t adler;
|
|
|
|
uint16_t bsd;
|
|
|
|
|
|
|
|
const char *data;
|
|
|
|
size_t size;
|
|
|
|
} TESTS[] = {
|
|
|
|
{ 0xDF5B150C, 0x52FB, ALPHABET, strlen (ALPHABET) }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int, char**) {
|
|
|
|
for (unsigned i = 0; i < elems (TESTS); ++i) {
|
2012-05-11 12:34:21 +10:00
|
|
|
CHECK_EQ (TESTS[i].adler, adler32 (TESTS[i].data, TESTS[i].size));
|
|
|
|
CHECK_EQ (TESTS[i].bsd, bsdsum (TESTS[i].data, TESTS[i].size));
|
2011-11-04 16:56:25 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|