Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80904 - in sandbox/SOC/2011/checks: boost/checks libs/checks/doc libs/checks/doc/doxygen libs/checks/test
From: pierre.talbot.6114_at_[hidden]
Date: 2012-10-08 00:53:27


Author: trademark
Date: 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
New Revision: 80904
URL: http://svn.boost.org/trac/boost/changeset/80904

Log:
Add helper functions (compute_...(string) and check_...(string)) to simplify the check for basic case. Update the tests and add some tests cases.
Added:
   sandbox/SOC/2011/checks/boost/checks/precheck.hpp (contents, props changed)
Removed:
   sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp
   sandbox/SOC/2011/checks/boost/checks/prechecksum.hpp
Text files modified:
   sandbox/SOC/2011/checks/boost/checks/amex.hpp | 54 ++++---
   sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp | 8
   sandbox/SOC/2011/checks/boost/checks/checks_fwd.hpp | 87 +++++++----
   sandbox/SOC/2011/checks/boost/checks/checksum.hpp | 1
   sandbox/SOC/2011/checks/boost/checks/ean.hpp | 38 ++++-
   sandbox/SOC/2011/checks/boost/checks/isbn.hpp | 20 ++
   sandbox/SOC/2011/checks/boost/checks/mastercard.hpp | 19 +
   sandbox/SOC/2011/checks/boost/checks/modulus97.hpp | 62 +++++--
   sandbox/SOC/2011/checks/boost/checks/upc.hpp | 30 ++-
   sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp | 1
   sandbox/SOC/2011/checks/boost/checks/visa.hpp | 29 ++-
   sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp | 1
   sandbox/SOC/2011/checks/libs/checks/doc/AutoDoxywarnings.log | 26 +++
   sandbox/SOC/2011/checks/libs/checks/doc/checks.qbk | 34 ++--
   sandbox/SOC/2011/checks/libs/checks/doc/doxygen/doxywarn.log | 26 +++
   sandbox/SOC/2011/checks/libs/checks/doc/introduction.qbk | 4
   sandbox/SOC/2011/checks/libs/checks/test/test_checks.cpp | 287 ++++++++++++++++++++++++++++++---------
   sandbox/SOC/2011/checks/libs/checks/test/test_checks_tools.cpp | 34 ----
   18 files changed, 531 insertions(+), 230 deletions(-)

Modified: sandbox/SOC/2011/checks/boost/checks/amex.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/amex.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/amex.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -17,10 +17,6 @@
 #endif
 
 #include <cstddef> // std::size_t
-#include <boost/checks/prechecksum.hpp>
-#include <boost/checks/conversion.hpp>
-#include <boost/checks/filter.hpp>
-#include <boost/checks/checkdigit.hpp>
 #include <boost/checks/luhn.hpp>
 #include <boost/checks/checksum.hpp>
  
@@ -29,13 +25,18 @@
 #include <boost/range/iterator_range.hpp>
 
 /*!
- \brief This macro defines the size of a American Express card number (15).
+ \brief Size of an American Express card number.
 */
 #define AMEX_SIZE 15
 
 namespace boost {
     namespace checks{
 
+/*!
+ \brief American express features
+ \see luhn AMEX_SIZE
+*/
+
 typedef features
 <
   luhn,
@@ -43,17 +44,15 @@
> amex;
 
 /*!
- \brief Validate a sequence according to the amex_check_algorithm type.
-
- \pre check_seq is a valid range.
+ \brief Check the validity of an American Express card number.
 
- \tparam range is a valid range type.
- \param check_seq is the sequence of value to check.
-
- \throws std::invalid_argument if check_seq doesn't contain exactly AMEX_SIZE digits.
- \throws std::invalid_argument if the two first digits (from the leftmost) don't match the Amex pattern.
-
- \returns @c true if the check digit is correct, @c false otherwise.
+ \tparam range Refer to the range concept.
+
+ \param x is the value range to check.
+
+ \returns @c true if the check digit is correct and the length of @c x equals to @c AMEX_SIZE, @c false otherwise.
+
+ \see check_sequence amex AMEX_SIZE
 */
 template <typename range>
 bool check_amex (const range& x)
@@ -61,19 +60,22 @@
   return check_sequence<amex>(x);
 }
 
-/*!
- \brief Calculate the check digit of a sequence according to the amex_compute_algorithm type.
+bool check_amex(const std::string& x)
+{
+ return check_sequence<amex>(make_precheck<digit>(x));
+}
+
 
- \pre check_seq is a valid range.
+/*!
+ \brief Calculate the check digit of an American Express card number.
 
- \tparam range is a valid range type.
- \param check_seq is the sequence of value to check.
+ \tparam range Refer to the range concept.
+
+ \param x is the value range to check.
 
- \throws std::invalid_argument if check_seq doesn't contain exactly AMEX_SIZE_WITHOUT_CHECKDIGIT digits.
- \throws std::invalid_argument if the two first digits (from the leftmost) don't match the amex pattern.
- \throws boost::checks::translation_exception if the check digit cannot be translated into the checkdigit type.
+ \returns The check digit as an integer in the range [0..9]. If the length of @c x is not equals to @c AMEX_SIZE, @c bad_sequence is returned.
 
- \returns The check digit. The check digit is in the range [0..9].
+ \see compute_checkdigit bad_sequence amex AMEX_SIZE
 */
 template <typename range>
 std::size_t compute_amex(const range& x)
@@ -81,6 +83,10 @@
   return compute_checkdigit<amex>(x);
 }
 
+std::size_t compute_amex(const std::string& x)
+{
+ return compute_checkdigit<amex>(make_precheck<digit>(x));
+}
 
 }} // namespace boost namespace checks
 #endif

Deleted: sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
+++ (empty file)
@@ -1,32 +0,0 @@
-// Boost checks/basic_check_algorithm.hpp header file ------------------------------------//
-// (C) Copyright Pierre Talbot 2011 - 2012
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt
-// See http://www.boost.org for updates, documentation, and revision history.
-
-/*! \file
- \brief This file provides a class that should be used as an "interface" because most of the static functions should be re-implemented using inheritance.
-
- \remarks The class implements static functions that are common to many algorithms.
-*/
-
-#ifndef BOOST_CHECKS_BASIC_CHECK_ALGO_HPP
-#define BOOST_CHECKS_BASIC_CHECK_ALGO_HPP
-
-#ifdef _MSC_VER
- #pragma once
-#endif
-
-#include <cstddef> // std::size_t
-#include <boost/checks/filter.hpp>
-#include <boost/checks/conversion.hpp>
-#include <boost/checks/prechecksum.hpp>
-#include <boost/range.hpp>
-
-namespace boost{
- namespace checks{
-
-}} // namespace boost namespace checks
-
-#endif //BOOST_CHECKS_BASIC_CHECK_ALGO_HPP

Modified: sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -73,7 +73,7 @@
 */
 template <typename features,
           typename range>
-bool check_sequence(range &x)
+bool check_sequence(const range &x)
 {
   boost::checks::detail::simple_counter::type counter = boost::checks::detail::simple_counter()();
   std::size_t checksum;
@@ -101,9 +101,11 @@
 */
 template <typename features,
           typename range>
-std::size_t compute_checkdigit(range &x)
+std::size_t compute_checkdigit(const range &x)
 {
- typedef typename boost::checks::detail::skip_counter<features::checksum::checkdigit_detail::pos, features::checksum::checkdigit_detail::size> counter_type;
+ typedef typename boost::checks::detail::skip_counter<features::checksum::checkdigit_detail::pos,
+ features::checksum::checkdigit_detail::size
+ > counter_type;
   typename counter_type::type counter = counter_type()();
 
   std::size_t checksum;

Modified: sandbox/SOC/2011/checks/boost/checks/checks_fwd.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/checks_fwd.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/checks_fwd.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -75,119 +75,142 @@
 // Luhn
 
 template <size_t size_expected, typename check_range>
-bool check_luhn(const check_range& check_seq);
+bool check_luhn(const check_range& x);
 
 template <typename check_range>
-bool check_luhn(const check_range& check_seq);
+bool check_luhn(const check_range& x);
 
 template <size_t size_expected, typename check_range>
-std::size_t compute_luhn(const check_range& check_seq);
+size_t compute_luhn(const check_range& x);
 
 template <typename check_range>
-std::size_t compute_luhn(const check_range& check_seq);
+size_t compute_luhn(const check_range& x);
 
 // Verhoeff
 
 template <size_t size_expected, typename check_range>
-bool check_verhoeff(const check_range& check_seq);
+bool check_verhoeff(const check_range& x);
 
 template <typename check_range>
-bool check_verhoeff(const check_range& check_seq);
+bool check_verhoeff(const check_range& x);
 
 template <size_t size_expected, typename check_range>
-std::size_t compute_verhoeff(const check_range& check_seq);
+size_t compute_verhoeff(const check_range& x);
 
 template <typename check_range>
-std::size_t compute_verhoeff(const check_range& check_seq);
+size_t compute_verhoeff(const check_range& x);
 
 // Modulus 11
 
 template <size_t size_expected, typename check_range>
-bool check_modulus11(const check_range& check_seq);
+bool check_modulus11(const check_range& x);
 
 template <typename check_range>
-bool check_modulus11(const check_range& check_seq);
+bool check_modulus11(const check_range& x);
 
 template <size_t size_expected, typename check_range>
-std::size_t compute_modulus11(const check_range& check_seq);
+size_t compute_modulus11(const check_range& x);
 
 template <typename check_range>
-std::size_t compute_modulus11(const check_range& check_seq);
+size_t compute_modulus11(const check_range& x);
 
 // Modulus 97-10(ISO/IEC 7064:2003)
 
 template <size_t size_expected, typename check_range>
-bool check_mod97_10(const check_range& check_seq);
+bool check_mod97_10(const check_range& x);
+template <size_t size_expected>
+bool check_mod97_10 (const std::string& x);
 
 template <typename check_range>
-bool check_mod97_10(const check_range& check_seq);
+bool check_mod97_10(const check_range& x);
+bool check_mod97_10(const std::string& x);
 
 template <size_t size_expected, typename check_range>
-std::size_t compute_mod97_10(const check_range& check_seq);
+size_t compute_mod97_10(const check_range& x);
+
+template <size_t size_expected>
+size_t compute_mod97_10(const std::string& x);
 
 template <typename check_range>
-std::size_t compute_mod97_10(const check_range& check_seq);
+size_t compute_mod97_10(const check_range& x);
+size_t compute_mod97_10(const std::string& x);
 
 // EAN-13 and EAN-8
 
 template <typename check_range>
-bool check_ean13(const check_range& check_seq);
+bool check_ean13(const check_range& x);
+
+bool check_ean13(const std::string& x);
 
 template <typename check_range>
-std::size_t compute_ean13(const check_range& check_seq);
+size_t compute_ean13(const check_range& x);
+
+size_t compute_ean13(const std::string& x);
 
 template <typename check_range>
-bool check_ean8(const check_range& check_seq);
+bool check_ean8(const check_range& x);
+
+bool check_ean8 (const std::string& x);
 
 template <typename check_range>
-std::size_t compute_ean8(const check_range& check_seq);
+size_t compute_ean8(const check_range& x);
+
+size_t compute_ean8(const std::string& x);
 
 // IBSN-10 and ISBN-13
 
 template <typename check_range>
-bool check_isbn10(const check_range& check_seq);
+bool check_isbn10(const check_range& x);
 
 template <typename check_range>
-std::size_t compute_isbn10(const check_range& check_seq);
+size_t compute_isbn10(const check_range& x);
 
 template <typename check_range>
-bool check_isbn13(const check_range& check_seq);
+bool check_isbn13(const check_range& x);
 
 template <typename check_range>
-std::size_t compute_isbn13(const check_range& check_seq);
+size_t compute_isbn13(const check_range& x);
 
 // UPC-A
 
 template <typename check_range>
-bool check_upca(const check_range& check_seq);
+bool check_upca(const check_range& x);
+bool check_upca(const std::string& x);
 
 template <typename check_range>
-std::size_t compute_upca(const check_range& check_seq);
+size_t compute_upca(const check_range& x);
+size_t compute_upca(const std::string& x);
 
 
 // American Express
 
 template <typename check_range>
-bool check_amex(const check_range& check_seq);
+bool check_amex(const check_range& x);
+bool check_amex(const std::string& x);
 
 template <typename check_range>
-std::size_t compute_amex(const check_range& check_seq);
+size_t compute_amex(const check_range& x);
+size_t compute_amex(const std::string& x);
 
 // VISA
 
 template <typename check_range>
-bool check_visa(const check_range& check_seq);
+bool check_visa(const check_range& x);
+bool check_visa(const std::string& x);
 
 template <typename check_range>
-std::size_t compute_visa(const check_range& check_seq);
+size_t compute_visa(const check_range& x);
+size_t compute_visa(const std::string& x);
 
 // Mastercard
 
 template <typename check_range>
-bool check_mastercard(const check_range& check_seq);
+bool check_mastercard(const check_range& x);
+bool check_mastercard(const std::string& x);
 
 template <typename check_range>
-std::size_t compute_mastercard(const check_range& check_seq);
+size_t compute_mastercard(const check_range& x);
+size_t compute_mastercard(const std::string& x);
 
 
 }} // namespace boost namespace checks

Modified: sandbox/SOC/2011/checks/boost/checks/checksum.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/checksum.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/checksum.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -19,6 +19,7 @@
 #include <boost/range/rbegin.hpp>
 #include <boost/range/rend.hpp>
 #include <boost/range/iterator_range.hpp>
+#include <boost/checks/checkdigit.hpp>
 
 namespace boost {
   namespace checks{

Modified: sandbox/SOC/2011/checks/boost/checks/ean.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/ean.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/ean.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -16,12 +16,15 @@
     #pragma once
 #endif
 
+#include <string>
+
 #include <boost/checks/weight.hpp>
 #include <boost/checks/checkdigit.hpp>
 #include <boost/checks/basic_checks.hpp>
 #include <boost/checks/modulus10.hpp>
 #include <boost/checks/weighted_sum.hpp>
 #include <boost/checks/checksum.hpp>
+#include <boost/checks/precheck.hpp>
 
 #include <boost/range/rbegin.hpp>
 #include <boost/range/rend.hpp>
@@ -76,9 +79,14 @@
     \returns @c true if the check digit is correct, @c false otherwise.
 */
 template <typename check_range>
-bool check_ean13(const check_range& check_seq)
+bool check_ean13(const check_range& x)
+{
+ return check_sequence<ean13>(x);
+}
+
+bool check_ean13(const std::string& x)
 {
- return check_sequence<ean13> (check_seq);
+ return check_sequence<ean13>(make_precheck<digit>(x));
 }
 
 /*!
@@ -95,9 +103,14 @@
     \returns The check digit. The check digit is in the range [0..9].
 */
 template <typename check_range>
-std::size_t compute_ean13(const check_range& check_seq)
+std::size_t compute_ean13(const check_range& x)
+{
+ return compute_checkdigit<ean13>(x);
+}
+
+std::size_t compute_ean13(const std::string& x)
 {
- return compute_checkdigit<ean13>(check_seq);
+ return compute_checkdigit<ean13>(make_precheck<digit>(x));
 }
 
 /*!
@@ -113,9 +126,14 @@
     \returns @c true if the check digit is correct, @c false otherwise.
 */
 template <typename check_range>
-bool check_ean8 (const check_range& check_seq)
+bool check_ean8 (const check_range& x)
+{
+ return check_sequence<ean8>(x);
+}
+
+bool check_ean8 (const std::string& x)
 {
- return check_sequence<ean8>(check_seq);
+ return check_sequence<ean8>(make_precheck<digit>(x));
 }
 
 /*!
@@ -132,11 +150,15 @@
     \returns The check digit. The check digit is in the range [0..9].
 */
 template <typename check_range>
-std::size_t compute_ean8(const check_range& check_seq)
+std::size_t compute_ean8(const check_range& x)
 {
- return compute_checkdigit<ean8>(check_seq);
+ return compute_checkdigit<ean8>(x);
 }
 
+std::size_t compute_ean8(const std::string& x)
+{
+ return compute_checkdigit<ean8>(make_precheck<digit>(x));
+}
 
 }} // namespace boost namespace checks
 #endif // BOOST_CHECKS_EAN_HPP

Modified: sandbox/SOC/2011/checks/boost/checks/isbn.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/isbn.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/isbn.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -55,6 +55,11 @@
   return check_sequence<isbn13>(x);
 }
 
+bool check_isbn13 (const std::string& x)
+{
+ return check_sequence<isbn13>(make_precheck<digit>(x));
+}
+
 /*!
     \brief Calculate the check digit of a sequence according to the isbn13_compute_algorithm type.
 
@@ -74,6 +79,11 @@
   return compute_checkdigit<isbn13>(x);
 }
 
+std::size_t compute_isbn13 (const std::string& x)
+{
+ return compute_checkdigit<isbn13>(make_precheck<digit>(x));
+}
+
 typedef features
 <
   mod11,
@@ -98,6 +108,12 @@
   return check_sequence<isbn10>(x);
 }
 
+bool check_isbn10(const std::string& x)
+{
+ return check_sequence<isbn10>(make_precheck<digitx>(x));
+}
+
+
 /*!
     \brief Calculate the check digit of a sequence according to the mod11_compute_algorithm type.
 
@@ -117,6 +133,10 @@
   return compute_checkdigit<isbn10>(x);
 }
 
+std::size_t compute_isbn10(const std::string& x)
+{
+ return compute_checkdigit<isbn10>(make_precheck<digitx>(x));
+}
 
 }} // namespace boost namespace checks
 #endif // BOOST_CHECKS_ISBN_HPP

Modified: sandbox/SOC/2011/checks/boost/checks/mastercard.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/mastercard.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/mastercard.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -19,8 +19,8 @@
 #include <boost/range/rbegin.hpp>
 #include <boost/range/rend.hpp>
 #include <boost/range/iterator_range.hpp>
-#include <boost/checks/checksum.hpp>
 
+#include <boost/checks/checksum.hpp>
 #include <boost/checks/luhn.hpp>
 #include <boost/checks/checkdigit.hpp>
 
@@ -52,9 +52,14 @@
     \returns True if the check digit is correct, false otherwise.
 */
 template <typename check_range>
-bool check_mastercard(const check_range& check_seq)
+bool check_mastercard(const check_range& x)
 {
- return check_sequence<mastercard>(check_seq);
+ return check_sequence<mastercard>(x);
+}
+
+bool check_mastercard(const std::string& x)
+{
+ return check_sequence<mastercard>(make_precheck<digit>(x));
 }
 
 /*!
@@ -72,11 +77,15 @@
     \returns The check digit. The check digit is in the range [0..9].
 */
 template <typename check_range>
-std::size_t compute_mastercard(const check_range& check_seq)
+size_t compute_mastercard(const check_range& x)
 {
- return compute_checkdigit<mastercard>(check_seq);
+ return compute_checkdigit<mastercard>(x);
 }
 
+size_t compute_mastercard(const std::string& x)
+{
+ return compute_checkdigit<mastercard>(make_precheck<digit>(x));
+}
 
 }} // namespace boost namespace checks
 #endif // BOOST_CHECKS_MASTERCARD_HPP

Modified: sandbox/SOC/2011/checks/boost/checks/modulus97.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/modulus97.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/modulus97.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -103,81 +103,103 @@
 /*!
     \brief Validate a sequence according to the mod97_10_check_algorithm type.
 
- \pre check_seq is a valid range.\n size_expected > 0 (enforced by static assert).
+ \pre x is a valid range.\n size_expected > 0 (enforced by static assert).
 
     \tparam size_expected is the number of valid value expected in the sequence.
     \tparam check_range is a valid range type.
- \param check_seq is the sequence of value to check.
+ \param x is the sequence of value to check.
 
- \throws std::invalid_argument if check_seq doesn't contain size_expected valid values.
+ \throws std::invalid_argument if x doesn't contain size_expected valid values.
 
     \returns True if the two check digits are correct, false otherwise.
 */
 template <size_t size_expected, typename check_range>
-bool check_mod97_10 (const check_range& check_seq)
+bool check_mod97_10 (const check_range& x)
 {
- return check_sequence<features<mod97_10, size_expected> >(check_seq);
+ return check_sequence<features<mod97_10, size_expected> >(x);
+}
+
+template <size_t size_expected>
+bool check_mod97_10 (const std::string& x)
+{
+ return check_sequence<features<mod97_10, size_expected> >(make_precheck<digit>(x));
 }
 
 /*!
     \brief Validate a sequence according to the mod97_10_check_algorithm type.
 
- \pre check_seq is a valid range.
+ \pre x is a valid range.
 
     \tparam check_range is a valid range type.
- \param check_seq is the sequence of value to check.
+ \param x is the sequence of value to check.
 
- \throws std::invalid_argument if check_seq contains no valid value.
+ \throws std::invalid_argument if x contains no valid value.
 
     \returns @c true if the two check digits are correct, @c false otherwise.
 */
 template <typename check_range>
-bool check_mod97_10(const check_range& check_seq)
+bool check_mod97_10(const check_range& x)
+{
+ return check_sequence<features<mod97_10> >(x);
+}
+
+bool check_mod97_10(const std::string& x)
 {
- return check_sequence<features<mod97_10> >(check_seq);
+ return check_sequence<features<mod97_10> >(make_precheck<digit>(x));
 }
 
 /*!
     \brief Calculate the check digits of a sequence according to the mod97_10_compute_algorithm type.
 
- \pre check_seq is a valid range.\n size_expected > 0 (enforced by static assert).\n mod97_checkdigits should have enough reserved place to store the two check digits.
+ \pre x is a valid range.\n size_expected > 0 (enforced by static assert).\n mod97_checkdigits should have enough reserved place to store the two check digits.
 
     \tparam size_expected is the number of valid value expected in the sequence. (So the check digits are not included.)
     \tparam check_range is a valid range type.
     \tparam checkdigits_iter must meet the OutputIterator requirements.
- \param check_seq is the sequence of value to check.
+ \param x is the sequence of value to check.
     \param mod97_checkdigits is the OutputIterator in which the two check digits will be stored.
 
- \throws std::invalid_argument if check_seq doesn't contain size_expected valid values.
+ \throws std::invalid_argument if x doesn't contain size_expected valid values.
     \throws translation_exception if the check digits cannot be translated into the checkdigits_iter type.
 
     \returns The check digits are stored into mod97_checkdigits. The range of these is [0..9][0..9].
 */
 template <size_t size_expected, typename check_range>
-std::size_t compute_mod97_10(const check_range& check_seq)
+std::size_t compute_mod97_10(const check_range& x)
 {
- return compute_checkdigit<features<mod97_10, size_expected> >(check_seq);
+ return compute_checkdigit<features<mod97_10, size_expected> >(x);
+}
+
+template <size_t size_expected>
+std::size_t compute_mod97_10(const std::string& x)
+{
+ return compute_checkdigit<features<mod97_10, size_expected> >(make_precheck<digit>(x));
 }
 
 /*!
     \brief Calculate the check digits of a sequence according to the mod97_10_compute_algorithm type.
 
- \pre check_seq is a valid range.\n mod97_checkdigits should have enough reserved place to store the two check digits.
+ \pre x is a valid range.\n mod97_checkdigits should have enough reserved place to store the two check digits.
 
     \tparam check_range is a valid range type.
     \tparam checkdigits_iter must meet the OutputIterator requirements.
- \param check_seq is the sequence of value to check.
+ \param x is the sequence of value to check.
     \param mod97_checkdigits is the OutputIterator in which the two check digits will be stored.
 
- \throws std::invalid_argument if check_seq contains no valid value.
+ \throws std::invalid_argument if x contains no valid value.
     \throws translation_exception if the check digits cannot be translated into the checkdigits_iter type.
 
     \returns The check digits are stored into mod97_checkdigits. The range of these is [0..9][0..9].
 */
 template <typename check_range>
-std::size_t compute_mod97_10(const check_range& check_seq)
+std::size_t compute_mod97_10(const check_range& x)
+{
+ return compute_checkdigit<features<mod97_10> >(x);
+}
+
+std::size_t compute_mod97_10(const std::string& x)
 {
- return compute_checkdigit<features<mod97_10> >(check_seq);
+ return compute_checkdigit<features<mod97_10> >(make_precheck<digit>(x));
 }
 
 

Added: sandbox/SOC/2011/checks/boost/checks/precheck.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2011/checks/boost/checks/precheck.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -0,0 +1,136 @@
+// Boost checks/precheck.hpp header file
+// (C) Copyright Pierre Talbot 2012
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt
+// See http://www.boost.org for updates, documentation, and revision history.
+
+/*! \file
+ \brief
+*/
+
+#ifndef BOOST_CHECK_PRECHECK_HPP
+#define BOOST_CHECK_PRECHECK_HPP
+
+#ifdef _MSC_VER
+ #pragma once
+#endif
+
+#include <utility>
+#include <boost/range.hpp>
+#include <boost/iterator/filter_iterator.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+
+#include <boost/checks/filter.hpp>
+#include <boost/checks/conversion.hpp>
+
+namespace boost {
+ namespace checks{
+
+template <
+ typename Precheck,
+ typename Iterator
+ >
+std::pair
+<
+ typename Precheck::template iterator<Iterator>::type,
+ typename Precheck::template iterator<Iterator>::type
+>
+make_precheck(Iterator begin, Iterator end)
+{
+ typedef typename Precheck::template iterator<Iterator>::type iter;
+ Precheck precheck;
+ return std::make_pair<iter, iter>(precheck(begin, end), precheck(end, end));
+}
+
+template <
+ typename Precheck,
+ typename T
+ >
+std::pair
+<
+ typename Precheck::template iterator<typename range_iterator<T>::type>::type,
+ typename Precheck::template iterator<typename range_iterator<T>::type>::type
+>
+make_precheck(T &x)
+{
+ return make_precheck<Precheck>(boost::begin(x), boost::end(x));
+}
+
+struct no_filter_tag {};
+struct no_conversion_tag {};
+
+template <typename UnaryPredicate,
+ typename UnaryFunction>
+struct precheck
+{
+ typedef UnaryPredicate FilterPredicate;
+ typedef UnaryFunction ConversionFunction;
+
+ template <typename BaseIterator>
+ struct iterator
+ {
+ typedef typename boost::transform_iterator<ConversionFunction,
+ boost::filter_iterator<FilterPredicate,
+ BaseIterator> > type;
+ };
+
+ FilterPredicate filter;
+ ConversionFunction converter;
+
+ template <typename BaseIterator>
+ typename iterator<BaseIterator>::type operator()(BaseIterator b, BaseIterator e)
+ {
+ return typename iterator<BaseIterator>::type(boost::filter_iterator<FilterPredicate, BaseIterator>(filter, b, e),
+ converter);
+ }
+};
+
+template <typename UnaryFunction>
+struct precheck<no_filter_tag, UnaryFunction>
+{
+ typedef UnaryFunction ConversionFunction;
+
+ template <typename BaseIterator>
+ struct iterator
+ {
+ typedef typename boost::transform_iterator<ConversionFunction,
+ BaseIterator> type;
+ };
+
+ ConversionFunction converter;
+
+ template <typename BaseIterator>
+ typename iterator<BaseIterator>::type operator()(BaseIterator b, BaseIterator e)
+ {
+ return typename iterator<BaseIterator>::type(b, converter);
+ }
+};
+
+template <typename UnaryPredicate>
+struct precheck<UnaryPredicate, no_conversion_tag>
+{
+ typedef UnaryPredicate FilterPredicate;
+
+ template <typename BaseIterator>
+ struct iterator
+ {
+ typedef typename boost::filter_iterator<FilterPredicate, BaseIterator> type;
+ };
+
+ FilterPredicate filter;
+
+ template <typename BaseIterator>
+ typename iterator<BaseIterator>::type operator()(BaseIterator b, BaseIterator e)
+ {
+ return typename iterator<BaseIterator>::type(filter, b, e);
+ }
+};
+
+typedef precheck<digit_filter, chartodigit> digit;
+typedef precheck<digitx_filter, chartodigitx> digitx;
+
+} // namespace checks
+} // namespace boost
+
+#endif // BOOST_CHECK_PRECHECK_HPP

Deleted: sandbox/SOC/2011/checks/boost/checks/prechecksum.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/prechecksum.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
+++ (empty file)
@@ -1,139 +0,0 @@
-// Boost checks/prechecksum.hpp header file
-// (C) Copyright Pierre Talbot 2012
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt
-// See http://www.boost.org for updates, documentation, and revision history.
-
-/*! \file
- \brief
-*/
-
-#ifndef BOOST_CHECK_PRECHECKSUM_HPP
-#define BOOST_CHECK_PRECHECKSUM_HPP
-
-#ifdef _MSC_VER
- #pragma once
-#endif
-
-#include <utility>
-#include <boost/range.hpp>
-#include <boost/iterator/filter_iterator.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-
-#include <boost/checks/filter.hpp>
-#include <boost/checks/conversion.hpp>
-
-namespace boost {
- namespace checks{
-
-
-
-
-template <
- typename Prechecksum,
- typename Iterator
- >
-std::pair
-<
- typename Prechecksum::template iterator<Iterator>::type,
- typename Prechecksum::template iterator<Iterator>::type
->
-make_prechecksum(Iterator begin, Iterator end)
-{
- typedef typename Prechecksum::template iterator<Iterator>::type iter;
- Prechecksum prechecksum;
- return std::make_pair<iter, iter>(prechecksum(begin, end), prechecksum(end, end));
-}
-
-template <
- typename Prechecksum,
- typename T
- >
-std::pair
-<
- typename Prechecksum::template iterator<typename range_iterator<T>::type>::type,
- typename Prechecksum::template iterator<typename range_iterator<T>::type>::type
->
-make_prechecksum(T &sequence)
-{
- return make_prechecksum<Prechecksum>(boost::begin(sequence), boost::end(sequence));
-}
-
-struct no_filter_tag {};
-struct no_conversion_tag {};
-
-template <typename UnaryPredicate,
- typename UnaryFunction>
-struct prechecksum
-{
- typedef UnaryPredicate FilterPredicate;
- typedef UnaryFunction ConversionFunction;
-
- template <typename BaseIterator>
- struct iterator
- {
- typedef typename boost::transform_iterator<ConversionFunction,
- boost::filter_iterator<FilterPredicate,
- BaseIterator> > type;
- };
-
- FilterPredicate filter;
- ConversionFunction converter;
-
- template <typename BaseIterator>
- typename iterator<BaseIterator>::type operator()(BaseIterator b, BaseIterator e)
- {
- return typename iterator<BaseIterator>::type(boost::filter_iterator<FilterPredicate, BaseIterator>(filter, b, e),
- converter);
- }
-};
-
-template <typename UnaryFunction>
-struct prechecksum<no_filter_tag, UnaryFunction>
-{
- typedef UnaryFunction ConversionFunction;
-
- template <typename BaseIterator>
- struct iterator
- {
- typedef typename boost::transform_iterator<ConversionFunction,
- BaseIterator> type;
- };
-
- ConversionFunction converter;
-
- template <typename BaseIterator>
- typename iterator<BaseIterator>::type operator()(BaseIterator b, BaseIterator e)
- {
- return typename iterator<BaseIterator>::type(b, converter);
- }
-};
-
-template <typename UnaryPredicate>
-struct prechecksum<UnaryPredicate, no_conversion_tag>
-{
- typedef UnaryPredicate FilterPredicate;
-
- template <typename BaseIterator>
- struct iterator
- {
- typedef typename boost::filter_iterator<FilterPredicate, BaseIterator> type;
- };
-
- FilterPredicate filter;
-
- template <typename BaseIterator>
- typename iterator<BaseIterator>::type operator()(BaseIterator b, BaseIterator e)
- {
- return typename iterator<BaseIterator>::type(filter, b, e);
- }
-};
-
-typedef prechecksum<digit_filter, chartodigit> digit_prechecksum;
-typedef prechecksum<digitx_filter, chartodigitx> digitx_prechecksum;
-
-} // namespace checks
-} // namespace boost
-
-#endif // BOOST_CHECK_PRECHECKSUM_HPP

Modified: sandbox/SOC/2011/checks/boost/checks/upc.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/upc.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/upc.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -55,38 +55,48 @@
 /*!
     \brief Validate a sequence according to the upc_check_algorithm type.
 
- \pre check_seq is a valid range.
+ \pre x is a valid range.
 
     \tparam check_range is a valid range type.
- \param check_seq is the sequence of value to check.
+ \param x is the sequence of value to check.
 
- \throws std::invalid_argument if check_seq doesn't contain exactly UPCA_SIZE digits.
+ \throws std::invalid_argument if x doesn't contain exactly UPCA_SIZE digits.
 
     \returns @c true if the check digit is correct, @c false otherwise.
 */
 template <typename check_range>
-bool check_upca (const check_range& check_seq)
+bool check_upca (const check_range& x)
 {
- return check_sequence<upca>(check_seq);
+ return check_sequence<upca>(x);
+}
+
+bool check_upca (const std::string& x)
+{
+ return check_sequence<upca>(make_precheck<digit>(x));
 }
 
 /*!
     \brief Calculate the check digit of a sequence according to the upc_compute_algorithm type.
 
- \pre check_seq is a valid range.
+ \pre x is a valid range.
 
     \tparam check_range is a valid range type.
- \param check_seq is the sequence of value to check.
+ \param x is the sequence of value to check.
 
- \throws std::invalid_argument if check_seq doesn't contain exactly UPCA_SIZE_WITHOUT_CHECKDIGIT digits.
+ \throws std::invalid_argument if x doesn't contain exactly UPCA_SIZE_WITHOUT_CHECKDIGIT digits.
     \throws boost::checks::translation_exception if the check digit cannot be translated into the checkdigit type.
 
     \returns The check digit. The check digit is in the range [0..9].
 */
 template <typename check_range>
-std::size_t compute_upca(const check_range& check_seq)
+std::size_t compute_upca(const check_range& x)
+{
+ return compute_checkdigit<upca>(x);
+}
+
+std::size_t compute_upca(const std::string& x)
 {
- return compute_checkdigit<upca>(check_seq);
+ return compute_checkdigit<upca>(make_precheck<digit>(x));
 }
 
 }} // namespace boost namespace checks

Modified: sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -27,7 +27,6 @@
 #include <boost/checks/weight.hpp>
 #include <boost/checks/checkdigit.hpp>
 #include <boost/checks/basic_checks.hpp>
-#include <boost/checks/basic_check_algorithm.hpp>
 
 namespace boost {
     namespace checks{

Modified: sandbox/SOC/2011/checks/boost/checks/visa.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/visa.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/visa.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -40,42 +40,51 @@
 /*!
     \brief Validate a sequence according to the visa_check_algorithm type.
 
- \pre check_seq is a valid range.
+ \pre x is a valid range.
 
     \tparam check_range is a valid range type.
- \param check_seq is the sequence of value to check.
+ \param x is the sequence of value to check.
 
- \throws std::invalid_argument if check_seq doesn't contain exactly VISA_SIZE digits.
+ \throws std::invalid_argument if x doesn't contain exactly VISA_SIZE digits.
     \throws std::invalid_argument if the first digit(from the leftmost)doesn't match the Visa pattern.
 
     \returns @c true if the check digit is correct, @c false otherwise.
 */
 template <typename check_range>
-bool check_visa(const check_range& check_seq)
+bool check_visa(const check_range& x)
 {
- return check_sequence<visa>(check_seq);
+ return check_sequence<visa>(x);
+}
+
+bool check_visa(const std::string& x)
+{
+ return check_sequence<visa>(make_precheck<digit>(x));
 }
 
 /*!
     \brief Calculate the check digit of a sequence according to the visa_compute_algorithm type.
 
- \pre check_seq is a valid range.
+ \pre x is a valid range.
 
     \tparam check_range is a valid range type.
- \param check_seq is the sequence of value to check.
+ \param x is the sequence of value to check.
 
- \throws std::invalid_argument if check_seq doesn't contain exactly VISA_SIZE_WITHOUT_CHECKDIGIT digits.
+ \throws std::invalid_argument if x doesn't contain exactly VISA_SIZE_WITHOUT_CHECKDIGIT digits.
     \throws std::invalid_argument if the first digit(from the leftmost)doESn't match the Visa pattern.
     \throws boost::checks::translation_exception if the check digit cannot be translated into the checkdigit type.
 
     \returns The check digit. The check digit is in the range [0..9].
 */
 template <typename check_range>
-std::size_t compute_visa(const check_range& check_seq)
+std::size_t compute_visa(const check_range& x)
 {
- return compute_checkdigit<visa>(check_seq);
+ return compute_checkdigit<visa>(x);
 }
 
+std::size_t compute_visa(const std::string& x)
+{
+ return compute_checkdigit<visa>(make_precheck<digit>(x));
+}
 
 }} // namespace boost namespace checks
 #endif // BOOST_CHECKS_VISA_HPP

Modified: sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -18,7 +18,6 @@
 
 #include <boost/checks/weight.hpp>
 #include <boost/checks/basic_checks.hpp>
-#include <boost/checks/basic_check_algorithm.hpp>
 
 namespace boost{
   namespace checks{

Modified: sandbox/SOC/2011/checks/libs/checks/doc/AutoDoxywarnings.log
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/doc/AutoDoxywarnings.log (original)
+++ sandbox/SOC/2011/checks/libs/checks/doc/AutoDoxywarnings.log 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -0,0 +1,26 @@
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:83: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::check_isbn10(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:83: warning: The following parameters of boost::checks::check_isbn10(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:40: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::check_isbn13(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:40: warning: The following parameters of boost::checks::check_isbn13(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:61: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::check_sequence(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:61: warning: The following parameters of boost::checks::check_sequence(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:89: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::compute_checkdigit(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:89: warning: The following parameters of boost::checks::compute_checkdigit(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:29: warning: argument 'seq_begin' of command @param is not found in the argument list of boost::checks::compute_checksum(iterator begin, iterator end, counter_iter &counter)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:29: warning: argument 'seq_end' of command @param is not found in the argument list of boost::checks::compute_checksum(iterator begin, iterator end, counter_iter &counter)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:29: warning: The following parameters of boost::checks::compute_checksum(iterator begin, iterator end, counter_iter &counter) are not documented:
+ parameter 'begin'
+ parameter 'end'
+ parameter 'counter'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:101: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::compute_isbn10(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:101: warning: The following parameters of boost::checks::compute_isbn10(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:58: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::compute_isbn13(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:58: warning: The following parameters of boost::checks::compute_isbn13(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/modulus97.hpp:140: warning: argument 'mod97_checkdigits' of command @param is not found in the argument list of boost::checks::compute_mod97_10(const check_range &check_seq)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/modulus97.hpp:162: warning: argument 'mod97_checkdigits' of command @param is not found in the argument list of boost::checks::compute_mod97_10(const check_range &check_seq)

Modified: sandbox/SOC/2011/checks/libs/checks/doc/checks.qbk
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/doc/checks.qbk (original)
+++ sandbox/SOC/2011/checks/libs/checks/doc/checks.qbk 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -19,8 +19,15 @@
 [/Note too that it can't be used for images.]
 [def __boostlicense [@http://www.boost.org/LICENSE_1_0.txt Boost License]]
 
+[/ Links to documentation.]
+[def __CHECKS_DOC_HTML [@http://boost-sandbox.sourceforge.net/libs/checks/doc/html/index.html HTML documentation]]
+[def __CHECKS_DOC_PDF [@https://svn.boost.org/svn/boost/sandbox/SOC/2011/checks/libs/checks/doc/checks.pdf PDF documentation]]
+
+[/ Links to source code]
+[def __CHECKS_SRC_CODE [@https://svn.boost.org/svn/boost/sandbox/SOC/2011/checks/boost/checks/boost/ Boost Sandbox checks source code.]]
+
 [def __CHECKS__HIERARCHY__ [$./images/checks/check_hierarchy.png]]
-[def __EXTENDS__LIBRARY__ [link checks.checks.tutorial.extending_the_library extending the library]]
+[def __EXTENDS__LIBRARY__ [link checks.checks.tutorial.extending_the_library Extending the library]]
 
 [def __BASIC__CHECK__FILE__ [@../../../../boost/checks/basic_checks.hpp basic_checks.hpp]]
 [def __WEIGHTED__SUM__FILE__ [@../../../../boost/checks/weighted_sum.hpp weighted_sum.hpp]]
@@ -97,19 +104,20 @@
 the code is quite functional, but interfaces, library structure, and names
 may still be changed without notice. The current version is available at
 
-[*https://svn.boost.org/svn/boost/sandbox/SOC/2011/checks/libs/checks/doc/checks.pdf PDF documentation.]
+[*__CHECKS_DOC_PDF]
+
+[*__CHECKS_DOC_HTML]
 
-[*https://svn.boost.org/svn/boost/sandbox/SOC/2011/checks/libs/checks/doc/html/index.html HTML documentation.]
+[*__CHECKS_SRC_CODE]
 
-[*https://svn.boost.org/svn/boost/sandbox/SOC/2011/checks/boost/checks/boost/ Boost Sandbox checks source code.]
 ] [/important]
 
-[note Comments and suggestions (even bugs!) to Pierre Talbot ( ptalbot_at_[hidden] ) ]
+[note Comments and suggestions (even bugs!) to Pierre Talbot ( ptalbot (at) mopong (dot) net ) ]
 
 [endsect] [/section:status Status]
 
 [include conventions.qbk]
-[include tutorial.qbk]
+[include quickstart.qbk]
 [include algorithm.qbk]
 [include errors.qbk]
 
@@ -164,23 +172,11 @@
 
 * For more flexibility, this library uses the range concept. So you can use old C-array or
 std::string,...
-* If there is only one check digit in the number, this check digit is returned in the same
-raw type than in the range sequence.
-* If there is more than one check digit, an extra parameter is required. This must be an
-OutputIterator, the function returns an iterator at one pass the end of the check digit
-stored into this iterator.
-
-[h4 Use of template parameters to pass size and weights]
-* This feature means that much of the commonality between the various check systems
-can be implemented in one place and reused.
-* It also makes it possible to implement other check systems
-(of which there are very many in use worldwide)
-and to devise new ones without writing new code.
 
 [h4 Performance]
 
 * Performance is not a major objective, but all the current algorithms
-are implemented with a ['O(n)] complexity, where ['n] is the number of digits or characters.
+are implemented with a ['O(n)] complexity, where ['n] is the number of characters.
 
 [endsect] [/section:rationale Rationale]
 

Modified: sandbox/SOC/2011/checks/libs/checks/doc/doxygen/doxywarn.log
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/doc/doxygen/doxywarn.log (original)
+++ sandbox/SOC/2011/checks/libs/checks/doc/doxygen/doxywarn.log 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -0,0 +1,26 @@
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:83: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::check_isbn10(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:83: warning: The following parameters of boost::checks::check_isbn10(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:40: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::check_isbn13(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:40: warning: The following parameters of boost::checks::check_isbn13(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:61: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::check_sequence(range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:61: warning: The following parameters of boost::checks::check_sequence(range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:89: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::compute_checkdigit(range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:89: warning: The following parameters of boost::checks::compute_checkdigit(range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:29: warning: argument 'seq_begin' of command @param is not found in the argument list of boost::checks::compute_checksum(iterator begin, iterator end, counter_iter &counter)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:29: warning: argument 'seq_end' of command @param is not found in the argument list of boost::checks::compute_checksum(iterator begin, iterator end, counter_iter &counter)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp:29: warning: The following parameters of boost::checks::compute_checksum(iterator begin, iterator end, counter_iter &counter) are not documented:
+ parameter 'begin'
+ parameter 'end'
+ parameter 'counter'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:101: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::compute_isbn10(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:101: warning: The following parameters of boost::checks::compute_isbn10(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:58: warning: argument 'check_seq' of command @param is not found in the argument list of boost::checks::compute_isbn13(const range &x)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/isbn.hpp:58: warning: The following parameters of boost::checks::compute_isbn13(const range &x) are not documented:
+ parameter 'x'
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/modulus97.hpp:140: warning: argument 'mod97_checkdigits' of command @param is not found in the argument list of boost::checks::compute_mod97_10(const check_range &check_seq)
+/home/trademark/Boost/boost-sandbox/SOC/2011/checks/boost/checks/modulus97.hpp:162: warning: argument 'mod97_checkdigits' of command @param is not found in the argument list of boost::checks::compute_mod97_10(const check_range &check_seq)

Modified: sandbox/SOC/2011/checks/libs/checks/doc/introduction.qbk
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/doc/introduction.qbk (original)
+++ sandbox/SOC/2011/checks/libs/checks/doc/introduction.qbk 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -1,6 +1,6 @@
 [section:introduction Introduction]
 
-Checks are required in a numerous domains : distribution chain (bar codes on products),
+Checks are required in a numerous domains: distribution chain (bar codes on products),
 banking (bank account numbers, credit cards, fidelity cards, ...) and many others.
 These codes and numbers are often copied or scanned by humans or machines, and both make errors.
 We need a way to control it and this is why some people created a check digit.
@@ -18,4 +18,4 @@
 Theoritically, the user should only use the high level library which is more specific.
 In some cases, the user would like to use the lower level library because some kind of exotic numbers (social number of india,...) are not provided by the library.
 
-[endsect] [/section:introduction Introduction]
\ No newline at end of file
+[endsect] [/section:introduction Introduction]

Modified: sandbox/SOC/2011/checks/libs/checks/test/test_checks.cpp
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/test/test_checks.cpp (original)
+++ sandbox/SOC/2011/checks/libs/checks/test/test_checks.cpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -22,7 +22,7 @@
 #include <boost/test/unit_test.hpp> // Enhanced for unit_test framework autolink
 #include <boost/test/included/unit_test.hpp>
 
-#include <boost/checks/prechecksum.hpp>
+#include <boost/checks/precheck.hpp>
 
 #include <boost/checks/luhn.hpp>
 #include <boost/checks/verhoeff.hpp>
@@ -53,158 +53,313 @@
 
 BOOST_AUTO_TEST_CASE(visa_tests)
 {
+ // Checkdigit validation tests.
   std::string visa_valid = "4417 1234 5678 9113";
+ std::string visa_invalid = "5417 1234 5678 9113";
   std::string visa_low_size_failure = "417 1234 5678 9113"; // A missing digit '4'.
   std::string visa_big_size_failure = "44417 1234 5678 9113"; // An extra '4' digit.
 
- BOOST_CHECK(check_visa(make_prechecksum<digit_prechecksum>(visa_valid)));
- BOOST_CHECK_EQUAL(check_visa(make_prechecksum<digit_prechecksum>(visa_low_size_failure)), false);
- BOOST_CHECK_EQUAL(check_visa(make_prechecksum<digit_prechecksum>(visa_big_size_failure)), false);
+ // Verify that check_amex(string) == check_amex(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(check_visa(make_precheck<digit>(visa_valid)), check_visa(visa_valid));
+ BOOST_CHECK_EQUAL(check_visa(make_precheck<digit>(visa_invalid)), check_visa(visa_invalid));
+ BOOST_CHECK_EQUAL(check_visa(make_precheck<digit>(visa_low_size_failure)), check_visa(visa_low_size_failure));
+ BOOST_CHECK_EQUAL(check_visa(make_precheck<digit>(visa_big_size_failure)), check_visa(visa_big_size_failure));
+
+ // Verify the check validity.
+ BOOST_CHECK(check_visa(visa_valid));
+ BOOST_CHECK_EQUAL(check_visa(visa_invalid), false);
+ BOOST_CHECK_EQUAL(check_visa(visa_low_size_failure), false);
+ BOOST_CHECK_EQUAL(check_visa(visa_big_size_failure), false);
 
+ // Checkdigit computation tests.
   std::string visa_valid_without_checkdigit = "4417 1234 5678 911";
- std::size_t valid_checkdigit = 3;
- BOOST_CHECK_EQUAL(compute_visa(make_prechecksum<digit_prechecksum>(visa_valid_without_checkdigit)), valid_checkdigit);
+ std::string visa_invalid_without_checkdigit = "5417 1234 5678 911";
+ std::string visa_size_error = "4417 1234 5678 91";
+ size_t valid_checkdigit = 3;
+
+ // Verify that compute_visa(make_precheck<digit>(string)) == compute_visa(string).
+ BOOST_CHECK_EQUAL(compute_visa(make_precheck<digit>(visa_valid_without_checkdigit)), compute_visa(visa_valid_without_checkdigit));
+
+ // Verify the check digit computation.
+ BOOST_CHECK_EQUAL(compute_visa(visa_valid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_NE(compute_visa(visa_invalid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_EQUAL(compute_visa(visa_size_error), bad_sequence);
 }
 
 BOOST_AUTO_TEST_CASE(amex_tests)
 {
+ // Checkdigit validation tests.
   std::string amex_valid = "3782 822463 10005";
   std::string amex_low_size_failure = "378 822463 10005";
   std::string amex_big_size_failure = "33782 822463 10005";
 
- BOOST_CHECK(check_amex(make_prechecksum<digit_prechecksum>(amex_valid)));
- BOOST_CHECK_EQUAL(check_amex(make_prechecksum<digit_prechecksum>(amex_low_size_failure)), false);
- BOOST_CHECK_EQUAL(check_amex(make_prechecksum<digit_prechecksum>(amex_big_size_failure)), false);
+ // Verify that check_amex(string) == check_amex(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(check_amex(amex_valid), check_amex(make_precheck<digit>(amex_valid)));
+ BOOST_CHECK_EQUAL(check_amex(amex_low_size_failure), check_amex(make_precheck<digit>(amex_low_size_failure)));
+ BOOST_CHECK_EQUAL(check_amex(amex_big_size_failure), check_amex(make_precheck<digit>(amex_big_size_failure)));
+
+ // Verify the check validity.
+ BOOST_CHECK(check_amex(amex_valid));
+ BOOST_CHECK_EQUAL(check_amex(amex_low_size_failure), false);
+ BOOST_CHECK_EQUAL(check_amex(amex_big_size_failure), false);
 
+ // Checkdigit computation tests.
   std::string amex_valid_without_checkdigit = "3782 822463 1000";
- std::size_t valid_checkdigit = 5;
-
- BOOST_CHECK_EQUAL(compute_amex(make_prechecksum<digit_prechecksum>(amex_valid_without_checkdigit)), valid_checkdigit);
+ std::string amex_invalid_without_checkdigit = "4782 822463 1000";
+ std::string amex_size_error = "782 822463 1000";
+ size_t valid_checkdigit = 5;
+
+ // Verify that compute_amex(make_precheck<digit>(string)) == compute_amex(string).
+ BOOST_CHECK_EQUAL(compute_amex(make_precheck<digit>(amex_valid_without_checkdigit)), compute_amex(amex_valid_without_checkdigit));
+
+ // Verify the check digit computation.
+ BOOST_CHECK_EQUAL(compute_amex(amex_valid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_NE(compute_amex(amex_invalid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_EQUAL(compute_amex(amex_size_error), bad_sequence);
 }
 
 BOOST_AUTO_TEST_CASE(mastercard_tests)
 {
+ // Checkdigit validation tests.
   std::string mastercard_valid = "5105 1051 0510 5100";
   std::string mastercard_low_size_failure = "515 1051 0510 5100";
   std::string mastercard_big_size_failure = "51505 1051 0510 5100";
 
- BOOST_CHECK(check_mastercard(make_prechecksum<digit_prechecksum>(mastercard_valid)));
- BOOST_CHECK_EQUAL(check_mastercard(make_prechecksum<digit_prechecksum>(mastercard_low_size_failure)), false);
- BOOST_CHECK_EQUAL(check_mastercard(make_prechecksum<digit_prechecksum>(mastercard_big_size_failure)), false);
+ // Verify that check_mastercard(string) == check_mastercard(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(check_mastercard(mastercard_valid), check_mastercard(make_precheck<digit>(mastercard_valid)));
+ BOOST_CHECK_EQUAL(check_mastercard(mastercard_low_size_failure), check_mastercard(make_precheck<digit>(mastercard_low_size_failure)));
+ BOOST_CHECK_EQUAL(check_mastercard(mastercard_big_size_failure), check_mastercard(make_precheck<digit>(mastercard_big_size_failure)));
+
+ // Verify the check validity.
+ BOOST_CHECK(check_mastercard(mastercard_valid));
+ BOOST_CHECK_EQUAL(check_mastercard(mastercard_low_size_failure), false);
+ BOOST_CHECK_EQUAL(check_mastercard(mastercard_big_size_failure), false);
 
+ // Checkdigit computation tests.
   std::string mastercard_valid_without_checkdigit = "5105 1051 0510 510";
- std::size_t valid_checkdigit = 0;
+ std::string mastercard_invalid_without_checkdigit = "5105 1051 0510 511"; // 511 instead of 510.
+ std::string mastercard_size_error = "105 1051 0510 510";
+ size_t valid_checkdigit = 0;
   
- BOOST_CHECK_EQUAL(compute_mastercard(make_prechecksum<digit_prechecksum>(mastercard_valid_without_checkdigit)), valid_checkdigit);
+ // Verify that compute_mastercard(make_precheck<digit>(string)) == compute_mastercard(string).
+ BOOST_CHECK_EQUAL(compute_mastercard(mastercard_valid_without_checkdigit), compute_mastercard(make_precheck<digit>(mastercard_valid_without_checkdigit)));
+
+ // Verify the check digit computation.
+ BOOST_CHECK_EQUAL(compute_mastercard(mastercard_valid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_NE(compute_mastercard(mastercard_invalid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_EQUAL(compute_mastercard(mastercard_size_error), bad_sequence);
 }
 
-BOOST_AUTO_TEST_CASE(ean_tests)
+BOOST_AUTO_TEST_CASE(ean13_tests)
 {
+ // Checkdigit validation tests.
   std::string ean13_valid = "5 412983 130028"; // Belgium beer "Bon secours".
   std::string ean13_low_size_failure = "05 412983 130028";
   std::string ean13_big_size_failure = "412983 130028";
 
- BOOST_CHECK(check_ean13(make_prechecksum<digit_prechecksum>(ean13_valid)));
- BOOST_CHECK_EQUAL(check_ean13(make_prechecksum<digit_prechecksum>(ean13_low_size_failure)), false);
- BOOST_CHECK_EQUAL(check_ean13(make_prechecksum<digit_prechecksum>(ean13_big_size_failure)), false);
+ // Verify that check_ean13(string) == check_ean13(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(check_ean13(make_precheck<digit>(ean13_valid)), check_ean13(ean13_valid));
+ BOOST_CHECK_EQUAL(check_ean13(make_precheck<digit>(ean13_low_size_failure)), check_ean13(ean13_low_size_failure));
+ BOOST_CHECK_EQUAL(check_ean13(make_precheck<digit>(ean13_big_size_failure)), check_ean13(ean13_big_size_failure));
+
+ // Verify the check validity
+ BOOST_CHECK(check_ean13(ean13_valid));
+ BOOST_CHECK_EQUAL(check_ean13(ean13_low_size_failure), false);
+ BOOST_CHECK_EQUAL(check_ean13(ean13_big_size_failure), false);
 
+ // Checkdigit computation tests.
   std::string ean13_valid_without_checkdigit = "5 412983 13002";
- std::size_t valid_checkdigit = 8;
+ std::string ean13_invalid_without_checkdigit = "1 412983 13002";
+ std::string ean13_size_error = " 412983 13002";
+ size_t valid_checkdigit = 8;
+
+ // Verify that compute_ean13(string) == compute_ean13(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(compute_ean13(make_precheck<digit>(ean13_valid_without_checkdigit)), compute_ean13(ean13_valid_without_checkdigit));
+
+ // Verify the check digit computation.
+ BOOST_CHECK_EQUAL(compute_ean13(ean13_valid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_NE(compute_ean13(ean13_invalid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_EQUAL(compute_ean13(ean13_size_error), bad_sequence);
+}
 
- BOOST_CHECK_EQUAL(compute_ean13(make_prechecksum<digit_prechecksum>(ean13_valid_without_checkdigit)), valid_checkdigit);
 
+BOOST_AUTO_TEST_CASE(ean8_tests)
+{
+ // Checkdigit validation tests.
   std::string ean8_valid = "5449 1472"; // Bottle of Coke.
   std::string ean8_low_size_failure = "5449 472";
   std::string ean8_big_size_failure = "05449 1472";
 
- BOOST_CHECK(check_ean8(make_prechecksum<digit_prechecksum>(ean8_valid)));
- BOOST_CHECK_EQUAL(check_ean8(make_prechecksum<digit_prechecksum>(ean8_low_size_failure)), false);
- BOOST_CHECK_EQUAL(check_ean8(make_prechecksum<digit_prechecksum>(ean8_big_size_failure)), false);
+ // Verify that check_ean8(string) == check_ean8(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(check_ean8(make_precheck<digit>(ean8_valid)), check_ean8(ean8_valid));
+ BOOST_CHECK_EQUAL(check_ean8(make_precheck<digit>(ean8_low_size_failure)), check_ean8(ean8_low_size_failure));
+ BOOST_CHECK_EQUAL(check_ean8(make_precheck<digit>(ean8_big_size_failure)), check_ean8(ean8_big_size_failure));
+
+ // Verify the check validity.
+ BOOST_CHECK(check_ean8(ean8_valid));
+ BOOST_CHECK_EQUAL(check_ean8(ean8_low_size_failure), false);
+ BOOST_CHECK_EQUAL(check_ean8(ean8_big_size_failure), false);
 
+ // Checkdigit computation tests.
   std::string ean8_valid_without_checkdigit = "5449 147";
- valid_checkdigit = 2;
-
- BOOST_CHECK_EQUAL(compute_ean8(make_prechecksum<digit_prechecksum>(ean8_valid_without_checkdigit)), valid_checkdigit);
+ std::string ean8_invalid_without_checkdigit = "1449 147";
+ std::string ean8_size_error = "5449 14";
+ size_t valid_checkdigit = 2;
+
+ // Verify that compute_ean8(string) == compute_ean8(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(compute_ean8(make_precheck<digit>(ean8_valid_without_checkdigit)), compute_ean8(ean8_valid_without_checkdigit));
+
+ // Verify the check digit computation.
+ BOOST_CHECK_EQUAL(compute_ean8(ean8_valid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_NE(compute_ean8(ean8_invalid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_EQUAL(compute_ean8(ean8_size_error), bad_sequence);
 }
 
 BOOST_AUTO_TEST_CASE(upc_tests)
 {
+ // Checkdigit validation tests.
   std::string upca_valid = "036000291452"; // Box of tissues.
+ std::string upca_invalid = "136000291452";
   std::string upca_low_size_failure = "36000291452";
   std::string upca_big_size_failure = "0036000291452";
 
- BOOST_CHECK(check_upca(make_prechecksum<digit_prechecksum>(upca_valid)));
- BOOST_CHECK_EQUAL(check_upca(make_prechecksum<digit_prechecksum>(upca_low_size_failure)), false);
- BOOST_CHECK_EQUAL(check_upca(make_prechecksum<digit_prechecksum>(upca_big_size_failure)), false);
+ // Verify that check_upc(string) == check_upc(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(check_upca(make_precheck<digit>(upca_valid)), check_upca(upca_valid));
+ BOOST_CHECK_EQUAL(check_upca(make_precheck<digit>(upca_invalid)), check_upca(upca_invalid));
+ BOOST_CHECK_EQUAL(check_upca(make_precheck<digit>(upca_low_size_failure)), check_upca(upca_low_size_failure));
+ BOOST_CHECK_EQUAL(check_upca(make_precheck<digit>(upca_big_size_failure)), check_upca(upca_big_size_failure));
+
+ // Verify the check validity.
+ BOOST_CHECK(check_upca(upca_valid));
+ BOOST_CHECK_EQUAL(check_upca(upca_invalid), false);
+ BOOST_CHECK_EQUAL(check_upca(upca_low_size_failure), false);
+ BOOST_CHECK_EQUAL(check_upca(upca_big_size_failure), false);
 
+ // Checkdigit computation tests.
   std::string upca_valid_without_checkdigit = "03600029145";
- std::size_t valid_checkdigit = 2;
+ std::string upca_invalid_without_checkdigit = "13600029145";
+ std::string upca_size_error = "0360002914";
+ size_t valid_checkdigit = 2;
   
- BOOST_CHECK_EQUAL(compute_upca(make_prechecksum<digit_prechecksum>(upca_valid_without_checkdigit)), valid_checkdigit);
+ // Verify that compute_ean13(string) == compute_ean13(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(compute_upca(make_precheck<digit>(upca_valid_without_checkdigit)), compute_upca(upca_valid_without_checkdigit));
+
+ // Verify the check digit computation.
+ BOOST_CHECK_EQUAL(compute_upca(upca_valid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_NE(compute_upca(upca_invalid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_EQUAL(compute_upca(upca_size_error), bad_sequence);
 }
 
-BOOST_AUTO_TEST_CASE(isbn_tests)
+BOOST_AUTO_TEST_CASE(isbn13_tests)
 {
-
+ // Checkdigit validation tests.
   std::string isbn13_valid = "978-0-13-235088-4"; // Clean Code: a handbook of agile software craftsmanship, Robert C. Martin.
   std::string isbn13_not_valid = "979-0-13-235088-4";
   std::string isbn13_low_size_failure = "978--13-235088-4";
   std::string isbn13_big_size_failure = "978-00-13-235088-4";
 
- BOOST_CHECK(check_isbn13(make_prechecksum<digit_prechecksum>(isbn13_valid)));
- BOOST_CHECK(!check_isbn13(make_prechecksum<digit_prechecksum>(isbn13_not_valid)));
- BOOST_CHECK_EQUAL(check_isbn13(make_prechecksum<digit_prechecksum>(isbn13_low_size_failure)), false);
- BOOST_CHECK_EQUAL(check_isbn13(make_prechecksum<digit_prechecksum>(isbn13_big_size_failure)), false);
+ // Verify that check_isbn13(string) == check_isbn13(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(check_isbn13(make_precheck<digit>(isbn13_valid)), check_isbn13(isbn13_valid));
+ BOOST_CHECK_EQUAL(check_isbn13(make_precheck<digit>(isbn13_not_valid)), check_isbn13(isbn13_not_valid));
+ BOOST_CHECK_EQUAL(check_isbn13(make_precheck<digit>(isbn13_low_size_failure)), check_isbn13(isbn13_low_size_failure));
+ BOOST_CHECK_EQUAL(check_isbn13(make_precheck<digit>(isbn13_big_size_failure)), check_isbn13(isbn13_big_size_failure));
+
+ // Verify the check validity.
+ BOOST_CHECK(check_isbn13(isbn13_valid));
+ BOOST_CHECK_EQUAL(check_isbn13(isbn13_not_valid), false);
+ BOOST_CHECK_EQUAL(check_isbn13(isbn13_low_size_failure), false);
+ BOOST_CHECK_EQUAL(check_isbn13(isbn13_big_size_failure), false);
 
+ // Checkdigit computation tests.
   std::string isbn13_valid_without_checkdigit = "978-0-13-235088-";
- std::string isbn13_not_valid_without_checkdigit = "979-0-13-235088-";
- std::size_t valid_checkdigit = 4;
+ std::string isbn13_not_valid_without_checkdigit = "979-0-13-235088-"; // 979
+ std::string isbn13_size_error = "978-0-13-35088-";
+
+ size_t valid_checkdigit = 4;
   
- BOOST_CHECK_EQUAL(compute_isbn13(make_prechecksum<digit_prechecksum>(isbn13_valid_without_checkdigit)), valid_checkdigit);
- BOOST_CHECK_NE(compute_isbn13(make_prechecksum<digit_prechecksum>(isbn13_not_valid_without_checkdigit)), valid_checkdigit);
+ // Verify that compute_isbn13(string) == compute_isbn13(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(compute_isbn13(make_precheck<digit>(isbn13_valid_without_checkdigit)), compute_isbn13(isbn13_valid_without_checkdigit));
 
+ // Verify the check digit computation.
+ BOOST_CHECK_EQUAL(compute_isbn13(isbn13_valid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_NE(compute_isbn13(isbn13_not_valid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_EQUAL(compute_isbn13(isbn13_size_error), bad_sequence);
+}
+
+BOOST_AUTO_TEST_CASE(isbn10_tests)
+{
+ // Checkdigit validation tests.
   std::string isbn10_valid = "0-201-70073-5"; // The C++ Programming Language, Special Edition, Bjarne Stroustrup.
+ std::string isbn10_invalid = "-201-70073-5";
   std::string isbn10_low_size_failure = "00-201-70073-5";
   std::string isbn10_big_size_failure = "-201-70073-5";
 
- BOOST_CHECK(check_isbn10(make_prechecksum<digitx_prechecksum>(isbn10_valid)));
- BOOST_CHECK_EQUAL(check_isbn10(make_prechecksum<digitx_prechecksum>(isbn10_low_size_failure)), false);
- BOOST_CHECK_EQUAL(check_isbn10(make_prechecksum<digitx_prechecksum>(isbn10_big_size_failure)), false);
+ // Verify that check_isbn10(string) == check_isbn10(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(check_isbn10(make_precheck<digitx>(isbn10_valid)), check_isbn10(isbn10_valid));
+ BOOST_CHECK_EQUAL(check_isbn10(make_precheck<digitx>(isbn10_invalid)), check_isbn10(isbn10_invalid));
+ BOOST_CHECK_EQUAL(check_isbn10(make_precheck<digitx>(isbn10_low_size_failure)), check_isbn10(isbn10_low_size_failure));
+ BOOST_CHECK_EQUAL(check_isbn10(make_precheck<digitx>(isbn10_big_size_failure)), check_isbn10(isbn10_big_size_failure));
+
+ // Verify the check validity.
+ BOOST_CHECK(check_isbn10(isbn10_valid));
+ BOOST_CHECK_EQUAL(check_isbn10(isbn10_invalid), false);
+ BOOST_CHECK_EQUAL(check_isbn10(isbn10_low_size_failure), false);
+ BOOST_CHECK_EQUAL(check_isbn10(isbn10_big_size_failure), false);
 
+ // Checkdigit computation tests.
   std::string isbn10_valid_without_checkdigit = "0-201-70073-";
- valid_checkdigit = 5;
-
- BOOST_CHECK_EQUAL(compute_isbn10(make_prechecksum<digitx_prechecksum>(isbn10_valid_without_checkdigit)), valid_checkdigit);
+ std::string isbn10_invalid_without_checkdigit = "1-201-70073-";
+ std::string isbn10_size_error = "0-20-70073-"; // 20 instead of 201
+ size_t valid_checkdigit = 5;
+
+ // Verify that compute_isbn10(string) == compute_isbn10(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(compute_isbn10(make_precheck<digitx>(isbn10_valid_without_checkdigit)), compute_isbn10(isbn10_valid_without_checkdigit));
+
+ // Verify the check digit computation.
+ BOOST_CHECK_EQUAL(compute_isbn10(isbn10_valid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_NE(compute_isbn10(isbn10_invalid_without_checkdigit), valid_checkdigit);
+ BOOST_CHECK_EQUAL(compute_isbn10(isbn10_size_error), bad_sequence);
 }
 
 BOOST_AUTO_TEST_CASE(mod97_10_tests)
 {
+ // Checkdigit validation tests.
   std::string mod97_10_valid = "510007547061111462"; // From a Belgian IBAN
   std::string mod97_10_not_valid = "511007547061111462";
   std::string mod97_10_low_size_failure = "51007547061111462";
   std::string mod97_10_big_size_failure = "5100007547061111462";
 
- BOOST_CHECK(check_mod97_10(make_prechecksum<digit_prechecksum>(mod97_10_valid)));
- BOOST_CHECK(!check_mod97_10(make_prechecksum<digit_prechecksum>(mod97_10_not_valid)));
- BOOST_CHECK(!check_mod97_10(make_prechecksum<digit_prechecksum>(mod97_10_low_size_failure)));
- BOOST_CHECK(!check_mod97_10(make_prechecksum<digit_prechecksum>(mod97_10_big_size_failure)));
+ // Verify that check_mod97_10(string) == check_mod97_10(make_precheck<digit>(string)).
+ BOOST_CHECK(check_mod97_10(make_precheck<digit>(mod97_10_valid)));
+ BOOST_CHECK_EQUAL(check_mod97_10(make_precheck<digit>(mod97_10_not_valid)), check_mod97_10(mod97_10_not_valid));
+ BOOST_CHECK_EQUAL(check_mod97_10(make_precheck<digit>(mod97_10_low_size_failure)), check_mod97_10(mod97_10_low_size_failure));
+ BOOST_CHECK_EQUAL(check_mod97_10(make_precheck<digit>(mod97_10_big_size_failure)), check_mod97_10(mod97_10_big_size_failure));
+
+ // Verify the check validity.
+ BOOST_CHECK(check_mod97_10(mod97_10_valid));
+ BOOST_CHECK_EQUAL(check_mod97_10(mod97_10_not_valid), false);
+ BOOST_CHECK_EQUAL(check_mod97_10(mod97_10_low_size_failure), false);
+ BOOST_CHECK_EQUAL(check_mod97_10(mod97_10_big_size_failure), false);
 
+ // Checkdigit computation tests.
   std::string mod97_10_valid_without_checkdigits = "5100075470611114";
- std::string mod97_10_not_valid_without_checkdigits = "5110075470611114";
+ std::string mod97_10_invalid_without_checkdigits = "5110075470611114";
+ std::string mod97_10_size_error = "51100754706111141";
 
- std::size_t checkdigits = 62;
- std::size_t valid_check_digits = compute_mod97_10(make_prechecksum<digit_prechecksum>(mod97_10_valid_without_checkdigits));
- BOOST_CHECK_EQUAL(valid_check_digits, checkdigits);
+ size_t checkdigits = 62;
 
- std::size_t invalid_check_digits = compute_mod97_10(make_prechecksum<digit_prechecksum>(mod97_10_not_valid_without_checkdigits));
- BOOST_CHECK_NE(invalid_check_digits, checkdigits);
+ // Verify that compute_isbn10(string) == compute_isbn10(make_precheck<digit>(string)).
+ BOOST_CHECK_EQUAL(compute_mod97_10(make_precheck<digit>(mod97_10_valid_without_checkdigits)), compute_mod97_10(mod97_10_valid_without_checkdigits));
+ BOOST_CHECK_EQUAL(compute_mod97_10(make_precheck<digit>(mod97_10_invalid_without_checkdigits)), compute_mod97_10(mod97_10_invalid_without_checkdigits));
+
+ // Verify the check digit computation.
+ BOOST_CHECK_EQUAL(compute_mod97_10(mod97_10_valid_without_checkdigits), checkdigits);
+ BOOST_CHECK_NE(compute_mod97_10(mod97_10_invalid_without_checkdigits), checkdigits);
+ BOOST_CHECK_EQUAL(compute_mod97_10<16>(mod97_10_size_error), bad_sequence);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
 
-
-
-
 BOOST_AUTO_TEST_SUITE(technical_tests)
 
 struct luhn_functor
@@ -212,7 +367,7 @@
   template <typename range>
   typename boost::range_value<range>::type operator()(const range &check_range)const
   {
- return compute_luhn(make_prechecksum<digit_prechecksum>(check_range));
+ return compute_luhn(make_precheck<digit>(check_range));
   }
 };
 
@@ -221,7 +376,7 @@
   template <typename range>
   typename boost::range_value<range>::type operator()(const range &check_range)const
   {
- return compute_verhoeff(make_prechecksum<digit_prechecksum>(check_range));
+ return compute_verhoeff(make_precheck<digit>(check_range));
   }
 };
 
@@ -230,7 +385,7 @@
   template <typename range>
   typename boost::range_value<range>::type operator()(const range &check_range)const
   {
- return compute_modulus11(make_prechecksum<digitx_prechecksum>(check_range));
+ return compute_modulus11(make_precheck<digitx>(check_range));
   }
 };
 

Modified: sandbox/SOC/2011/checks/libs/checks/test/test_checks_tools.cpp
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/test/test_checks_tools.cpp (original)
+++ sandbox/SOC/2011/checks/libs/checks/test/test_checks_tools.cpp 2012-10-08 00:53:22 EDT (Mon, 08 Oct 2012)
@@ -19,44 +19,20 @@
 #include <boost/test/unit_test.hpp> // Enhanced for unit_test framework autolink.
 
 #include <boost/checks/weight.hpp>
-#include <boost/checks/limits.hpp>
+#include <boost/checks/checksum.hpp>
 
 
 BOOST_AUTO_TEST_CASE(weight_test)
 {
   typedef boost::checks::weight<0,1,2,3,4,5,6,7,8,9> number_suite ;
- for(int i=0 ; i < 100 ; ++i)
+ for(size_t i=0 ; i < 100 ; ++i)
     BOOST_CHECK ( i%10 == number_suite::at( i ) ) ;
 
   typedef boost::checks::weight<1,1,1,1,1,1> suite_of_1 ;
- for(int i=0 ; i < 100; ++i)
+ for(size_t i=0 ; i < 100; ++i)
     BOOST_CHECK ( 1 == suite_of_1::at( i ) ) ;
 
   typedef boost::checks::weight<> no_weight_specify ;
- for(int i=0 ; i < 100; ++i)
+ for(size_t i=0 ; i < 100; ++i)
     BOOST_CHECK ( 0 == no_weight_specify::at( i ) ) ;
-}
-
-BOOST_AUTO_TEST_CASE(limits_test)
-{
- typedef boost::checks::strict_size_contract<5> size_expected ;
- typedef boost::checks::no_null_size_contract<> no_size_expected ;
-
- size_expected::respect_size_contract( 5 ) ;
-
- for(int i = 6 ; i < 14 ; ++i)
- BOOST_CHECK_THROW ( size_expected::respect_size_contract( i%10+1 ) , std::invalid_argument )
-
- for(int i=1 ; i < 10; ++i)
- no_size_expected::respect_size_contract (i) ;
-
- BOOST_CHECK_THROW ( no_size_expected::respect_size_contract (0), std::invalid_argument )
-
- for(int i = 0 ; i < 6 ; ++i)
- {
- BOOST_CHECK ( !size_expected::reach_one_past_the_end(i) );
- BOOST_CHECK ( !no_size_expected::reach_one_past_the_end(i) );
- }
- BOOST_CHECK ( size_expected::reach_one_past_the_end(6) );
- BOOST_CHECK ( !no_size_expected::reach_one_past_the_end(6) );
-}
+}
\ No newline at end of file


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