15 SECTION(
"'3 x A1' in a loop") {
19 SECTION(
"'3 x A1' in one chunk") {
20 static constexpr std::array<uint8_t, 3> buf = { 0xA1, 0xA1, 0xA1 };
24 SECTION(
"'3 x A1' via init") {
25 crc.
init({0xA1, 0xA1, 0xA1});
32 SECTION(
"'123456789' in a loop") {
33 for (
char c : {
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'}) crc.
update(c);
36 SECTION(
"'123456789' in one chunk") {
37 static constexpr const char*
const digits =
"123456789";
38 crc.
update(std::span{
reinterpret_cast<const uint8_t*
>(digits), 9});
42 SECTION(
"512 bytes") {
43 std::array<uint8_t, 512> buf;
44 for (
auto i :
xrange(512)) buf[i] = narrow_cast<uint8_t>(i & 255);
45 SECTION(
"in a loop") {
46 for (
char c : buf) crc.
update(c);
49 SECTION(
"in one chunk") {
58 SECTION(
"'11' in a loop") {
59 for (uint8_t c : {uint8_t(0x11)}) crc.
update(c);
62 SECTION(
"'11' in one chunk") {
63 static constexpr std::array<uint8_t, 1> buf = {0x11};
67 SECTION(
"'11' via init") {
72 SECTION(
"'11 22' in a loop") {
73 for (uint8_t c : {uint8_t(0x11), uint8_t(0x22)}) crc.
update(c);
76 SECTION(
"'11 22' in one chunk") {
77 static constexpr std::array<uint8_t, 2> buf = {0x11, 0x22};
81 SECTION(
"'11 22' via init") {
82 crc.
init({0x11, 0x22});
86 SECTION(
"'11 22 33' in a loop") {
87 for (uint8_t c : {uint8_t(0x11), uint8_t(0x22), uint8_t(0x33)}) crc.
update(c);
90 SECTION(
"'11 22 33' in one chunk") {
91 static constexpr std::array<uint8_t, 3> buf = {0x11, 0x22, 0x33};
95 SECTION(
"'11 22 33' via init") {
96 crc.
init({0x11, 0x22, 0x33});
100 SECTION(
"'11 22 33 44' in a loop") {
101 for (uint8_t c : {uint8_t(0x11), uint8_t(0x22), uint8_t(0x33), uint8_t(0x44)}) crc.
update(c);
104 SECTION(
"'11 22 33 44' in one chunk") {
105 static constexpr std::array<uint8_t, 4> buf = {0x11, 0x22, 0x33, 0x44};
109 SECTION(
"'11 22 33 44' via init") {
110 crc.
init({0x11, 0x22, 0x33, 0x44});
124 crc.
init({0xA1, 0xA1, 0xA1});
This class calculates CRC numbers for the polygon x^16 + x^12 + x^5 + 1.
constexpr void update(uint8_t value)
Update CRC with one byte.
constexpr uint16_t getValue() const
Get current CRC value.
constexpr void init(uint16_t initialCRC)
(Re)initialize the current value
This file implemented 3 utility functions:
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.
constexpr auto xrange(T e)