Boost logo

Boost-Commit :

From: dwalker07_at_[hidden]
Date: 2008-08-31 19:48:54


Author: dlwalker
Date: 2008-08-31 19:48:54 EDT (Sun, 31 Aug 2008)
New Revision: 48508
URL: http://svn.boost.org/trac/boost/changeset/48508

Log:
Added member function to adler32_computer for restarting from a given checksum; corrected cycle length for no-queuing case from 1 to 0; changed some (in)equality-checking test macro calls to use the specific macros for testing (in)equality, if the macro wasn't testing the (in)equality operators
Text files modified:
   sandbox/md5/boost/coding/adler32.hpp | 18 ++++++++++++++
   sandbox/md5/libs/coding/test/adler32_test.cpp | 47 ++++++++++++++++++++++-----------------
   2 files changed, 43 insertions(+), 22 deletions(-)

Modified: sandbox/md5/boost/coding/adler32.hpp
==============================================================================
--- sandbox/md5/boost/coding/adler32.hpp (original)
+++ sandbox/md5/boost/coding/adler32.hpp 2008-08-31 19:48:54 EDT (Sun, 31 Aug 2008)
@@ -140,7 +140,7 @@
     // and the initial threshold goes up to 380,368,696 with the reset threshold
     // being 380,368,439.
 #else
- typedef mpl::size_t<1u> initial_threshold, reset_threshold; // no queuing
+ typedef mpl::size_t<0u> initial_threshold, reset_threshold; // no queuing
 #endif
 
     // Member data
@@ -458,6 +458,8 @@
     // Assignment
     //! Sets state back to initial conditions
     void reset();
+ //! Sets state to restart from a given checksum
+ void configure( sum_type checksum );
     //! Changes the current state to a copy of another object's
     void assign( self_type const &c );
 
@@ -527,6 +529,20 @@
  */
 inline void adler32_computer::reset() { this->context() = adler32_context(); }
 
+/** Changes an object to be like it was (re)started from a given checksum.
+
+ \pre <code>(<var>checksum</var> &amp; 0xFFFF) &lt; 65,521 &amp;&amp;
+ (<var>checksum</var> &gt;&gt; 16) &lt; 65,521</code>. (This implies
+ that \p checksum is less than 2<sup>32</sup>.)
+
+ \param checksum The checksum of the conditions to restart from.
+
+ \post <code>#augmented_byte_sum() == <var>checksum</var> &amp; FFFF</code>.
+ \post <code>#sum_of_byte_sums() == <var>checksum</var> &gt;&gt; 16</code>.
+ */
+inline void adler32_computer::configure( sum_type checksum )
+{ this->context() = adler32_context( checksum ); }
+
 /** Changes an object to be like the given object. Only the computation
     elements are copied; no function object proxies are reseated.
 

Modified: sandbox/md5/libs/coding/test/adler32_test.cpp
==============================================================================
--- sandbox/md5/libs/coding/test/adler32_test.cpp (original)
+++ sandbox/md5/libs/coding/test/adler32_test.cpp 2008-08-31 19:48:54 EDT (Sun, 31 Aug 2008)
@@ -260,33 +260,38 @@
     // Copy constructor
     adler32_computer c2, c3( c1 );
 
- BOOST_CHECK( c3 == c1 );
- BOOST_CHECK( c3 != c2 );
+ BOOST_CHECK_EQUAL( c3, c1 );
+ BOOST_CHECK_NE( c3, c2 );
 
     // Assignment operator
     c3 = c2;
- BOOST_CHECK( c3 == c2 );
- BOOST_CHECK( c3 != c1 );
+ BOOST_CHECK_EQUAL( c3, c2 );
+ BOOST_CHECK_NE( c3, c1 );
 
     // Assignment method
     c3.assign( c1 );
- BOOST_CHECK( c3 == c1 );
- BOOST_CHECK( c3 != c2 );
+ BOOST_CHECK_EQUAL( c3, c1 );
+ BOOST_CHECK_NE( c3, c2 );
 
     // Reset to default
     c3.reset();
- BOOST_CHECK( c3 == c2 );
- BOOST_CHECK( c3 != c1 );
+ BOOST_CHECK_EQUAL( c3, c2 );
+ BOOST_CHECK_NE( c3, c1 );
 
     // Swap
     c3.swap( c1 );
- BOOST_CHECK( c3 != c2 );
- BOOST_CHECK( c1 == c2 );
+ BOOST_CHECK_NE( c3, c2 );
+ BOOST_CHECK_EQUAL( c1, c2 );
 
     // Free-function swap
     boost::coding::swap( c1, c3 );
- BOOST_CHECK( c3 == c2 );
- BOOST_CHECK( c1 != c2 );
+ BOOST_CHECK_EQUAL( c3, c2 );
+ BOOST_CHECK_NE( c1, c2 );
+
+ // Set to new checksum
+ c3.configure( c1.checksum() );
+ BOOST_CHECK_EQUAL( c3, c1 );
+ BOOST_CHECK_NE( c3, c2 );
 }
 
 // Threshold(s) test
@@ -338,28 +343,28 @@
     c1.process_bytes( values, 3 );
     BOOST_FOREACH( unsigned char b, values )
         c2.bytes( b );
- BOOST_CHECK( c1 == c2 );
+ BOOST_CHECK_EQUAL( c1, c2 );
 
     // Use with algorithms
     adler32_computer c3, c4;
 
- BOOST_CHECK( c3 == c4 );
+ BOOST_CHECK_EQUAL( c3, c4 );
     for_each( values, values + 3, c3.bytes );
- BOOST_CHECK( c3 == c4 );
- BOOST_CHECK( c3 != c2 );
+ BOOST_CHECK_EQUAL( c3, c4 );
+ BOOST_CHECK_NE( c3, c2 );
     c3.bytes = for_each( values, values + 3, c3.bytes );
- BOOST_CHECK( c3 != c4 );
- BOOST_CHECK( c3 == c2 );
+ BOOST_CHECK_NE( c3, c4 );
+ BOOST_CHECK_EQUAL( c3, c2 );
 
     // Assignment
     c4.bytes = c3.bytes;
- BOOST_CHECK( c4 == c3 );
+ BOOST_CHECK_EQUAL( c4, c3 );
 
     // Re-do
     c4.reset();
- BOOST_CHECK( c4 != c3 );
+ BOOST_CHECK_NE( c4, c3 );
     c4.bytes = for_each( values, values + 3, c4.bytes );
- BOOST_CHECK( c4 == c3 );
+ BOOST_CHECK_EQUAL( c4, c3 );
 }
 
 // Archiving test


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk