added check for CRC with example from README

This commit is contained in:
Ahmet Inan 2018-07-29 08:01:56 +02:00
commit 2c9248f6f8
2 changed files with 22 additions and 2 deletions

View file

@ -5,9 +5,10 @@ CXX = clang++ -stdlib=libc++
.PHONY: clean test
test: kahan
test: kahan crc
./kahan
./crc
clean:
rm -f kahan
rm -f kahan crc

19
tests/crc.cc Normal file
View file

@ -0,0 +1,19 @@
/*
Test for the Cyclic redundancy check
Copyright 2018 Ahmet Inan <inan@aicodix.de>
*/
#include <cassert>
#include <iostream>
#include "crc.hh"
int main()
{
DSP::CRC<uint32_t> crc(0xEDB88320, 0xFFFFFFFF);
for (uint8_t c: std::string("Hello World!")) crc(c);
assert(!crc(uint32_t(~0x1C291CA3)));
std::cerr << "Cyclic redundancy check test passed!" << std::endl;
return 0;
}