summaryrefslogtreecommitdiff
path: root/ucoolib/utils/test
diff options
context:
space:
mode:
authorNicolas Schodet2013-05-01 12:08:01 +0200
committerNicolas Schodet2019-10-07 00:01:14 +0200
commit996aca5612de78239a01f52bc79d75a5e403d5c7 (patch)
tree41da65ea09c9c601c408c177423dc9ac090e5062 /ucoolib/utils/test
parent317531104f0ab32495dd2c540b8dcefdd71efa48 (diff)
ucoolib/utils/crc: add CRC32
Diffstat (limited to 'ucoolib/utils/test')
-rw-r--r--ucoolib/utils/test/test_crc.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/ucoolib/utils/test/test_crc.cc b/ucoolib/utils/test/test_crc.cc
index 19d6ca8..77c4c1a 100644
--- a/ucoolib/utils/test/test_crc.cc
+++ b/ucoolib/utils/test/test_crc.cc
@@ -25,16 +25,25 @@
#include "ucoolib/arch/arch.hh"
#include "ucoolib/base/test/test.hh"
+#include <cstring>
+
int
main (int argc, const char **argv)
{
ucoo::arch_init (argc, argv);
ucoo::TestSuite tsuite ("crc");
{
- ucoo::Test test (tsuite, "test vector");
+ ucoo::Test test (tsuite, "crc8 test vector");
static const uint8_t test_vector[] = { 0x02, 0x1c, 0xb8, 0x01, 0, 0, 0, 0xa2 };
if (ucoo::crc8_compute (test_vector, lengthof (test_vector)) != 0)
test.fail ();
}
+ {
+ ucoo::Test test (tsuite, "crc32 test vector");
+ const char *check_str = "123456789";
+ if (ucoo::crc32_compute ((const uint8_t *) check_str,
+ std::strlen (check_str)) != 0xCBF43926)
+ test.fail ();
+ }
return tsuite.report () ? 0 : 1;
}