Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76104 - in trunk: boost libs/crc/test
From: dwalker07_at_[hidden]
Date: 2011-12-22 07:07:24

Author: dlwalker
Date: 2011-12-22 07:07:23 EST (Thu, 22 Dec 2011)
New Revision: 76104

Added new example CRC computer types to correct the mistaken ones; added test cases for those new types.
Text files modified:
   trunk/boost/crc.hpp | 16 ++++++++++++++--
   trunk/libs/crc/test/crc_test2.cpp | 18 +++++++++++++-----
   2 files changed, 27 insertions(+), 7 deletions(-)

Modified: trunk/boost/crc.hpp
--- trunk/boost/crc.hpp (original)
+++ trunk/boost/crc.hpp 2011-12-22 07:07:23 EST (Thu, 22 Dec 2011)
@@ -20,6 +20,11 @@
     Contains the declarations (and definitions) of various kinds of CRC
     computation functions, function object types, and encapsulated policy types.
+ \warning The sample CRC-computer types were just checked against the
+ <a href="">Catalogue of
+ parametrised CRC algorithms</a>. New type aliases were added where I got
+ a standard wrong. However, the mistaken <code>typedef</code>s are still
+ there for backwards compatibility.
     \note There are references to the <i>Rocksoft&trade; Model CRC
       Algorithm</i>, as described within \"<cite>A Painless Guide to CRC Error
       Detection Algorithms</cite>,\" linked from \"<a
@@ -116,11 +121,18 @@
 //! Computation type for ARC|CRC-16|CRC-IBM|CRC-16/ARC|CRC-16/LHA standard
 typedef crc_optimal<16, 0x8005, 0, 0, true, true> crc_16_type;
-//! Computation type for an incorrectly marked standard(!!)
-typedef crc_optimal<16, 0x1021, 0xFFFF, 0, false, false> crc_ccitt_type;
+//! Computation type for CRC-16/CCITT-FALSE standard
+typedef crc_optimal<16, 0x1021, 0xFFFF, 0, false, false> crc_ccitt_false_t;
+//! Computation type for the CRC mistakenly called the CCITT standard
+typedef crc_ccitt_false_t crc_ccitt_type;
+//! Computation type for the actual
+typedef crc_optimal<16, 0x1021, 0, 0, true, true> crc_ccitt_true_t;
 //! Computation type that I mistakenly called the XMODEM standard; it inverts
 //! both reflection parameters and reflects the truncated divisor (Don't use?!)
 typedef crc_optimal<16, 0x8408, 0, 0, true, true> crc_xmodem_type;
+//! Computation type for the actual XMODEM|ZMODEM|CRC-16/ACORN standard
+typedef crc_optimal<16, 0x1021, 0, 0, false, false> crc_xmodem_t;
 //! Computation type for CRC-32|CRC-32/ADCCP|PKZIP standard
 typedef crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, true>

Modified: trunk/libs/crc/test/crc_test2.cpp
--- trunk/libs/crc/test/crc_test2.cpp (original)
+++ trunk/libs/crc/test/crc_test2.cpp 2011-12-22 07:07:23 EST (Thu, 22 Dec 2011)
@@ -47,7 +47,9 @@
 std::size_t const std_data_len = sizeof( std_data ) / sizeof( std_data[0] );
 // Checksums of the standard test data for common configurations
-boost::uint16_t const std_crc_ccitt_result = 0x29B1u;
+boost::uint16_t const std_crc_ccitt_false_result = 0x29B1u;
+boost::uint16_t const std_crc_ccitt_true_result = 0x2189u;
+boost::uint16_t const std_crc_xmodem_result = 0x31C3u;
 boost::uint16_t const std_crc_16_result = 0xBB3Du;
 boost::uint32_t const std_crc_32_result = 0xCBF43926ul;
@@ -187,12 +189,17 @@
 typedef my_crc_test_traits<16u, 0x8005u, 0u, true, true, 0u, std_crc_16_result>
 typedef my_crc_test_traits<16u, 0x1021u, 0xFFFFu, false, false, 0u,
- std_crc_ccitt_result> my_crc_ccitt_traits;
+ std_crc_ccitt_false_result> my_crc_ccitt_false_traits;
+typedef my_crc_test_traits<16u, 0x1021u, 0u, true, true, 0u,
+ std_crc_ccitt_true_result> my_crc_ccitt_true_traits;
+typedef my_crc_test_traits<16u, 0x1021u, 0u, false, false, 0u,
+ std_crc_xmodem_result> my_crc_xmodem_traits;
 typedef my_crc_test_traits<32u, 0x04C11DB7ul, 0xFFFFFFFFul, true, true,
  0xFFFFFFFFul, std_crc_32_result> my_crc_32_traits;
-typedef boost::mpl::list<my_crc_16_traits, my_crc_ccitt_traits,
- my_crc_32_traits> crc_test_policies;
+typedef boost::mpl::list<my_crc_16_traits, my_crc_ccitt_false_traits,
+ my_crc_ccitt_true_traits, my_crc_xmodem_traits, my_crc_32_traits>
+ crc_test_policies;
 // Need to test when ReflectInputBytes and ReflectOutputRemainder differ
 // (Grabbed from table at <>.)
@@ -201,7 +208,8 @@
 typedef my_crc_test_traits<12u, 0x80Fu, 0u, false, true, 0u, 0xDAFu>
-typedef boost::mpl::list<my_crc_16_traits, my_crc_ccitt_traits, my_crc_32_traits
+typedef boost::mpl::list<my_crc_16_traits, my_crc_ccitt_false_traits
+ , my_crc_ccitt_true_traits, my_crc_xmodem_traits, my_crc_32_traits
  , my_crc_6_darc_traits

Boost-Commit list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at