1// Copyright 2023 Peter Dimov.
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt)
4
5#include <boost/crc.hpp>
6#include <boost/core/lightweight_test.hpp>
7#include <cstring>
8
9int main()
10{
11 char const* data = "123456789";
12
13 {
14 // CRC-14/DARC
15
16 boost::crc_basic<14> c1( 0x805, 0x0000, 0x0000, true, true );
17 boost::crc_optimal<14, 0x805, 0x0000, 0x0000, true, true> c2;
18
19 c1.process_bytes( buffer: data, byte_count: std::strlen( s: data ) );
20 c2.process_bytes( buffer: data, byte_count: std::strlen( s: data ) );
21
22 BOOST_TEST_EQ( c1.checksum(), c2.checksum() );
23 }
24
25 {
26 // CRC-24/BLE
27
28 boost::crc_basic<24> c1( 0x00065B, 0x555555, 0x000000, true, true );
29 boost::crc_optimal<24, 0x00065B, 0x555555, 0x000000, true, true> c2;
30
31 c1.process_bytes( buffer: data, byte_count: std::strlen( s: data ) );
32 c2.process_bytes( buffer: data, byte_count: std::strlen( s: data ) );
33
34 BOOST_TEST_EQ( c1.checksum(), c2.checksum() );
35 }
36
37 return boost::report_errors();
38}
39

source code of boost/libs/crc/test/pr15_test.cpp