libcruft-util/test/checksum.cpp

34 lines
688 B
C++

#include "adler.hpp"
#include "bsdsum.hpp"
#include "types.hpp"
#include "debug.hpp"
#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) {
CHECK_EQ (TESTS[i].adler, adler32 (TESTS[i].data, TESTS[i].size));
CHECK_EQ (TESTS[i].bsd, bsdsum (TESTS[i].data, TESTS[i].size));
}
return EXIT_SUCCESS;
}