1 /*=============================================================================
2 Copyright (c) 2001-2012 Joel de Guzman
3 Copyright (c) 2001-2011 Hartmut Kaiser
4 Copyright (c) 2011 Bryce Lelbach
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #if !defined(BOOST_SPIRIT_TEST_QI_UINT_HPP)
10 #define BOOST_SPIRIT_TEST_QI_UINT_HPP
13 #include <boost/detail/lightweight_test.hpp>
14 #include <boost/spirit/home/x3.hpp>
19 ///////////////////////////////////////////////////////////////////////////////
21 // *** BEWARE PLATFORM DEPENDENT!!! ***
22 // *** The following assumes 32 bit integers and 64 bit long longs.
23 // *** Modify these constant strings when appropriate.
25 ///////////////////////////////////////////////////////////////////////////////
27 char const* max_unsigned = "4294967295";
28 char const* unsigned_overflow = "4294967296";
29 char const* max_int = "2147483647";
30 char const* int_overflow = "2147483648";
31 char const* min_int = "-2147483648";
32 char const* int_underflow = "-2147483649";
33 char const* max_binary = "11111111111111111111111111111111";
34 char const* binary_overflow = "100000000000000000000000000000000";
35 char const* max_octal = "37777777777";
36 char const* octal_overflow = "100000000000";
37 char const* max_hex = "FFFFFFFF";
38 char const* hex_overflow = "100000000";
40 ///////////////////////////////////////////////////////////////////////////////
45 custom_uint() : n(0) {}
46 explicit custom_uint(unsigned n_) : n(n_) {}
47 custom_uint& operator=(unsigned n_) { n = n_; return *this; }
48 friend bool operator==(custom_uint a, custom_uint b)
49 { return a.n == b.n; }
50 friend bool operator==(custom_uint a, unsigned b)
52 friend custom_uint operator*(custom_uint a, custom_uint b)
53 { return custom_uint(a.n * b.n); }
54 friend custom_uint operator+(custom_uint a, custom_uint b)
55 { return custom_uint(a.n + b.n); }