|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71347 - in trunk: boost/spirit/home/qi/numeric boost/spirit/home/qi/numeric/detail libs/spirit/test libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2011-04-16 22:55:38
Author: hkaiser
Date: 2011-04-16 22:55:36 EDT (Sat, 16 Apr 2011)
New Revision: 71347
URL: http://svn.boost.org/trac/boost/changeset/71347
Log:
Spirit: applying patch to allow for arbitrary radicies while parsing unsigned numbers
Added:
trunk/libs/spirit/test/qi/uint_radix.cpp (contents, props changed)
trunk/libs/spirit/test/qi/uint_radix.hpp (contents, props changed)
Removed:
trunk/libs/spirit/test/qi/radix_test.cpp
Text files modified:
trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp | 212 ++++++++++++---------------------------
trunk/boost/spirit/home/qi/numeric/numeric_utils.hpp | 2
trunk/boost/spirit/home/qi/numeric/uint.hpp | 2
trunk/libs/spirit/test/Jamfile | 1
4 files changed, 71 insertions(+), 146 deletions(-)
Modified: trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp 2011-04-16 22:55:36 EDT (Sat, 16 Apr 2011)
@@ -2,6 +2,7 @@
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2001-2011 Hartmut Kaiser
Copyright (c) 2006 Stephen Nutt
+ Copyright (c) 2011 Jan Frederick Eick
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)
@@ -18,6 +19,10 @@
#include <boost/spirit/home/qi/detail/attributes.hpp>
#include <boost/spirit/home/support/char_encoding/ascii.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/iteration/local.hpp>
+#include <boost/preprocessor/comparison/less.hpp>
+#include <boost/preprocessor/control/if.hpp>
+#include <boost/preprocessor/seq/elem.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_signed.hpp>
@@ -55,131 +60,52 @@
template <unsigned Radix>
struct radix_traits;
- // Binary
- template <>
- struct radix_traits<2>
- {
- template<typename Char>
- inline static bool is_valid(Char ch)
- {
- return ('0' == ch || '1' == ch);
- }
-
- template<typename Char>
- inline static unsigned digit(Char ch)
- {
- return ch - '0';
- }
+// lookup table for log2(x) : 2 <= x <= 36
+#define LOG2 (#error)(#error) \
+ (1.0)(1.58496)(2.0)(2.32192)(2.58496)(2.80735)(3.0) \
+ (3.16992)(3.32192)(3.45943)(3.58496)(3.70043)(3.80735) \
+ (3.90689)(4.0)(4.08746)(4.16992)(4.24792)(4.32192) \
+ (4.39231)(4.45943)(4.52356)(4.58496)(4.64385)(4.70043) \
+ (4.75488)(4.80735)(4.85798)(4.90689)(4.95419)(5.0) \
+ (5.04439)(5.08746)(5.12928)(5.169925) \
+ /***/
+
+#define BOOST_PP_LOCAL_MACRO(Radix) \
+ template<> struct radix_traits<Radix> \
+ { \
+ template <typename Char> \
+ inline static bool is_valid(Char ch) \
+ { \
+ BOOST_PP_IF( BOOST_PP_LESS_EQUAL(Radix, 10) \
+ , return (ch >= '0' && ch <= static_cast<Char>('0' + Radix -1)) \
+ , return (ch >= '0' && ch <= '9') \
+ || (ch >= 'a' && ch <= static_cast<Char>('a' + Radix -10 -1)) \
+ || (ch >= 'A' && ch <= static_cast<Char>('A' + Radix -10 -1)) \
+ ); \
+ } \
+ template <typename Char> \
+ inline static unsigned digit(Char ch) \
+ { \
+ BOOST_PP_IF( BOOST_PP_LESS_EQUAL(Radix, 10) \
+ , return ch - '0'; \
+ , if (ch >= '0' && ch <= '9') return ch - '0'; \
+ return spirit::char_encoding::ascii::tolower(ch) - 'a' + 10; \
+ ) \
+ } \
+ template <typename T> \
+ struct digits \
+ { \
+ typedef std::numeric_limits<T> numeric_limits_; \
+ BOOST_STATIC_CONSTANT(int, value = static_cast<int>( \
+ numeric_limits_::digits / BOOST_PP_SEQ_ELEM(Radix, LOG2))); \
+ }; \
+ }; \
+ /***/
- template<typename T>
- struct digits
- {
- typedef std::numeric_limits<T> numeric_limits_;
- BOOST_STATIC_CONSTANT(int, value = numeric_limits_::digits);
- };
- };
-
- // Octal
- template <>
- struct radix_traits<8>
- {
- template<typename Char>
- inline static bool is_valid(Char ch)
- {
- return ch >= '0' && ch <= '7';
- }
+#define BOOST_PP_LOCAL_LIMITS (2, 36)
+#include BOOST_PP_LOCAL_ITERATE()
- template<typename Char>
- inline static unsigned digit(Char ch)
- {
- return ch - '0';
- }
-
- template<typename T>
- struct digits
- {
- typedef std::numeric_limits<T> numeric_limits_;
- BOOST_STATIC_CONSTANT(int, value = numeric_limits_::digits / 3);
- };
- };
-
- // Decimal
- template <>
- struct radix_traits<10>
- {
- template<typename Char>
- inline static bool is_valid(Char ch)
- {
- return ch >= '0' && ch <= '9';
- }
-
- template<typename Char>
- inline static unsigned digit(Char ch)
- {
- return ch - '0';
- }
-
- template<typename T>
- struct digits
- {
- typedef std::numeric_limits<T> numeric_limits_;
- BOOST_STATIC_CONSTANT(int, value = numeric_limits_::digits10);
- };
- };
-
- // Hexadecimal
- template <>
- struct radix_traits<16>
- {
- template<typename Char>
- inline static bool is_valid(Char ch)
- {
- return (ch >= '0' && ch <= '9')
- || (ch >= 'a' && ch <= 'f')
- || (ch >= 'A' && ch <= 'F');
- }
-
- template<typename Char>
- inline static unsigned digit(Char ch)
- {
- if (ch >= '0' && ch <= '9')
- return ch - '0';
- return spirit::char_encoding::ascii::tolower(ch) - 'a' + 10;
- }
-
- template<typename T>
- struct digits
- {
- typedef std::numeric_limits<T> numeric_limits_;
- BOOST_STATIC_CONSTANT(int, value = numeric_limits_::digits / 4);
- };
- };
-
- // arbitrary Radix
- template <unsigned Radix>
- struct radix_traits
- {
- template<typename Char>
- inline static bool is_valid(Char ch)
- {
- return (ch >= '0' && ch <= ('0' + Radix - 1));
- }
-
- template<typename Char>
- inline static unsigned digit(Char ch)
- {
- return ch - '0';
- }
-
- template<typename T>
- struct digits
- {
- typedef std::numeric_limits<T> numeric_limits_;
- BOOST_STATIC_CONSTANT(int, value = numeric_limits_::digits10);
- // TODO(j.f.eick_at_[hidden]): this is the min number of digits which
- // can be safely parsed if the radix is < 10 - this is not optimal?
- };
- };
+#undef LOG2
///////////////////////////////////////////////////////////////////////////
// positive_accumulator/negative_accumulator: Accumulator policies for
@@ -201,7 +127,6 @@
{
// Ensure n *= Radix will not overflow
static T const max = (std::numeric_limits<T>::max)();
- //static T const val = (max - 1) / Radix;
static T const val = max / Radix;
if (n > val)
return false;
@@ -333,15 +258,15 @@
///////////////////////////////////////////////////////////////////////////
// extract_int: main code for extracting integers
///////////////////////////////////////////////////////////////////////////
-#define SPIRIT_NUMERIC_INNER_LOOP(z, x, data) \
- if (!check_max_digits<MaxDigits>::call(count + leading_zeros) \
- || it == last) \
- break; \
- ch = *it; \
- if (!radix_check::is_valid(ch) || !extractor::call(ch, count, val)) \
- break; \
- ++it; \
- ++count; \
+#define SPIRIT_NUMERIC_INNER_LOOP(z, x, data) \
+ if (!check_max_digits<MaxDigits>::call(count + leading_zeros) \
+ || it == last) \
+ break; \
+ ch = *it; \
+ if (!radix_check::is_valid(ch) || !extractor::call(ch, count, val)) \
+ break; \
+ ++it; \
+ ++count; \
/**/
template <
@@ -434,16 +359,16 @@
// extract_int: main code for extracting integers
// common case where MinDigits == 1 and MaxDigits = -1
///////////////////////////////////////////////////////////////////////////
-#define SPIRIT_NUMERIC_INNER_LOOP(z, x, data) \
- if (it == last) \
- break; \
- ch = *it; \
- if (!radix_check::is_valid(ch)) \
- break; \
- if (!extractor::call(ch, count, val)) \
- return false; \
- ++it; \
- ++count; \
+#define SPIRIT_NUMERIC_INNER_LOOP(z, x, data) \
+ if (it == last) \
+ break; \
+ ch = *it; \
+ if (!radix_check::is_valid(ch)) \
+ break; \
+ if (!extractor::call(ch, count, val)) \
+ return false; \
+ ++it; \
+ ++count; \
/**/
template <typename T, unsigned Radix, typename Accumulator, bool Accumulate>
@@ -572,7 +497,6 @@
return n;
}
};
-
}}}}
#endif
Modified: trunk/boost/spirit/home/qi/numeric/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/numeric_utils.hpp 2011-04-16 22:55:36 EDT (Sat, 16 Apr 2011)
@@ -48,7 +48,7 @@
{
// check template parameter 'Radix' for validity
BOOST_SPIRIT_ASSERT_MSG(
- Radix >= 2 || Radix <= 10 || Radix == 16,
+ Radix >= 2 && Radix <= 36,
not_supported_radix, ());
template <typename Iterator>
Modified: trunk/boost/spirit/home/qi/numeric/uint.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/uint.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/uint.hpp 2011-04-16 22:55:36 EDT (Sat, 16 Apr 2011)
@@ -221,7 +221,7 @@
{
// check template parameter 'Radix' for validity
BOOST_SPIRIT_ASSERT_MSG(
- Radix >= 2 || Radix <= 10 || Radix == 16,
+ Radix >= 2 && Radix <= 36,
not_supported_radix, ());
template <typename Context, typename Iterator>
Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2011-04-16 22:55:36 EDT (Sat, 16 Apr 2011)
@@ -110,6 +110,7 @@
[ run qi/pass_container2.cpp : : : : qi_pass_container2 ]
[ run qi/permutation.cpp : : : : qi_permutation ]
[ run qi/plus.cpp : : : : qi_plus ]
+ [ run qi/uint_radix.cpp : : : : qi_uint_radix ]
[ run qi/range_run.cpp : : : : qi_range_run ]
[ run qi/raw.cpp : : : : qi_raw ]
[ run qi/real1.cpp : : : : qi_real1 ]
Deleted: trunk/libs/spirit/test/qi/radix_test.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/radix_test.cpp 2011-04-16 22:55:36 EDT (Sat, 16 Apr 2011)
+++ (empty file)
@@ -1,187 +0,0 @@
-#include "uint.hpp"
-
-#include <iostream>
-
-int
-main()
-{
- using spirit_test::test;
- using spirit_test::test_attr;
-
- ///////////////////////////////////////////////////////////////////////////
- // arbitrary radix test (base 3)
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::uint_;
- using boost::spirit::qi::uint_parser;
- unsigned int u;
-
- uint_parser<unsigned int, 3, 1, -1> base3_parser;
-
- BOOST_TEST(test("210112221200", base3_parser));
- BOOST_TEST(test_attr("210112221200", base3_parser, u));
- BOOST_TEST(424242 == u);
-
- BOOST_TEST(!test("1231", base3_parser));
- BOOST_TEST(!test_attr("1231", base3_parser, u));
-
- char const* max_unsigned_base3 = "102002022201221111210";
- char const* unsigned_overflow_base3 = "102002022201221111211";
- char const* digit_overflow_base3 = "1020020222012211112100";
-
- BOOST_TEST(test(max_unsigned_base3, base3_parser));
- BOOST_TEST(test_attr(max_unsigned_base3, base3_parser, u));
-
- BOOST_TEST(!test(unsigned_overflow_base3, base3_parser));
- BOOST_TEST(!test_attr(unsigned_overflow_base3, base3_parser, u));
- BOOST_TEST(!test(digit_overflow_base3, base3_parser));
- BOOST_TEST(!test_attr(digit_overflow_base3, base3_parser, u));
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // arbitrary radix test (base 4)
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::uint_;
- using boost::spirit::qi::uint_parser;
- unsigned int u;
-
- uint_parser<unsigned int, 4, 1, -1> base4_parser;
-
- BOOST_TEST(test("1213210302", base4_parser));
- BOOST_TEST(test_attr("1213210302", base4_parser, u));
- BOOST_TEST(424242 == u);
-
- BOOST_TEST(!test("1234", base4_parser));
- BOOST_TEST(!test_attr("1234", base4_parser, u));
-
- char const* max_unsigned_base4 = "3333333333333333";
- char const* unsigned_overflow_base4 = "33333333333333330";
- BOOST_TEST(test(max_unsigned_base4, base4_parser));
- BOOST_TEST(test_attr(max_unsigned_base4, base4_parser, u));
- BOOST_TEST(!test(unsigned_overflow_base4, base4_parser));
- BOOST_TEST(!test_attr(unsigned_overflow_base4, base4_parser, u));
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // arbitrary radix test (base 5)
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::uint_;
- using boost::spirit::qi::uint_parser;
- unsigned int u;
-
- uint_parser<unsigned int, 5, 1, -1> base5_parser;
-
- BOOST_TEST(test("102033432", base5_parser));
- BOOST_TEST(test_attr("102033432", base5_parser, u));
- BOOST_TEST(424242 == u);
-
- BOOST_TEST(!test("2345", base5_parser));
- BOOST_TEST(!test_attr("2345", base5_parser, u));
-
- char const* max_unsigned_base5 = "32244002423140";
- char const* unsigned_overflow_base5 = "32244002423141";
- char const* digit_overflow_base5 = "322440024231400";
-
- BOOST_TEST(test(max_unsigned_base5, base5_parser));
- BOOST_TEST(test_attr(max_unsigned_base5, base5_parser, u));
-
- BOOST_TEST(!test(unsigned_overflow_base5, base5_parser));
- BOOST_TEST(!test_attr(unsigned_overflow_base5, base5_parser, u));
- BOOST_TEST(!test(digit_overflow_base5, base5_parser));
- BOOST_TEST(!test_attr(digit_overflow_base5, base5_parser, u));
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // arbitrary radix test (base 6)
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::uint_;
- using boost::spirit::qi::uint_parser;
- unsigned int u;
-
- uint_parser<unsigned int, 6, 1, -1> base6_parser;
-
- BOOST_TEST(test("13032030", base6_parser));
- BOOST_TEST(test_attr("13032030", base6_parser, u));
- BOOST_TEST(424242 == u);
-
- BOOST_TEST(!test("3456", base6_parser));
- BOOST_TEST(!test_attr("3456", base6_parser, u));
-
- char const* max_unsigned_base6 = "1550104015503";
- char const* unsigned_overflow_base6 = "1550104015504";
- char const* digit_overflow_base6 = "15501040155030";
-
- BOOST_TEST(test(max_unsigned_base6, base6_parser));
- BOOST_TEST(test_attr(max_unsigned_base6, base6_parser, u));
-
- BOOST_TEST(!test(unsigned_overflow_base6, base6_parser));
- BOOST_TEST(!test_attr(unsigned_overflow_base6, base6_parser, u));
- BOOST_TEST(!test(digit_overflow_base6, base6_parser));
- BOOST_TEST(!test_attr(digit_overflow_base6, base6_parser, u));
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // arbitrary radix test (base 7)
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::uint_;
- using boost::spirit::qi::uint_parser;
- unsigned int u;
-
- uint_parser<unsigned int, 7, 1, -1> base7_parser;
-
- BOOST_TEST(test("3414600", base7_parser));
- BOOST_TEST(test_attr("3414600", base7_parser, u));
- BOOST_TEST(424242 == u);
-
- BOOST_TEST(!test("4567", base7_parser));
- BOOST_TEST(!test_attr("4567", base7_parser, u));
-
- char const* max_unsigned_base7 = "211301422353";
- char const* unsigned_overflow_base7 = "211301422354";
- char const* digit_overflow_base7 = "2113014223530";
-
- BOOST_TEST(test(max_unsigned_base7, base7_parser));
- BOOST_TEST(test_attr(max_unsigned_base7, base7_parser, u));
-
- BOOST_TEST(!test(unsigned_overflow_base7, base7_parser));
- BOOST_TEST(!test_attr(unsigned_overflow_base7, base7_parser, u));
- BOOST_TEST(!test(digit_overflow_base7, base7_parser));
- BOOST_TEST(!test_attr(digit_overflow_base7, base7_parser, u));
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // arbitrary radix test (base 7)
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::uint_;
- using boost::spirit::qi::uint_parser;
- unsigned int u;
-
- uint_parser<unsigned int, 9, 1, -1> base9_parser;
-
- BOOST_TEST(test("715850", base9_parser));
- BOOST_TEST(test_attr("715850", base9_parser, u));
- BOOST_TEST(424242 == u);
-
- BOOST_TEST(!test("6789", base9_parser));
- BOOST_TEST(!test_attr("6789", base9_parser, u));
-
- char const* max_unsigned_base9 = "12068657453";
- char const* unsigned_overflow_base9 = "12068657454";
- char const* digit_overflow_base9 = "120686574530";
-
- BOOST_TEST(test(max_unsigned_base9, base9_parser));
- BOOST_TEST(test_attr(max_unsigned_base9, base9_parser, u));
-
- BOOST_TEST(!test(unsigned_overflow_base9, base9_parser));
- BOOST_TEST(!test_attr(unsigned_overflow_base9, base9_parser, u));
- BOOST_TEST(!test(digit_overflow_base9, base9_parser));
- BOOST_TEST(!test_attr(digit_overflow_base9, base9_parser, u));
- }
-
- return boost::report_errors();
-}
Added: trunk/libs/spirit/test/qi/uint_radix.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/uint_radix.cpp 2011-04-16 22:55:36 EDT (Sat, 16 Apr 2011)
@@ -0,0 +1,746 @@
+/*=============================================================================
+ Copyright (c) 2011 Jan Frederick Eick
+
+ 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)
+=============================================================================*/
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/support_argument.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+
+#include <climits>
+#include <cstring>
+#include "test.hpp"
+
+#include "uint_radix.hpp"
+
+int
+main()
+{
+ using spirit_test::test;
+ using spirit_test::test_attr;
+
+ using boost::spirit::qi::uint_;
+ using boost::spirit::qi::uint_parser;
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 3)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 3, 1, -1> base3_parser;
+
+ BOOST_TEST(test("210112221200", base3_parser));
+ BOOST_TEST(test_attr("210112221200", base3_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("1231", base3_parser));
+ BOOST_TEST(!test_attr("1231", base3_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base3, base3_parser));
+ BOOST_TEST(test_attr(max_unsigned_base3, base3_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base3, base3_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base3, base3_parser, u));
+ BOOST_TEST(!test(digit_overflow_base3, base3_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base3, base3_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 4)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+
+ uint_parser<unsigned int, 4, 1, -1> base4_parser;
+
+ BOOST_TEST(test("1213210302", base4_parser));
+ BOOST_TEST(test_attr("1213210302", base4_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("1234", base4_parser));
+ BOOST_TEST(!test_attr("1234", base4_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base4, base4_parser));
+ BOOST_TEST(test_attr(max_unsigned_base4, base4_parser, u));
+ BOOST_TEST(!test(digit_overflow_base4, base4_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base4, base4_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 5)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+
+ uint_parser<unsigned int, 5, 1, -1> base5_parser;
+
+ BOOST_TEST(test("102033432", base5_parser));
+ BOOST_TEST(test_attr("102033432", base5_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("2345", base5_parser));
+ BOOST_TEST(!test_attr("2345", base5_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base5, base5_parser));
+ BOOST_TEST(test_attr(max_unsigned_base5, base5_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base5, base5_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base5, base5_parser, u));
+ BOOST_TEST(!test(digit_overflow_base5, base5_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base5, base5_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 6)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+
+ uint_parser<unsigned int, 6, 1, -1> base6_parser;
+
+ BOOST_TEST(test("13032030", base6_parser));
+ BOOST_TEST(test_attr("13032030", base6_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("3456", base6_parser));
+ BOOST_TEST(!test_attr("3456", base6_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base6, base6_parser));
+ BOOST_TEST(test_attr(max_unsigned_base6, base6_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base6, base6_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base6, base6_parser, u));
+ BOOST_TEST(!test(digit_overflow_base6, base6_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base6, base6_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 7)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+
+ uint_parser<unsigned int, 7, 1, -1> base7_parser;
+
+ BOOST_TEST(test("3414600", base7_parser));
+ BOOST_TEST(test_attr("3414600", base7_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("4567", base7_parser));
+ BOOST_TEST(!test_attr("4567", base7_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base7, base7_parser));
+ BOOST_TEST(test_attr(max_unsigned_base7, base7_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base7, base7_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base7, base7_parser, u));
+ BOOST_TEST(!test(digit_overflow_base7, base7_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base7, base7_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 9)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+
+ uint_parser<unsigned int, 9, 1, -1> base9_parser;
+
+ BOOST_TEST(test("715850", base9_parser));
+ BOOST_TEST(test_attr("715850", base9_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("6789", base9_parser));
+ BOOST_TEST(!test_attr("6789", base9_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base9, base9_parser));
+ BOOST_TEST(test_attr(max_unsigned_base9, base9_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base9, base9_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base9, base9_parser, u));
+ BOOST_TEST(!test(digit_overflow_base9, base9_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base9, base9_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 11)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+
+ uint_parser<unsigned int, 11, 1, -1> base11_parser;
+
+ BOOST_TEST(test("26a815", base11_parser));
+ BOOST_TEST(test_attr("26a815", base11_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("90ab", base11_parser));
+ BOOST_TEST(!test_attr("90AB", base11_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base11, base11_parser));
+ BOOST_TEST(test_attr(max_unsigned_base11, base11_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base11, base11_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base11, base11_parser, u));
+ BOOST_TEST(!test(digit_overflow_base11, base11_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base11, base11_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 12)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 12, 1, -1> base12_parser;
+
+ BOOST_TEST(test("185616", base12_parser));
+ BOOST_TEST(test_attr("185616", base12_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("9abc", base12_parser));
+ BOOST_TEST(!test_attr("9ABC", base12_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base12, base12_parser));
+ BOOST_TEST(test_attr(max_unsigned_base12, base12_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base12, base12_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base12, base12_parser, u));
+ BOOST_TEST(!test(digit_overflow_base12, base12_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base12, base12_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 13)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 13, 1, -1> base13_parser;
+
+ BOOST_TEST(test("11b140", base13_parser));
+ BOOST_TEST(test_attr("11b140", base13_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("abcd", base13_parser));
+ BOOST_TEST(!test_attr("ABCD", base13_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base13, base13_parser));
+ BOOST_TEST(test_attr(max_unsigned_base13, base13_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base13, base13_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base13, base13_parser, u));
+ BOOST_TEST(!test(digit_overflow_base13, base13_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base13, base13_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 14)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 14, 1, -1> base14_parser;
+
+ BOOST_TEST(test("b0870", base14_parser));
+ BOOST_TEST(test_attr("b0870", base14_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("bcde", base14_parser));
+ BOOST_TEST(!test_attr("BCDE", base14_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base14, base14_parser));
+ BOOST_TEST(test_attr(max_unsigned_base14, base14_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base14, base14_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base14, base14_parser, u));
+ BOOST_TEST(!test(digit_overflow_base14, base14_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base14, base14_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 15)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 15, 1, -1> base15_parser;
+
+ BOOST_TEST(test("85a7c", base15_parser));
+ BOOST_TEST(test_attr("85a7c", base15_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("cdef", base15_parser));
+ BOOST_TEST(!test_attr("CDEF", base15_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base15, base15_parser));
+ BOOST_TEST(test_attr(max_unsigned_base15, base15_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base15, base15_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base15, base15_parser, u));
+ BOOST_TEST(!test(digit_overflow_base15, base15_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base15, base15_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 17)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 17, 1, -1> base17_parser;
+
+ BOOST_TEST(test("515g7", base17_parser));
+ BOOST_TEST(test_attr("515g7", base17_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("efgh", base17_parser));
+ BOOST_TEST(!test_attr("EFGH", base17_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base17, base17_parser));
+ BOOST_TEST(test_attr(max_unsigned_base17, base17_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base17, base17_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base17, base17_parser, u));
+ BOOST_TEST(!test(digit_overflow_base17, base17_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base17, base17_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 18)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 18, 1, -1> base18_parser;
+
+ BOOST_TEST(test("40d70", base18_parser));
+ BOOST_TEST(test_attr("40d70", base18_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("fghi", base18_parser));
+ BOOST_TEST(!test_attr("FGHI", base18_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base18, base18_parser));
+ BOOST_TEST(test_attr(max_unsigned_base18, base18_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base18, base18_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base18, base18_parser, u));
+ BOOST_TEST(!test(digit_overflow_base18, base18_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base18, base18_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 19)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 19, 1, -1> base19_parser;
+
+ BOOST_TEST(test("34g3a", base19_parser));
+ BOOST_TEST(test_attr("34g3a", base19_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("ghij", base19_parser));
+ BOOST_TEST(!test_attr("GHIJ", base19_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base19, base19_parser));
+ BOOST_TEST(test_attr(max_unsigned_base19, base19_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base19, base19_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base19, base19_parser, u));
+ BOOST_TEST(!test(digit_overflow_base19, base19_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base19, base19_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 20)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 20, 1, -1> base20_parser;
+
+ BOOST_TEST(test("2d0c2", base20_parser));
+ BOOST_TEST(test_attr("2d0c2", base20_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("hijk", base20_parser));
+ BOOST_TEST(!test_attr("HIJK", base20_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base20, base20_parser));
+ BOOST_TEST(test_attr(max_unsigned_base20, base20_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base20, base20_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base20, base20_parser, u));
+ BOOST_TEST(!test(digit_overflow_base20, base20_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base20, base20_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 21)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 21, 1, -1> base21_parser;
+
+ BOOST_TEST(test("23h00", base21_parser));
+ BOOST_TEST(test_attr("23h00", base21_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("ijkl", base21_parser));
+ BOOST_TEST(!test_attr("IJKL", base21_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base21, base21_parser));
+ BOOST_TEST(test_attr(max_unsigned_base21, base21_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base21, base21_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base21, base21_parser, u));
+ BOOST_TEST(!test(digit_overflow_base21, base21_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base21, base21_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 22)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 22, 1, -1> base22_parser;
+
+ BOOST_TEST(test("1hibg", base22_parser));
+ BOOST_TEST(test_attr("1hibg", base22_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("jklm", base22_parser));
+ BOOST_TEST(!test_attr("JKLM", base22_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base22, base22_parser));
+ BOOST_TEST(test_attr(max_unsigned_base22, base22_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base22, base22_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base22, base22_parser, u));
+ BOOST_TEST(!test(digit_overflow_base22, base22_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base22, base22_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 23)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 23, 1, -1> base23_parser;
+
+ BOOST_TEST(test("1bjm7", base23_parser));
+ BOOST_TEST(test_attr("1bjm7", base23_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("klmn", base23_parser));
+ BOOST_TEST(!test_attr("KLMN", base23_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base23, base23_parser));
+ BOOST_TEST(test_attr(max_unsigned_base23, base23_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base23, base23_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base23, base23_parser, u));
+ BOOST_TEST(!test(digit_overflow_base23, base23_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base23, base23_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 24)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 24, 1, -1> base24_parser;
+
+ BOOST_TEST(test("16gci", base24_parser));
+ BOOST_TEST(test_attr("16gci", base24_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("lmno", base24_parser));
+ BOOST_TEST(!test_attr("LMNO", base24_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base24, base24_parser));
+ BOOST_TEST(test_attr(max_unsigned_base24, base24_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base24, base24_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base24, base24_parser, u));
+ BOOST_TEST(!test(digit_overflow_base24, base24_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base24, base24_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 25)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 25, 1, -1> base25_parser;
+
+ BOOST_TEST(test("123jh", base25_parser));
+ BOOST_TEST(test_attr("123jh", base25_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("mnop", base25_parser));
+ BOOST_TEST(!test_attr("MNOP", base25_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base25, base25_parser));
+ BOOST_TEST(test_attr(max_unsigned_base25, base25_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base25, base25_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base25, base25_parser, u));
+ BOOST_TEST(!test(digit_overflow_base25, base25_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base25, base25_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 26)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 26, 1, -1> base26_parser;
+
+ BOOST_TEST(test("o3f0", base26_parser));
+ BOOST_TEST(test_attr("o3f0", base26_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("nopq", base26_parser));
+ BOOST_TEST(!test_attr("NOPQ", base26_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base26, base26_parser));
+ BOOST_TEST(test_attr(max_unsigned_base26, base26_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base26, base26_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base26, base26_parser, u));
+ BOOST_TEST(!test(digit_overflow_base26, base26_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base26, base26_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 27)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 27, 1, -1> base27_parser;
+
+ BOOST_TEST(test("lepi", base27_parser));
+ BOOST_TEST(test_attr("lepi", base27_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("opqr", base27_parser));
+ BOOST_TEST(!test_attr("OPQR", base27_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base27, base27_parser));
+ BOOST_TEST(test_attr(max_unsigned_base27, base27_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base27, base27_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base27, base27_parser, u));
+ BOOST_TEST(!test(digit_overflow_base27, base27_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base27, base27_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 28)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 28, 1, -1> base28_parser;
+
+ BOOST_TEST(test("j93e", base28_parser));
+ BOOST_TEST(test_attr("j93e", base28_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("pqrs", base28_parser));
+ BOOST_TEST(!test_attr("PQRS", base28_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base28, base28_parser));
+ BOOST_TEST(test_attr(max_unsigned_base28, base28_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base28, base28_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base28, base28_parser, u));
+ BOOST_TEST(!test(digit_overflow_base28, base28_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base28, base28_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 29)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 29, 1, -1> base29_parser;
+
+ BOOST_TEST(test("hbd1", base29_parser));
+ BOOST_TEST(test_attr("hbd1", base29_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("qrst", base29_parser));
+ BOOST_TEST(!test_attr("QRST", base29_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base29, base29_parser));
+ BOOST_TEST(test_attr(max_unsigned_base29, base29_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base29, base29_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base29, base29_parser, u));
+ BOOST_TEST(!test(digit_overflow_base29, base29_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base29, base29_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 30)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 30, 1, -1> base30_parser;
+
+ BOOST_TEST(test("flbc", base30_parser));
+ BOOST_TEST(test_attr("flbc", base30_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("rstu", base30_parser));
+ BOOST_TEST(!test_attr("RSTU", base30_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base30, base30_parser));
+ BOOST_TEST(test_attr(max_unsigned_base30, base30_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base30, base30_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base30, base30_parser, u));
+ BOOST_TEST(!test(digit_overflow_base30, base30_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base30, base30_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 31)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 31, 1, -1> base31_parser;
+
+ BOOST_TEST(test("e7e7", base31_parser));
+ BOOST_TEST(test_attr("e7e7", base31_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("stuv", base31_parser));
+ BOOST_TEST(!test_attr("STUV", base31_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base31, base31_parser));
+ BOOST_TEST(test_attr(max_unsigned_base31, base31_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base31, base31_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base31, base31_parser, u));
+ BOOST_TEST(!test(digit_overflow_base31, base31_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base31, base31_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 32)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 32, 1, -1> base32_parser;
+
+ BOOST_TEST(test("cu9i", base32_parser));
+ BOOST_TEST(test_attr("cu9i", base32_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("tuvw", base32_parser));
+ BOOST_TEST(!test_attr("TUVW", base32_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base32, base32_parser));
+ BOOST_TEST(test_attr(max_unsigned_base32, base32_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base32, base32_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base32, base32_parser, u));
+ BOOST_TEST(!test(digit_overflow_base32, base32_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base32, base32_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 33)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 33, 1, -1> base33_parser;
+
+ BOOST_TEST(test("bqir", base33_parser));
+ BOOST_TEST(test_attr("bqir", base33_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("uvwx", base33_parser));
+ BOOST_TEST(!test_attr("UVWX", base33_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base33, base33_parser));
+ BOOST_TEST(test_attr(max_unsigned_base33, base33_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base33, base33_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base33, base33_parser, u));
+ BOOST_TEST(!test(digit_overflow_base33, base33_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base33, base33_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 34)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 34, 1, -1> base34_parser;
+
+ BOOST_TEST(test("aqxo", base34_parser));
+ BOOST_TEST(test_attr("aqxo", base34_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("vwxy", base34_parser));
+ BOOST_TEST(!test_attr("VWXY", base34_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base34, base34_parser));
+ BOOST_TEST(test_attr(max_unsigned_base34, base34_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base34, base34_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base34, base34_parser, u));
+ BOOST_TEST(!test(digit_overflow_base34, base34_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base34, base34_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 35)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 35, 1, -1> base35_parser;
+
+ BOOST_TEST(test("9vb7", base35_parser));
+ BOOST_TEST(test_attr("9vb7", base35_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(!test("wxyz", base35_parser));
+ BOOST_TEST(!test_attr("WXYZ", base35_parser, u));
+
+ BOOST_TEST(test(max_unsigned_base35, base35_parser));
+ BOOST_TEST(test_attr(max_unsigned_base35, base35_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base35, base35_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base35, base35_parser, u));
+ BOOST_TEST(!test(digit_overflow_base35, base35_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base35, base35_parser, u));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // arbitrary radix test (base 36)
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ unsigned int u;
+ uint_parser<unsigned int, 36, 1, -1> base36_parser;
+
+ BOOST_TEST(test("93ci", base36_parser));
+ BOOST_TEST(test_attr("93ci", base36_parser, u));
+ BOOST_TEST(424242 == u);
+
+ BOOST_TEST(test(max_unsigned_base36, base36_parser));
+ BOOST_TEST(test_attr(max_unsigned_base36, base36_parser, u));
+
+ BOOST_TEST(!test(unsigned_overflow_base36, base36_parser));
+ BOOST_TEST(!test_attr(unsigned_overflow_base36, base36_parser, u));
+ BOOST_TEST(!test(digit_overflow_base36, base36_parser));
+ BOOST_TEST(!test_attr(digit_overflow_base36, base36_parser, u));
+ }
+
+ return boost::report_errors();
+}
Added: trunk/libs/spirit/test/qi/uint_radix.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/uint_radix.hpp 2011-04-16 22:55:36 EDT (Sat, 16 Apr 2011)
@@ -0,0 +1,142 @@
+/*=============================================================================
+ Copyright (c) 2011 Jan Frederick Eick
+
+ 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)
+=============================================================================*/
+
+#if !defined(BOOST_SPIRIT_TEST_QI_UINT4_HPP)
+#define BOOST_SPIRIT_TEST_QI_UINT4_HPP
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// *** BEWARE PLATFORM DEPENDENT!!! ***
+// *** The following assumes 32 bit integers and 64 bit long longs.
+// *** Modify these constant strings when appropriate.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+char const* max_unsigned_base3 = "102002022201221111210";
+char const* unsigned_overflow_base3 = "102002022201221111211";
+char const* digit_overflow_base3 = "1020020222012211112100";
+
+char const* max_unsigned_base4 = "3333333333333333";
+char const* digit_overflow_base4 = "33333333333333330";
+
+char const* max_unsigned_base5 = "32244002423140";
+char const* unsigned_overflow_base5 = "32244002423141";
+char const* digit_overflow_base5 = "322440024231400";
+
+char const* max_unsigned_base6 = "1550104015503";
+char const* unsigned_overflow_base6 = "1550104015504";
+char const* digit_overflow_base6 = "15501040155030";
+
+char const* max_unsigned_base7 = "211301422353";
+char const* unsigned_overflow_base7 = "211301422354";
+char const* digit_overflow_base7 = "2113014223530";
+
+char const* max_unsigned_base9 = "12068657453";
+char const* unsigned_overflow_base9 = "12068657454";
+char const* digit_overflow_base9 = "120686574530";
+
+char const* max_unsigned_base11 = "1904440553";
+char const* unsigned_overflow_base11 = "1904440554";
+char const* digit_overflow_base11 = "19044405530";
+
+char const* max_unsigned_base12 = "9BA461593";
+char const* unsigned_overflow_base12 = "9BA461594";
+char const* digit_overflow_base12 = "9BA4615930";
+
+char const* max_unsigned_base13 = "535A79888";
+char const* unsigned_overflow_base13 = "535A79889";
+char const* digit_overflow_base13 = "535A798880";
+
+char const* max_unsigned_base14 = "2CA5B7463";
+char const* unsigned_overflow_base14 = "2CA5B7464";
+char const* digit_overflow_base14 = "2CA5B74630";
+
+char const* max_unsigned_base15 = "1A20DCD80";
+char const* unsigned_overflow_base15 = "1A20DCD81";
+char const* digit_overflow_base15 = "1A20DCD800";
+
+char const* max_unsigned_base17 = "A7FFDA90";
+char const* unsigned_overflow_base17 = "A7FFDA91";
+char const* digit_overflow_base17 = "A7FFDA900";
+
+char const* max_unsigned_base18 = "704HE7G3";
+char const* unsigned_overflow_base18 = "704HE7G4";
+char const* digit_overflow_base18 = "704HE7G30";
+
+char const* max_unsigned_base19 = "4F5AFF65";
+char const* unsigned_overflow_base19 = "4F5AFF66";
+char const* digit_overflow_base19 = "4F5AFF650";
+
+char const* max_unsigned_base20 = "3723AI4F";
+char const* unsigned_overflow_base20 = "3723AI4G";
+char const* digit_overflow_base20 = "3723AI4G0";
+
+char const* max_unsigned_base21 = "281D55I3";
+char const* unsigned_overflow_base21 = "281D55I4";
+char const* digit_overflow_base21 = "281D55I30";
+
+char const* max_unsigned_base22 = "1FJ8B183";
+char const* unsigned_overflow_base22 = "1FJ8B184";
+char const* digit_overflow_base22 = "1FJ8B1830";
+
+char const* max_unsigned_base23 = "1606K7IB";
+char const* unsigned_overflow_base23 = "1606K7IC";
+char const* digit_overflow_base23 = "1606K7IB0";
+
+char const* max_unsigned_base24 = "MB994AF";
+char const* unsigned_overflow_base24 = "MB994AG";
+char const* digit_overflow_base24 = "MB994AF0";
+
+char const* max_unsigned_base25 = "HEK2MGK";
+char const* unsigned_overflow_base25 = "HEK2MGL";
+char const* digit_overflow_base25 = "HEK2MGK0";
+
+char const* max_unsigned_base26 = "DNCHBNL";
+char const* unsigned_overflow_base26 = "DNCHBNM";
+char const* digit_overflow_base26 = "DNCHBNL0";
+
+char const* max_unsigned_base27 = "B28JPDL";
+char const* unsigned_overflow_base27 = "B28JPDM";
+char const* digit_overflow_base27 = "B28JPDL0";
+
+char const* max_unsigned_base28 = "8PFGIH3";
+char const* unsigned_overflow_base28 = "8PFGIH4";
+char const* digit_overflow_base28 = "8PFGIH30";
+
+char const* max_unsigned_base29 = "76BEIGF";
+char const* unsigned_overflow_base29 = "76BEIGH";
+char const* digit_overflow_base29 = "76BEIGF0";
+
+char const* max_unsigned_base30 = "5QMCPQF";
+char const* unsigned_overflow_base30 = "5QMCPQG";
+char const* digit_overflow_base30 = "5QMCPQF0";
+
+char const* max_unsigned_base31 = "4Q0JTO3";
+char const* unsigned_overflow_base31 = "4Q0JTO4";
+char const* digit_overflow_base31 = "4Q0JTO30";
+
+char const* max_unsigned_base32 = "3VVVVVV";
+char const* unsigned_overflow_base32 = "3VVVVVW";
+char const* digit_overflow_base32 = "3VVVVVV0";
+
+char const* max_unsigned_base33 = "3AOKQ93";
+char const* unsigned_overflow_base33 = "3AOKQ94";
+char const* digit_overflow_base33 = "3AOKQ930";
+
+char const* max_unsigned_base34 = "2QHXJLH";
+char const* unsigned_overflow_base34 = "2QHXJLI";
+char const* digit_overflow_base34 = "2QHXJLH0";
+
+char const* max_unsigned_base35 = "2BR45QA";
+char const* unsigned_overflow_base35 = "2BR45QB";
+char const* digit_overflow_base35 = "2BR45QA0";
+
+char const* max_unsigned_base36 = "1Z141Z3";
+char const* unsigned_overflow_base36 = "1Z141Z4";
+char const* digit_overflow_base36 = "1Z141Z30";
+
+#endif
\ 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