From 2c9248f6f87bfc7a30258bf9e153e7d6d628309e Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sun, 29 Jul 2018 08:01:56 +0200 Subject: [PATCH] added check for CRC with example from README --- tests/Makefile | 5 +++-- tests/crc.cc | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/crc.cc diff --git a/tests/Makefile b/tests/Makefile index 47a7852..85193d0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -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 diff --git a/tests/crc.cc b/tests/crc.cc new file mode 100644 index 0000000..6834f97 --- /dev/null +++ b/tests/crc.cc @@ -0,0 +1,19 @@ +/* +Test for the Cyclic redundancy check + +Copyright 2018 Ahmet Inan +*/ + +#include +#include +#include "crc.hh" + +int main() +{ + DSP::CRC 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; +} +