1 /*============================================================================= 2 Copyright (c) 2001-2011 Joel de Guzman 3 Copyright (c) 2001-2011 Hartmut Kaiser 4 Copyright (c) 2011 Bryce Lelbach 5 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 11 12 #include <climits> 13 #include <boost/detail/lightweight_test.hpp> 14 #include <boost/spirit/include/qi_numeric.hpp> 15 #include <boost/spirit/include/qi_char.hpp> 16 #include <boost/spirit/include/qi_action.hpp> 17 #include <boost/spirit/include/support_argument.hpp> 18 #include <boost/spirit/include/phoenix_core.hpp> 19 #include <boost/spirit/include/phoenix_operator.hpp> 20 21 #include "test.hpp" 22 #include <cstring> 23 24 /////////////////////////////////////////////////////////////////////////////// 25 // 26 // *** BEWARE PLATFORM DEPENDENT!!! *** 27 // *** The following assumes 32 bit integers and 64 bit long longs. 28 // *** Modify these constant strings when appropriate. 29 // 30 /////////////////////////////////////////////////////////////////////////////// 31 32 char const* max_unsigned = "4294967295"; 33 char const* unsigned_overflow = "4294967296"; 34 char const* max_int = "2147483647"; 35 char const* int_overflow = "2147483648"; 36 char const* min_int = "-2147483648"; 37 char const* int_underflow = "-2147483649"; 38 char const* max_binary = "11111111111111111111111111111111"; 39 char const* binary_overflow = "100000000000000000000000000000000"; 40 char const* max_octal = "37777777777"; 41 char const* octal_overflow = "100000000000"; 42 char const* max_hex = "FFFFFFFF"; 43 char const* hex_overflow = "100000000"; 44 45 /////////////////////////////////////////////////////////////////////////////// 46 // A custom int type 47 struct custom_uint 48 { 49 unsigned n; custom_uintcustom_uint50 custom_uint() : n(0) {} custom_uintcustom_uint51 explicit custom_uint(unsigned n_) : n(n_) {} operator =custom_uint52 custom_uint& operator=(unsigned n_) { n = n_; return *this; } operator ==(custom_uint a,custom_uint b)53 friend bool operator==(custom_uint a, custom_uint b) 54 { return a.n == b.n; } operator ==(custom_uint a,unsigned b)55 friend bool operator==(custom_uint a, unsigned b) 56 { return a.n == b; } operator *(custom_uint a,custom_uint b)57 friend custom_uint operator*(custom_uint a, custom_uint b) 58 { return custom_uint(a.n * b.n); } operator +(custom_uint a,custom_uint b)59 friend custom_uint operator+(custom_uint a, custom_uint b) 60 { return custom_uint(a.n + b.n); } 61 }; 62 63 #endif 64 65