mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
added check for CRC with example from README
This commit is contained in:
parent
5eec31a61f
commit
2c9248f6f8
2 changed files with 22 additions and 2 deletions
|
|
@ -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
19
tests/crc.cc
Normal 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;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue