|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50456 - in branches/release/libs: array array/test crc crc/test functional functional/test integer integer/test preprocessor/test rational rational/test timer timer/test
From: Boris.Gubenko_at_[hidden]
Date: 2009-01-04 00:17:06
Author: bgubenko
Date: 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
New Revision: 50456
URL: http://svn.boost.org/trac/boost/changeset/50456
Log:
merge tests and Jamfiles for 7 libraries
Added:
branches/release/libs/array/test/
branches/release/libs/array/test/Jamfile.v2 (contents, props changed)
branches/release/libs/array/test/array0.cpp
- copied unchanged from r50455, /branches/release/libs/array/array0.cpp
branches/release/libs/array/test/array1.cpp
- copied unchanged from r50455, /branches/release/libs/array/array1.cpp
branches/release/libs/array/test/array2.cpp
- copied unchanged from r50455, /branches/release/libs/array/array2.cpp
branches/release/libs/array/test/array3.cpp
- copied unchanged from r50455, /branches/release/libs/array/array3.cpp
branches/release/libs/array/test/array4.cpp
- copied unchanged from r50455, /branches/release/libs/array/array4.cpp
branches/release/libs/array/test/array5.cpp
- copied unchanged from r50455, /branches/release/libs/array/array5.cpp
branches/release/libs/array/test/print.hpp
- copied unchanged from r50455, /branches/release/libs/array/print.hpp
branches/release/libs/crc/test/
branches/release/libs/crc/test/Jamfile.v2 (contents, props changed)
branches/release/libs/crc/test/crc_test.cpp
- copied unchanged from r50455, /branches/release/libs/crc/crc_test.cpp
branches/release/libs/functional/test/
branches/release/libs/functional/test/Jamfile.v2 (contents, props changed)
branches/release/libs/functional/test/function_test.cpp
- copied unchanged from r50455, /branches/release/libs/functional/function_test.cpp
branches/release/libs/integer/test/Jamfile.v2 (contents, props changed)
branches/release/libs/integer/test/cstdint_test.cpp
- copied unchanged from r50455, /branches/release/libs/integer/cstdint_test.cpp
branches/release/libs/integer/test/integer_test.cpp
- copied unchanged from r50455, /branches/release/libs/integer/integer_test.cpp
branches/release/libs/integer/test/integer_traits_test.cpp
- copied unchanged from r50455, /branches/release/libs/integer/integer_traits_test.cpp
branches/release/libs/preprocessor/test/Jamfile.v2 (contents, props changed)
branches/release/libs/rational/test/
branches/release/libs/rational/test/Jamfile.v2 (contents, props changed)
branches/release/libs/rational/test/rational_example.cpp
- copied unchanged from r50455, /branches/release/libs/rational/rational_example.cpp
branches/release/libs/rational/test/rational_test.cpp
- copied unchanged from r50455, /branches/release/libs/rational/rational_test.cpp
branches/release/libs/timer/test/
branches/release/libs/timer/test/Jamfile.v2 (contents, props changed)
branches/release/libs/timer/test/timer_test.cpp
- copied unchanged from r50455, /branches/release/libs/timer/timer_test.cpp
Removed:
branches/release/libs/array/array0.cpp
branches/release/libs/array/array1.cpp
branches/release/libs/array/array2.cpp
branches/release/libs/array/array3.cpp
branches/release/libs/array/array4.cpp
branches/release/libs/array/array5.cpp
branches/release/libs/array/print.hpp
branches/release/libs/crc/crc_test.cpp
branches/release/libs/functional/function_test.cpp
branches/release/libs/integer/cstdint_test.cpp
branches/release/libs/integer/integer_test.cpp
branches/release/libs/integer/integer_traits_test.cpp
branches/release/libs/rational/rational_example.cpp
branches/release/libs/rational/rational_test.cpp
branches/release/libs/timer/timer_test.cpp
Deleted: branches/release/libs/array/array0.cpp
==============================================================================
--- branches/release/libs/array/array0.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,107 +0,0 @@
-/* tests for using class array<> specialization for size 0
- * (C) Copyright Alisdair Meredith 2006.
- * 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 <string>
-#include <iostream>
-#include <boost/array.hpp>
-
-namespace {
-unsigned int failed_tests = 0;
-
-void fail_test( const char * reason ) {
- ++failed_tests;
- std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl;
-}
-
-template< class T >
-void BadValue( const T & )
-{
- fail_test( "Unexpected value" );
-}
-
-template< class T >
-void RunTests()
-{
- typedef boost::array< T, 0 > test_type;
-
- // Test value and aggegrate initialization
- test_type test_case = {};
- const boost::array< T, 0 > const_test_case = test_type();
-
- test_case.assign( T() );
-
- // front/back and operator[] must compile, but calling them is undefined
- // Likewise, all tests below should evaluate to false, avoiding undefined behaviour
- if( !test_case.empty() ) {
- BadValue( test_case.front() );
- }
-
- if( !const_test_case.empty() ) {
- BadValue( const_test_case.back() );
- }
-
- if( test_case.size() > 0 ) {
- BadValue( test_case[ 0 ] );
- }
-
- if( const_test_case.max_size() > 0 ) {
- BadValue( const_test_case[ 0 ] );
- }
-
- // Assert requirements of TR1 6.2.2.4
- if( test_case.begin() != test_case.end() ) {
- fail_test( "Not an empty range" );
- }
- if( const_test_case.begin() != const_test_case.end() ) {
- fail_test( "Not an empty range" );
- }
-
- if( test_case.begin() == const_test_case.begin() ) {
- fail_test( "iterators for different containers are not distinct" );
- }
-
- if( test_case.data() == const_test_case.data() ) {
- // Value of data is unspecified in TR1, so no requirement this test pass or fail
- // However, it must compile!
- }
-
-
- // Check can safely use all iterator types with std algorithms
- std::for_each( test_case.begin(), test_case.end(), BadValue< T > );
- std::for_each( test_case.rbegin(), test_case.rend(), BadValue< T > );
- std::for_each( const_test_case.begin(), const_test_case.end(), BadValue< T > );
- std::for_each( const_test_case.rbegin(), const_test_case.rend(), BadValue< T > );
-
- // Check swap is well formed
- std::swap( test_case, test_case );
-
- // Check assigment operator and overloads are well formed
- test_case = const_test_case;
-
- // Confirm at() throws the std lib defined exception
- try {
- BadValue( test_case.at( 0 ) );
- } catch ( const std::out_of_range & ) {
- }
-
- try {
- BadValue( const_test_case.at( 0 ) );
- } catch ( const std::out_of_range & ) {
- }
-}
-
-}
-
-int main()
-{
- RunTests< bool >();
- RunTests< void * >();
- RunTests< long double >();
- RunTests< std::string >();
- return failed_tests;
-}
-
Deleted: branches/release/libs/array/array1.cpp
==============================================================================
--- branches/release/libs/array/array1.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,58 +0,0 @@
-/* simple example for using class array<>
- *
- * (C) Copyright Nicolai M. Josuttis 2001.
- * 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)
- *
- * Changelog:
- * 20 Jan 2001 - Removed boolalpha use since stock GCC doesn't support it
- * (David Abrahams)
- */
-
-#include <iostream>
-#include <boost/array.hpp>
-
-int main()
-{
- // define special type name
- typedef boost::array<float,6> Array;
-
- // create and initialize an array
- Array a = { { 42 } };
-
- // access elements
- for (unsigned i=1; i<a.size(); ++i) {
- a[i] = a[i-1]+1;
- }
-
- // use some common STL container operations
- std::cout << "size: " << a.size() << std::endl;
- std::cout << "empty: " << (a.empty() ? "true" : "false") << std::endl;
- std::cout << "max_size: " << a.max_size() << std::endl;
- std::cout << "front: " << a.front() << std::endl;
- std::cout << "back: " << a.back() << std::endl;
- std::cout << "elems: ";
-
- // iterate through all elements
- for (Array::const_iterator pos=a.begin(); pos<a.end(); ++pos) {
- std::cout << *pos << ' ';
- }
- std::cout << std::endl;
-
- // check copy constructor and assignment operator
- Array b(a);
- Array c;
- c = a;
- if (a==b && a==c) {
- std::cout << "copy construction and copy assignment are OK"
- << std::endl;
- }
- else {
- std::cout << "copy construction and copy assignment FAILED"
- << std::endl;
- }
-
- return 0; // makes Visual-C++ compiler happy
-}
-
Deleted: branches/release/libs/array/array2.cpp
==============================================================================
--- branches/release/libs/array/array2.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,40 +0,0 @@
-/* example for using class array<>
- * (C) Copyright Nicolai M. Josuttis 2001.
- * 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 <algorithm>
-#include <functional>
-#include <boost/array.hpp>
-#include "print.hpp"
-using namespace std;
-using namespace boost;
-
-int main()
-{
- // create and initialize array
- array<int,10> a = { { 1, 2, 3, 4, 5 } };
-
- print_elements(a);
-
- // modify elements directly
- for (unsigned i=0; i<a.size(); ++i) {
- ++a[i];
- }
- print_elements(a);
-
- // change order using an STL algorithm
- reverse(a.begin(),a.end());
- print_elements(a);
-
- // negate elements using STL framework
- transform(a.begin(),a.end(), // source
- a.begin(), // destination
- negate<int>()); // operation
- print_elements(a);
-
- return 0; // makes Visual-C++ compiler happy
-}
-
Deleted: branches/release/libs/array/array3.cpp
==============================================================================
--- branches/release/libs/array/array3.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,55 +0,0 @@
-/* example for using class array<>
- * (C) Copyright Nicolai M. Josuttis 2001.
- * 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 <string>
-#include <iostream>
-#include <boost/array.hpp>
-
-template <class T>
-void print_elements (const T& x);
-
-int main()
-{
- // create array of four seasons
- boost::array<std::string,4> seasons = {
- { "spring", "summer", "autumn", "winter" }
- };
-
- // copy and change order
- boost::array<std::string,4> seasons_orig = seasons;
- for (unsigned i=seasons.size()-1; i>0; --i) {
- std::swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
- }
-
- std::cout << "one way: ";
- print_elements(seasons);
-
- // try swap()
- std::cout << "other way: ";
- std::swap(seasons,seasons_orig);
- print_elements(seasons);
-
- // try reverse iterators
- std::cout << "reverse: ";
- for (boost::array<std::string,4>::reverse_iterator pos
- =seasons.rbegin(); pos<seasons.rend(); ++pos) {
- std::cout << " " << *pos;
- }
- std::cout << std::endl;
-
- return 0; // makes Visual-C++ compiler happy
-}
-
-template <class T>
-void print_elements (const T& x)
-{
- for (unsigned i=0; i<x.size(); ++i) {
- std::cout << " " << x[i];
- }
- std::cout << std::endl;
-}
-
Deleted: branches/release/libs/array/array4.cpp
==============================================================================
--- branches/release/libs/array/array4.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,43 +0,0 @@
-/* example for using class array<>
- * (C) Copyright Nicolai M. Josuttis 2001.
- * 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 <algorithm>
-#include <functional>
-#include <string>
-#include <iostream>
-#include <boost/array.hpp>
-
-int main()
-{
- // array of arrays of seasons
- boost::array<boost::array<std::string,4>,2> seasons_i18n = {
- { { { "spring", "summer", "autumn", "winter", } },
- { { "Fruehling", "Sommer", "Herbst", "Winter" } }
- }
- };
-
- // for any array of seasons print seasons
- for (unsigned i=0; i<seasons_i18n.size(); ++i) {
- boost::array<std::string,4> seasons = seasons_i18n[i];
- for (unsigned j=0; j<seasons.size(); ++j) {
- std::cout << seasons[j] << " ";
- }
- std::cout << std::endl;
- }
-
- // print first element of first array
- std::cout << "first element of first array: "
- << seasons_i18n[0][0] << std::endl;
-
- // print last element of last array
- std::cout << "last element of last array: "
- << seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]
- << std::endl;
-
- return 0; // makes Visual-C++ compiler happy
-}
-
Deleted: branches/release/libs/array/array5.cpp
==============================================================================
--- branches/release/libs/array/array5.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,72 +0,0 @@
-/* simple example for using class array<>
- * (C) Copyright Nicolai M. Josuttis 2001.
- * 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 <iostream>
-#include <boost/array.hpp>
-
-template <typename T>
-void test_static_size (const T& cont)
-{
- int tmp[T::static_size];
- for (unsigned i=0; i<T::static_size; ++i) {
- tmp[i] = int(cont[i]);
- }
- for (unsigned j=0; j<T::static_size; ++j) {
- std::cout << tmp[j] << ' ';
- }
- std::cout << std::endl;
-}
-
-int main()
-{
- // define special type name
- typedef boost::array<float,6> Array;
-
- // create and initialize an array
- const Array a = { { 42.42 } };
-
- // use some common STL container operations
- std::cout << "static_size: " << a.size() << std::endl;
- std::cout << "size: " << a.size() << std::endl;
- // Can't use std::boolalpha because it isn't portable
- std::cout << "empty: " << (a.empty()? "true" : "false") << std::endl;
- std::cout << "max_size: " << a.max_size() << std::endl;
- std::cout << "front: " << a.front() << std::endl;
- std::cout << "back: " << a.back() << std::endl;
- std::cout << "[0]: " << a[0] << std::endl;
- std::cout << "elems: ";
-
- // iterate through all elements
- for (Array::const_iterator pos=a.begin(); pos<a.end(); ++pos) {
- std::cout << *pos << ' ';
- }
- std::cout << std::endl;
- test_static_size(a);
-
- // check copy constructor and assignment operator
- Array b(a);
- Array c;
- c = a;
- if (a==b && a==c) {
- std::cout << "copy construction and copy assignment are OK"
- << std::endl;
- }
- else {
- std::cout << "copy construction and copy assignment are BROKEN"
- << std::endl;
- }
-
- typedef boost::array<double,6> DArray;
- typedef boost::array<int,6> IArray;
- IArray ia = { { 1, 2, 3, 4, 5, 6 } } ; // extra braces silence GCC warning
- DArray da;
- da = ia;
- da.assign(42);
-
- return 0; // makes Visual-C++ compiler happy
-}
-
Deleted: branches/release/libs/array/print.hpp
==============================================================================
--- branches/release/libs/array/print.hpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,27 +0,0 @@
-/* The following code example is taken from the book
- * "The C++ Standard Library - A Tutorial and Reference"
- * by Nicolai M. Josuttis, Addison-Wesley, 1999
- *
- * (C) Copyright Nicolai M. Josuttis 1999.
- * 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 <iostream>
-
-/* print_elements()
- * - prints optional C-string optcstr followed by
- * - all elements of the collection coll
- * - separated by spaces
- */
-template <class T>
-inline void print_elements (const T& coll, const char* optcstr="")
-{
- typename T::const_iterator pos;
-
- std::cout << optcstr;
- for (pos=coll.begin(); pos!=coll.end(); ++pos) {
- std::cout << *pos << ' ';
- }
- std::cout << std::endl;
-}
Added: branches/release/libs/array/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/array/test/Jamfile.v2 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
@@ -0,0 +1,14 @@
+#~ Copyright Rene Rivera 2008
+#~ 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)
+
+import testing ;
+
+test-suite array :
+ [ run array0.cpp ]
+ [ run array1.cpp ]
+ [ run array2.cpp ]
+ [ run array3.cpp ]
+ [ run array4.cpp ]
+ [ run array5.cpp ]
+ ;
Deleted: branches/release/libs/crc/crc_test.cpp
==============================================================================
--- branches/release/libs/crc/crc_test.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,761 +0,0 @@
-// Boost CRC test program file ---------------------------------------------//
-
-// Copyright 2001, 2003, 2004 Daryle Walker. Use, modification, and
-// distribution are subject to the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or a copy at
-// <http://www.boost.org/LICENSE_1_0.txt>.)
-
-// See <http://www.boost.org/libs/crc/> for the library's home page.
-
-// Revision History
-// 28 Aug 2004 Added CRC tests for polynominals shorter than 8 bits
-// (Daryle Walker, by patch from Bert Klaps)
-// 23 Aug 2003 Adjust to updated Test framework (Daryle Walker)
-// 14 May 2001 Initial version (Daryle Walker)
-
-
-#include <boost/config.hpp> // for BOOST_MSVC, etc.
-#include <boost/crc.hpp> // for boost::crc_basic, etc.
-#include <boost/cstdint.hpp> // for boost::uint16_t, etc.
-#include <boost/cstdlib.hpp> // for boost::exit_success
-#include <boost/integer.hpp> // for boost::uint_t
-#include <boost/random/linear_congruential.hpp> // for boost::minstd_rand
-#include <boost/test/minimal.hpp> // for main, etc.
-#include <boost/timer.hpp> // for boost::timer
-
-#include <algorithm> // for std::for_each, std::generate_n, std::count
-#include <climits> // for CHAR_BIT
-#include <cstddef> // for std::size_t
-#include <iostream> // for std::cout (std::ostream and std::endl indirectly)
-
-
-#if CHAR_BIT != 8
-#error The expected results assume an eight-bit byte.
-#endif
-
-#if !(defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) || (defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)))
-#define CRC_PARM_TYPE typename boost::uint_t<Bits>::fast
-#else
-#define CRC_PARM_TYPE unsigned long
-#endif
-
-#if !defined(BOOST_MSVC) && !defined(__GNUC__)
-#define PRIVATE_DECLARE_BOOST( TypeName ) using boost:: TypeName
-#else
-#define PRIVATE_DECLARE_BOOST( TypeName ) typedef boost:: TypeName TypeName
-#endif
-
-
-// Types
-template < std::size_t Bits, CRC_PARM_TYPE TrPo, CRC_PARM_TYPE InRe,
- CRC_PARM_TYPE FiXo, bool ReIn, bool ReRe >
-class crc_tester
-{
-public:
- // All the following were separate function templates, but they have
- // been moved to class-static member functions of a class template
- // because MS VC++ 6 can't handle function templates that can't
- // deduce all their template arguments from their function arguments.
-
- typedef typename boost::uint_t<Bits>::fast value_type;
-
- static void master_test( char const *test_name, value_type expected );
-
-private:
- typedef boost::crc_optimal<Bits, TrPo, InRe, FiXo, ReIn, ReRe>
- optimal_crc_type;
- typedef boost::crc_basic<Bits> basic_crc_type;
-
- static void compute_test( value_type expected );
- static void interrupt_test( value_type expected );
- static void error_test();
-
-}; // crc_tester
-
-// Global data
-unsigned char const std_data[] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39 };
-std::size_t const std_data_len = sizeof( std_data ) / sizeof( std_data[0] );
-
-boost::uint16_t const std_crc_ccitt_result = 0x29B1;
-boost::uint16_t const std_crc_16_result = 0xBB3D;
-boost::uint32_t const std_crc_32_result = 0xCBF43926;
-
-// Function prototypes
-void timing_test();
-boost::uint32_t basic_crc32( void const *buffer, std::size_t byte_count );
-boost::uint32_t optimal_crc32( void const *buffer, std::size_t byte_count );
-boost::uint32_t quick_crc32( void const *buffer, std::size_t byte_count );
-boost::uint32_t quick_reflect( boost::uint32_t value, std::size_t bits );
-double time_trial( char const *name,
- boost::uint32_t (*crc_func)(void const *, std::size_t),
- boost::uint32_t expected, void const *data, std::size_t length );
-
-void augmented_tests();
-boost::uint32_t native_to_big( boost::uint32_t x );
-boost::uint32_t big_to_native( boost::uint32_t x );
-
-void small_crc_test1();
-void small_crc_test2();
-
-
-// Macro to compact code
-#define PRIVATE_TESTER_NAME crc_tester<Bits, TrPo, InRe, FiXo, ReIn, ReRe>
-
-// Run a test on slow and fast CRC computers and function
-template < std::size_t Bits, CRC_PARM_TYPE TrPo, CRC_PARM_TYPE InRe,
- CRC_PARM_TYPE FiXo, bool ReIn, bool ReRe >
-void
-PRIVATE_TESTER_NAME::compute_test
-(
- typename PRIVATE_TESTER_NAME::value_type expected
-)
-{
- std::cout << "\tDoing computation tests." << std::endl;
-
- optimal_crc_type fast_crc;
- basic_crc_type slow_crc( TrPo, InRe, FiXo, ReIn, ReRe );
- value_type const func_result = boost::crc<Bits, TrPo, InRe, FiXo, ReIn,
- ReRe>( std_data, std_data_len );
-
- fast_crc.process_bytes( std_data, std_data_len );
- slow_crc.process_bytes( std_data, std_data_len );
- BOOST_CHECK( fast_crc.checksum() == expected );
- BOOST_CHECK( slow_crc.checksum() == expected );
- BOOST_CHECK( func_result == expected );
-}
-
-// Run a test in two runs, and check all the inspectors
-template < std::size_t Bits, CRC_PARM_TYPE TrPo, CRC_PARM_TYPE InRe,
- CRC_PARM_TYPE FiXo, bool ReIn, bool ReRe >
-void
-PRIVATE_TESTER_NAME::interrupt_test
-(
- typename PRIVATE_TESTER_NAME::value_type expected
-)
-{
- std::cout << "\tDoing interrupt tests." << std::endl;
-
- // Process the first half of the data (also test accessors)
- optimal_crc_type fast_crc1;
- basic_crc_type slow_crc1( fast_crc1.get_truncated_polynominal(),
- fast_crc1.get_initial_remainder(), fast_crc1.get_final_xor_value(),
- fast_crc1.get_reflect_input(), fast_crc1.get_reflect_remainder() );
-
- BOOST_CHECK( fast_crc1.get_interim_remainder() ==
- slow_crc1.get_initial_remainder() );
-
- std::size_t const mid_way = std_data_len / 2;
- unsigned char const * const std_data_end = std_data + std_data_len;
-
- fast_crc1.process_bytes( std_data, mid_way );
- slow_crc1.process_bytes( std_data, mid_way );
- BOOST_CHECK( fast_crc1.checksum() == slow_crc1.checksum() );
-
- // Process the second half of the data (also test accessors)
- boost::crc_optimal<optimal_crc_type::bit_count,
- optimal_crc_type::truncated_polynominal, optimal_crc_type::initial_remainder,
- optimal_crc_type::final_xor_value, optimal_crc_type::reflect_input,
- optimal_crc_type::reflect_remainder>
- fast_crc2( fast_crc1.get_interim_remainder() );
- boost::crc_basic<basic_crc_type::bit_count> slow_crc2(
- slow_crc1.get_truncated_polynominal(), slow_crc1.get_interim_remainder(),
- slow_crc1.get_final_xor_value(), slow_crc1.get_reflect_input(),
- slow_crc1.get_reflect_remainder() );
-
- fast_crc2.process_block( std_data + mid_way, std_data_end );
- slow_crc2.process_block( std_data + mid_way, std_data_end );
- BOOST_CHECK( fast_crc2.checksum() == slow_crc2.checksum() );
- BOOST_CHECK( fast_crc2.checksum() == expected );
- BOOST_CHECK( slow_crc2.checksum() == expected );
-}
-
-// Run a test to see if a single-bit error is detected
-template < std::size_t Bits, CRC_PARM_TYPE TrPo, CRC_PARM_TYPE InRe,
- CRC_PARM_TYPE FiXo, bool ReIn, bool ReRe >
-void
-PRIVATE_TESTER_NAME::error_test
-(
-)
-{
- PRIVATE_DECLARE_BOOST( uint32_t );
-
- // A single-bit error is ensured to be detected if the polynominal
- // has at least two bits set. The highest bit is what is removed
- // to give the truncated polynominal, and it is always set. This
- // means that the truncated polynominal needs at least one of its
- // bits set, which implies that it cannot be zero.
- if ( !(TrPo & boost::detail::mask_uint_t<Bits>::sig_bits_fast) )
- {
- BOOST_FAIL( "truncated CRC polymonial is zero" );
- }
-
- std::cout << "\tDoing error tests." << std::endl;
-
- // Create a random block of data
- uint32_t ran_data[ 256 ];
- std::size_t const ran_length = sizeof(ran_data) / sizeof(ran_data[0]);
-
- std::generate_n( ran_data, ran_length, boost::minstd_rand() );
-
- // Create computers and compute the checksum of the data
- optimal_crc_type fast_tester;
- basic_crc_type slow_tester( TrPo, InRe, FiXo, ReIn, ReRe );
-
- fast_tester.process_bytes( ran_data, sizeof(ran_data) );
- slow_tester.process_bytes( ran_data, sizeof(ran_data) );
-
- uint32_t const fast_checksum = fast_tester.checksum();
- uint32_t const slow_checksum = slow_tester.checksum();
-
- BOOST_CHECK( fast_checksum == slow_checksum );
-
- // Do the checksum again (and test resetting ability)
- fast_tester.reset();
- slow_tester.reset( InRe );
- fast_tester.process_bytes( ran_data, sizeof(ran_data) );
- slow_tester.process_bytes( ran_data, sizeof(ran_data) );
- BOOST_CHECK( fast_tester.checksum() == slow_tester.checksum() );
- BOOST_CHECK( fast_tester.checksum() == fast_checksum );
- BOOST_CHECK( slow_tester.checksum() == slow_checksum );
-
- // Produce a single-bit error
- ran_data[ ran_data[0] % ran_length ] ^= ( 1 << (ran_data[1] % 32) );
-
- // Compute the checksum of the errorenous data
- // (and continue testing resetting ability)
- fast_tester.reset( InRe );
- slow_tester.reset();
- fast_tester.process_bytes( ran_data, sizeof(ran_data) );
- slow_tester.process_bytes( ran_data, sizeof(ran_data) );
- BOOST_CHECK( fast_tester.checksum() == slow_tester.checksum() );
- BOOST_CHECK( fast_tester.checksum() != fast_checksum );
- BOOST_CHECK( slow_tester.checksum() != slow_checksum );
-}
-
-// Run the other CRC object tests
-template < std::size_t Bits, CRC_PARM_TYPE TrPo, CRC_PARM_TYPE InRe,
- CRC_PARM_TYPE FiXo, bool ReIn, bool ReRe >
-void
-PRIVATE_TESTER_NAME::master_test
-(
- char const * test_name,
- typename PRIVATE_TESTER_NAME::value_type expected
-)
-{
- std::cout << "Doing test suite for " << test_name << '.' << std::endl;
- compute_test( expected );
- interrupt_test( expected );
- error_test();
-}
-
-// Undo limited macros
-#undef PRIVATE_TESTER_NAME
-
-
-// A CRC-32 computer based on crc_basic, for timing
-boost::uint32_t
-basic_crc32
-(
- void const * buffer,
- std::size_t byte_count
-)
-{
- static boost::crc_basic<32> computer( 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF,
- true, true );
-
- computer.reset();
- computer.process_bytes( buffer, byte_count );
- return computer.checksum();
-}
-
-// A CRC-32 computer based on crc_optimal, for timing
-inline
-boost::uint32_t
-optimal_crc32
-(
- void const * buffer,
- std::size_t byte_count
-)
-{
- static boost::crc_32_type computer;
-
- computer.reset();
- computer.process_bytes( buffer, byte_count );
- return computer.checksum();
-}
-
-// Reflect the lower "bits" bits of a "value"
-boost::uint32_t
-quick_reflect
-(
- boost::uint32_t value,
- std::size_t bits
-)
-{
- boost::uint32_t reflection = 0;
- for ( std::size_t i = 0 ; i < bits ; ++i )
- {
- if ( value & (1u << i) )
- {
- reflection |= 1 << ( bits - 1 - i );
- }
- }
-
- return reflection;
-}
-
-// A customized CRC-32 computer, for timing
-boost::uint32_t
-quick_crc32
-(
- void const * buffer,
- std::size_t byte_count
-)
-{
- PRIVATE_DECLARE_BOOST( uint32_t );
- typedef unsigned char byte_type;
-
- // Compute the CRC table (first run only)
- static bool did_init = false;
- static uint32_t crc_table[ 1ul << CHAR_BIT ];
- if ( !did_init )
- {
- uint32_t const value_high_bit = static_cast<uint32_t>(1) << 31u;
-
- byte_type dividend = 0;
- do
- {
- uint32_t remainder = 0;
- for ( byte_type mask = 1u << (CHAR_BIT - 1u) ; mask ; mask >>= 1 )
- {
- if ( dividend & mask )
- {
- remainder ^= value_high_bit;
- }
-
- if ( remainder & value_high_bit )
- {
- remainder <<= 1;
- remainder ^= 0x04C11DB7u;
- }
- else
- {
- remainder <<= 1;
- }
- }
-
- crc_table[ quick_reflect(dividend, CHAR_BIT) ]
- = quick_reflect( remainder, 32 );
- }
- while ( ++dividend );
-
- did_init = true;
- }
-
- // Compute the CRC of the data
- uint32_t rem = 0xFFFFFFFF;
-
- byte_type const * const b_begin = static_cast<byte_type const *>( buffer );
- byte_type const * const b_end = b_begin + byte_count;
- for ( byte_type const *p = b_begin ; p < b_end ; ++p )
- {
- byte_type const byte_index = *p ^ rem;
- rem >>= CHAR_BIT;
- rem ^= crc_table[ byte_index ];
- }
-
- return ~rem;
-}
-
-// Run an individual timing trial
-double
-time_trial
-(
- char const * name,
- boost::uint32_t (*crc_func)(void const *, std::size_t),
- boost::uint32_t expected,
- void const * data,
- std::size_t length
-)
-{
- PRIVATE_DECLARE_BOOST( uint32_t );
- using std::cout;
-
- // Limits of a trial
- static uint32_t const max_count = 1L << 16; // ~square-root of max
- static double const max_time = 3.14159; // easy as pi(e)
-
- // Mark the trial
- cout << '\t' << name << " CRC-32: ";
-
- // Trial loop
- uint32_t trial_count = 0, wrong_count = 0;
- double elapsed_time = 0.0;
- boost::timer t;
-
- do
- {
- uint32_t const scratch = (*crc_func)( data, length );
-
- if ( scratch != expected )
- {
- ++wrong_count;
- }
- elapsed_time = t.elapsed();
- ++trial_count;
- } while ( (trial_count < max_count) && (elapsed_time < max_time) );
-
- if ( wrong_count )
- {
- BOOST_ERROR( "at least one time trial didn't match expected" );
- }
-
- // Report results
- double const rate = trial_count / elapsed_time;
-
- cout << trial_count << " runs, " << elapsed_time << " s, " << rate
- << " run/s" << std::endl;
- return rate;
-}
-
-// Time runs of Boost CRCs vs. a customized CRC function
-void
-timing_test
-(
-)
-{
- PRIVATE_DECLARE_BOOST( uint32_t );
- using std::cout;
- using std::endl;
-
- cout << "Doing timing tests." << endl;
-
- // Create a random block of data
- boost::int32_t ran_data[ 256 ];
- std::size_t const ran_length = sizeof(ran_data) / sizeof(ran_data[0]);
-
- std::generate_n( ran_data, ran_length, boost::minstd_rand() );
-
- // Use the first runs as a check. This gives a chance for first-
- // time static initialization to not interfere in the timings.
- uint32_t const basic_result = basic_crc32( ran_data, sizeof(ran_data) );
- uint32_t const optimal_result = optimal_crc32( ran_data, sizeof(ran_data) );
- uint32_t const quick_result = quick_crc32( ran_data, sizeof(ran_data) );
-
- BOOST_CHECK( basic_result == optimal_result );
- BOOST_CHECK( optimal_result == quick_result );
- BOOST_CHECK( quick_result == basic_result );
-
- // Run trials
- double const basic_rate = time_trial( "Boost-Basic", basic_crc32,
- basic_result, ran_data, sizeof(ran_data) );
- double const optimal_rate = time_trial( "Boost-Optimal", optimal_crc32,
- optimal_result, ran_data, sizeof(ran_data) );
- double const quick_rate = time_trial( "Reference", quick_crc32,
- quick_result, ran_data, sizeof(ran_data) );
-
- // Report results
- cout << "\tThe optimal Boost version is " << (quick_rate - optimal_rate)
- / quick_rate * 100.0 << "% slower than the reference version.\n";
- cout << "\tThe basic Boost version is " << (quick_rate - basic_rate)
- / quick_rate * 100.0 << "% slower than the reference version.\n";
- cout << "\tThe basic Boost version is " << (optimal_rate - basic_rate)
- / optimal_rate * 100.0 << "% slower than the optimal Boost version."
- << endl;
-}
-
-
-// Reformat an integer to the big-endian storage format
-boost::uint32_t
-native_to_big
-(
- boost::uint32_t x
-)
-{
- boost::uint32_t temp;
- unsigned char * tp = reinterpret_cast<unsigned char *>( &temp );
-
- for ( std::size_t i = sizeof(x) ; i > 0 ; --i )
- {
- tp[ i - 1 ] = static_cast<unsigned char>( x );
- x >>= CHAR_BIT;
- }
-
- return temp;
-}
-
-// Restore an integer from the big-endian storage format
-boost::uint32_t
-big_to_native
-(
- boost::uint32_t x
-)
-{
- boost::uint32_t temp = 0;
- unsigned char * xp = reinterpret_cast<unsigned char *>( &x );
-
- for ( std::size_t i = 0 ; i < sizeof(x) ; ++i )
- {
- temp <<= CHAR_BIT;
- temp |= xp[ i ];
- }
-
- return temp;
-}
-
-// Run tests on using CRCs on augmented messages
-void
-augmented_tests
-(
-)
-{
- #define PRIVATE_ACRC_FUNC boost::augmented_crc<32, 0x04C11DB7>
-
- using std::size_t;
- PRIVATE_DECLARE_BOOST( uint32_t );
-
- std::cout << "Doing CRC-augmented message tests." << std::endl;
-
- // Create a random block of data, with space for a CRC.
- uint32_t ran_data[ 257 ];
- size_t const ran_length = sizeof(ran_data) / sizeof(ran_data[0]);
- size_t const data_length = ran_length - 1;
-
- std::generate_n( ran_data, data_length, boost::minstd_rand() );
-
- // When creating a CRC for an augmented message, use
- // zeros in the appended CRC spot for the first run.
- uint32_t & ran_crc = ran_data[ data_length ];
-
- ran_crc = 0;
-
- // Compute the CRC with augmented-CRC computing function
- typedef boost::uint_t<32>::fast return_type;
-
- ran_crc = PRIVATE_ACRC_FUNC( ran_data, sizeof(ran_data) );
-
- // With the appended CRC set, running the checksum again should get zero.
- // NOTE: CRC algorithm assumes numbers are in big-endian format
- ran_crc = native_to_big( ran_crc );
-
- uint32_t ran_crc_check = PRIVATE_ACRC_FUNC( ran_data, sizeof(ran_data) );
-
- BOOST_CHECK( 0 == ran_crc_check );
-
- // Compare that result with other CRC computing functions
- // and classes, which don't accept augmented messages.
- typedef boost::crc_optimal<32, 0x04C11DB7> fast_crc_type;
- typedef boost::crc_basic<32> slow_crc_type;
-
- fast_crc_type fast_tester;
- slow_crc_type slow_tester( 0x04C11DB7 );
- size_t const data_size = data_length * sizeof(ran_data[0]);
- uint32_t const func_tester = boost::crc<32, 0x04C11DB7, 0, 0, false,
- false>( ran_data, data_size );
-
- fast_tester.process_bytes( ran_data, data_size );
- slow_tester.process_bytes( ran_data, data_size );
- BOOST_CHECK( fast_tester.checksum() == slow_tester.checksum() );
- ran_crc = big_to_native( ran_crc );
- BOOST_CHECK( fast_tester.checksum() == ran_crc );
- BOOST_CHECK( func_tester == ran_crc );
-
- // Do a single-bit error test
- ran_crc = native_to_big( ran_crc );
- ran_data[ ran_data[0] % ran_length ] ^= ( 1 << (ran_data[1] % 32) );
- ran_crc_check = PRIVATE_ACRC_FUNC( ran_data, sizeof(ran_data) );
- BOOST_CHECK( 0 != ran_crc_check );
-
- // Run a version of these tests with a nonzero initial remainder.
- uint32_t const init_rem = ran_data[ ran_data[2] % ran_length ];
-
- ran_crc = 0;
- ran_crc = PRIVATE_ACRC_FUNC( ran_data, sizeof(ran_data), init_rem );
-
- // Have some fun by processing data in two steps.
- size_t const mid_index = ran_length / 2;
-
- ran_crc = native_to_big( ran_crc );
- ran_crc_check = PRIVATE_ACRC_FUNC( ran_data, mid_index
- * sizeof(ran_data[0]), init_rem );
- ran_crc_check = PRIVATE_ACRC_FUNC( &ran_data[mid_index], sizeof(ran_data)
- - mid_index * sizeof(ran_data[0]), ran_crc_check );
- BOOST_CHECK( 0 == ran_crc_check );
-
- // This substep translates an augmented-CRC initial
- // remainder to an unaugmented-CRC initial remainder.
- uint32_t const zero = 0;
- uint32_t const new_init_rem = PRIVATE_ACRC_FUNC( &zero, sizeof(zero),
- init_rem );
- slow_crc_type slow_tester2( 0x04C11DB7, new_init_rem );
-
- slow_tester2.process_bytes( ran_data, data_size );
- ran_crc = big_to_native( ran_crc );
- BOOST_CHECK( slow_tester2.checksum() == ran_crc );
-
- // Redo single-bit error test
- ran_data[ ran_data[3] % ran_length ] ^= ( 1 << (ran_data[4] % 32) );
- ran_crc_check = PRIVATE_ACRC_FUNC( ran_data, sizeof(ran_data), init_rem );
- BOOST_CHECK( 0 != ran_crc_check );
-
- #undef PRIVATE_ACRC_FUNC
-}
-
-
-// Run tests on CRCs below a byte in size (here, 3 bits)
-void
-small_crc_test1
-(
-)
-{
- std::cout << "Doing short-CRC (3-bit augmented) message tests."
- << std::endl;
-
- // The CRC standard is a SDH/SONET Low Order LCAS control word with CRC-3
- // taken from ITU-T G.707 (12/03) XIII.2.
-
- // Four samples, each four bytes; should all have a CRC of zero
- unsigned char const samples[4][4]
- = {
- { 0x3A, 0xC4, 0x08, 0x06 },
- { 0x42, 0xC5, 0x0A, 0x41 },
- { 0x4A, 0xC5, 0x08, 0x22 },
- { 0x52, 0xC4, 0x08, 0x05 }
- };
-
- // Basic computer
- boost::crc_basic<3> tester1( 0x03 );
-
- tester1.process_bytes( samples[0], 4 );
- BOOST_CHECK( tester1.checksum() == 0 );
-
- tester1.reset();
- tester1.process_bytes( samples[1], 4 );
- BOOST_CHECK( tester1.checksum() == 0 );
-
- tester1.reset();
- tester1.process_bytes( samples[2], 4 );
- BOOST_CHECK( tester1.checksum() == 0 );
-
- tester1.reset();
- tester1.process_bytes( samples[3], 4 );
- BOOST_CHECK( tester1.checksum() == 0 );
-
- // Optimal computer
- #define PRIVATE_CRC_FUNC boost::crc<3, 0x03, 0, 0, false, false>
- #define PRIVATE_ACRC_FUNC boost::augmented_crc<3, 0x03>
-
- BOOST_CHECK( 0 == PRIVATE_CRC_FUNC(samples[0], 4) );
- BOOST_CHECK( 0 == PRIVATE_CRC_FUNC(samples[1], 4) );
- BOOST_CHECK( 0 == PRIVATE_CRC_FUNC(samples[2], 4) );
- BOOST_CHECK( 0 == PRIVATE_CRC_FUNC(samples[3], 4) );
-
- // maybe the fix to CRC functions needs to be applied to augmented CRCs?
-
- #undef PRIVATE_ACRC_FUNC
- #undef PRIVATE_CRC_FUNC
-}
-
-// Run tests on CRCs below a byte in size (here, 7 bits)
-void
-small_crc_test2
-(
-)
-{
- std::cout << "Doing short-CRC (7-bit augmented) message tests."
- << std::endl;
-
- // The CRC standard is a SDH/SONET J0/J1/J2/N1/N2/TR TTI (trace message)
- // with CRC-7, o.a. ITU-T G.707 Annex B, G.832 Annex A.
-
- // Two samples, each sixteen bytes
- // Sample 1 is '\x80' + ASCII("123456789ABCDEF")
- // Sample 2 is '\x80' + ASCII("TTI UNAVAILABLE")
- unsigned char const samples[2][16]
- = {
- { 0x80, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41,
- 0x42, 0x43, 0x44, 0x45, 0x46 },
- { 0x80, 0x54, 0x54, 0x49, 0x20, 0x55, 0x4E, 0x41, 0x56, 0x41, 0x49,
- 0x4C, 0x41, 0x42, 0x4C, 0x45 }
- };
- unsigned const results[2] = { 0x62, 0x23 };
-
- // Basic computer
- boost::crc_basic<7> tester1( 0x09 );
-
- tester1.process_bytes( samples[0], 16 );
- BOOST_CHECK( tester1.checksum() == results[0] );
-
- tester1.reset();
- tester1.process_bytes( samples[1], 16 );
- BOOST_CHECK( tester1.checksum() == results[1] );
-
- // Optimal computer
- #define PRIVATE_CRC_FUNC boost::crc<7, 0x09, 0, 0, false, false>
- #define PRIVATE_ACRC_FUNC boost::augmented_crc<7, 0x09>
-
- BOOST_CHECK( results[0] == PRIVATE_CRC_FUNC(samples[0], 16) );
- BOOST_CHECK( results[1] == PRIVATE_CRC_FUNC(samples[1], 16) );
-
- // maybe the fix to CRC functions needs to be applied to augmented CRCs?
-
- #undef PRIVATE_ACRC_FUNC
- #undef PRIVATE_CRC_FUNC
-}
-
-
-#ifndef BOOST_MSVC
-// Explicit template instantiations
-// (needed to fix a link error in Metrowerks CodeWarrior Pro 5.3)
-template class crc_tester<16, 0x1021, 0xFFFF, 0, false, false>;
-template class crc_tester<16, 0x8005, 0, 0, true, true>;
-template class crc_tester<32, 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, true>;
-#endif
-
-// Main testing function
-int
-test_main
-(
- int , // "argc" is unused
- char * [] // "argv" is unused
-)
-{
- using std::cout;
- using std::endl;
-
- // Run simulations on some CRC types
- typedef crc_tester<16, 0x1021, 0xFFFF, 0, false, false> crc_ccitt_tester;
- typedef crc_tester<16, 0x8005, 0, 0, true, true> crc_16_tester;
- typedef crc_tester<32, 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, true>
- crc_32_tester;
-
- crc_ccitt_tester::master_test( "CRC-CCITT", std_crc_ccitt_result );
- crc_16_tester::master_test( "CRC-16", std_crc_16_result );
- crc_32_tester::master_test( "CRC-32", std_crc_32_result );
-
- // Run a timing comparison test
- timing_test();
-
- // Test using augmented messages
- augmented_tests();
-
- // Test with CRC types smaller than a byte
- small_crc_test1();
- small_crc_test2();
-
- // Try a CRC based on the (x + 1) polynominal, which is a factor in
- // many real-life polynominals and doesn't fit evenly in a byte.
- cout << "Doing one-bit polynominal CRC test." << endl;
- boost::crc_basic<1> crc_1( 1 );
- crc_1.process_bytes( std_data, std_data_len );
- BOOST_CHECK( crc_1.checksum() == 1 );
-
- // Test the function object interface
- cout << "Doing functional object interface test." << endl;
- boost::crc_optimal<16, 0x8005, 0, 0, true, true> crc_16;
- crc_16 = std::for_each( std_data, std_data + std_data_len, crc_16 );
- BOOST_CHECK( crc_16() == std_crc_16_result );
-
- return boost::exit_success;
-}
Added: branches/release/libs/crc/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/crc/test/Jamfile.v2 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
@@ -0,0 +1,14 @@
+#~ Copyright Rene Rivera 2008
+#~ 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)
+
+project
+ : requirements
+ <library>/boost/test//boost_test_exec_monitor/<link>static
+ ;
+
+import testing ;
+
+test-suite crc :
+ [ run crc_test.cpp ]
+ ;
Deleted: branches/release/libs/functional/function_test.cpp
==============================================================================
--- branches/release/libs/functional/function_test.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,334 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) 2000 Cadenza New Zealand Ltd
-// Distributed under the Boost Software License, Version 1.0. (See accompany-
-// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-// ------------------------------------------------------------------------------
-// Tests for the Boost functional.hpp header file
-//
-// Note that functional.hpp relies on partial specialisation to be
-// effective. If your compiler lacks this feature, very few of the
-// tests would compile, and so have been excluded from the test.
-// ------------------------------------------------------------------------------
-// $Id$
-// ------------------------------------------------------------------------------
-// $Log$
-// Revision 1.3 2006/12/02 13:57:32 andreas_huber69
-// Fixed license & copyright issues.
-//
-// From Mark Rodgers Fri Dec 1 12:59:14 2006
-// X-Apparently-To: ahd6974-boostorg -at- yahoo.com via 68.142.206.160; Fri, 01 Dec 2006 12:59:41 -0800
-// X-Originating-IP: [195.112.4.54]
-// Return-Path: <mark.rodgers -at- cadenza.co.nz>
-// Authentication-Results: mta550.mail.mud.yahoo.com from=cadenza.co.nz; domainkeys=neutral (no sig)
-// Received: from 195.112.4.54 (EHLO smtp.nildram.co.uk) (195.112.4.54) by mta550.mail.mud.yahoo.com with SMTP; Fri, 01 Dec 2006 12:59:40 -0800
-// Received: from snagglepuss.cadenza.co.nz (81-6-246-87.dyn.gotadsl.co.uk [81.6.246.87]) by smtp.nildram.co.uk (Postfix) with ESMTP id D32EA2B6D8C for <ahd6974-boostorg -at- yahoo.com>; Fri, 1 Dec 2006 20:59:35 +0000 (GMT)
-// Received: from penfold.cadenza.co.nz ([192.168.55.56]) by snagglepuss.cadenza.co.nz with esmtp (Exim 4.63) (envelope-from <mark.rodgers -at- cadenza.co.nz>) id J9M4Y9-0009TO-9K for ahd6974-boostorg -at- yahoo.com; Fri, 01 Dec 2006 20:58:57 +0000
-// Message-ID: <457097A2.1090305_at_[hidden]>
-// Date: Fri, 01 Dec 2006 20:59:14 +0000
-// From: "Mark Rodgers" <mark.rodgers -at- cadenza.co.nz>
-// User-Agent: Thunderbird 1.5.0.8 (Macintosh/20061025)
-// MIME-Version: 1.0
-// To: ahd6974-boostorg -at- yahoo.com [Edit - Delete]
-// Subject: Re: [boost] Reminder: Need your permission to correct license & copyright issues
-// References: <379990.36007.qm_at_[hidden]>
-// In-Reply-To: <379990.36007.qm_at_[hidden]>
-// Content-Type: text/plain; charset=ISO-8859-1; format=flowed
-// Content-Transfer-Encoding: 7bit
-// Content-Length: 812
-// Gidday Andreas
-//
-// Sure that's fine. I'm happy for you to do 1, 2 and 3.
-//
-// Regards
-// Mark
-//
-// Andreas Huber wrote:
-// > Hello Mark
-// >
-// > Quite a while ago it was decided that every file that goes into the
-// > 1.34 release of the Boost distribution (www.boost.org) needs uniform
-// > license and copyright information. For more information please see:
-// >
-// > <http://www.boost.org/more/license_info.html>
-// >
-// > You are receiving this email because several files you contributed
-// > lack such information or have an old license:
-// >
-// > boost/functional/functional.hpp
-// > boost/libs/functional/binders.html
-// > boost/libs/functional/function_test.cpp
-// > boost/libs/functional/function_traits.html
-// > boost/libs/functional/index.html
-// > boost/libs/functional/mem_fun.html
-// > boost/libs/functional/negators.html
-// > boost/libs/functional/ptr_fun.html
-// > boost/people/mark_rodgers.htm
-// >
-// > I therefore kindly ask you to grant the permission to do the
-// > following:
-// >
-// > 1. For the files above that already have a license text (all except
-// > mark_rodgers.htm), replace the license text with:
-// >
-// > "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)"
-// >
-// > 2. For the file that does not yet have a license and copyright
-// > (mark_rodgers.htm) add the same license text as under 1. and add the
-// > following copyright:
-// >
-// > "(c) Copyright Mark Rodgers 2000"
-// >
-// > 3. (Optional) I would also want to convert all HTML files to conform
-// > the HTML 4.01 Standard by running them through HTML Tidy, see
-// > <http://tidy.sf.net>
-// >
-// > It would be great if you could grant me permission to do 1 & 2 and
-// > optionally also 3.
-// >
-// > Thank you!
-// >
-// > Regards,
-// >
-// > Andreas Huber
-// >
-//
-// Revision 1.2 2001/09/22 11:52:24 johnmaddock
-// Intel C++ fixes: no void return types supported.
-//
-// Revision 1.1.1.1 2000/07/07 16:04:18 beman
-// 1.16.1 initial CVS checkin
-//
-// Revision 1.3 2000/06/26 09:44:01 mark
-// Updated following feedback from Jens Maurer.
-//
-// Revision 1.2 2000/05/17 08:31:45 mark
-// Added extra tests now that function traits work correctly.
-// For compilers with no support for partial specialisation,
-// excluded tests that won't work.
-//
-// Revision 1.1 2000/05/07 09:14:41 mark
-// Initial revision
-// ------------------------------------------------------------------------------
-
-// To demonstrate what the boosted function object adapters do for
-// you, try compiling with USE_STD defined. This will endeavour to
-// use the standard function object adapters, but is likely to result
-// in numerous errors due to the fact that you cannot have references
-// to references.
-#ifdef USE_STD
-#include <functional>
-#define boost std
-#else
-#include <boost/functional.hpp>
-#endif
-
-#include <algorithm>
-#include <iostream>
-#include <iterator>
-#include <string>
-#include <vector>
-
-class Person
-{
- public:
- Person() {}
- Person(const char *n) : name(n) {}
-
- const std::string &get_name() const { return name; }
- void print(std::ostream &os) const { os << name << " "; }
- void set_name(const std::string &n) { name = n; std::cout << name << " "; }
- std::string clear_name() { std::string ret = name; name = ""; return ret; }
- void do_something(int) const {}
-
- bool is_fred() const { return name == "Fred"; }
-
- private:
- std::string name;
-};
-
-namespace
-{
- bool is_equal(const std::string &s1, const std::string &s2)
- {
- return s1 == s2;
- }
-
- bool is_betty(const std::string &s)
- {
- return s == "Betty";
- }
-
- void do_set_name(Person *p, const std::string &name)
- {
- p->set_name(name);
- }
-
- void do_set_name_ref(Person &p, const std::string &name)
- {
- p.set_name(name);
- }
-}
-
-int main()
-{
- std::vector<Person> v1;
- v1.push_back("Fred");
- v1.push_back("Wilma");
- v1.push_back("Barney");
- v1.push_back("Betty");
-
- const std::vector<Person> cv1(v1.begin(), v1.end());
-
- std::vector<std::string> v2;
- v2.push_back("Fred");
- v2.push_back("Wilma");
- v2.push_back("Barney");
- v2.push_back("Betty");
-
- Person person;
- Person &r = person;
-
- Person fred("Fred");
- Person wilma("Wilma");
- Person barney("Barney");
- Person betty("Betty");
- std::vector<Person*> v3;
- v3.push_back(&fred);
- v3.push_back(&wilma);
- v3.push_back(&barney);
- v3.push_back(&betty);
-
- const std::vector<Person*> cv3(v3.begin(), v3.end());
- std::vector<const Person*> v3c(v3.begin(), v3.end());
-
- std::ostream &os = std::cout;
-
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__ICL)
- // unary_traits, unary_negate
- std::transform(v2.begin(), v2.end(),
- std::ostream_iterator<bool>(std::cout, " "),
- boost::not1(is_betty));
-
- std::cout << '\n';
- std::transform(v1.begin(), v1.end(),
- std::ostream_iterator<bool>(std::cout, " "),
- boost::not1(boost::mem_fun_ref(&Person::is_fred)));
-
- // binary_traits, binary_negate
- std::cout << '\n';
- std::transform(v2.begin(), v2.end(),
- std::ostream_iterator<bool>(std::cout, " "),
- boost::bind1st(boost::not2(is_equal), "Betty"));
-
- std::cout << '\n';
- std::transform(v2.begin(), v2.end(),
- std::ostream_iterator<bool>(std::cout, " "),
- boost::bind2nd(boost::not2(is_equal), "Betty"));
-
- // pointer_to_unary_function
- std::cout << '\n';
- std::transform(v2.begin(), v2.end(),
- std::ostream_iterator<bool>(std::cout, " "),
- boost::not1(boost::ptr_fun(is_betty)));
-
- // binary_traits, bind1st, bind2nd
- std::cout << '\n';
- std::transform(v2.begin(), v2.end(),
- std::ostream_iterator<bool>(std::cout, " "),
- boost::bind1st(is_equal, "Betty"));
-
- std::cout << '\n';
- std::transform(v2.begin(), v2.end(),
- std::ostream_iterator<bool>(std::cout, " "),
- boost::bind2nd(is_equal, "Betty"));
-
- // pointer_to_binary_function, bind1st
- std::cout << '\n';
- std::for_each(v2.begin(), v2.end(), boost::bind1st(boost::ptr_fun(do_set_name), &person));
-
- std::cout << '\n';
- std::for_each(v2.begin(), v2.end(), boost::bind1st(boost::ptr_fun(do_set_name_ref), person));
-
- std::cout << '\n';
- std::for_each(v2.begin(), v2.end(), boost::bind1st(boost::ptr_fun(do_set_name_ref), r));
-
- // binary_traits
- std::cout << '\n';
- std::for_each(v2.begin(), v2.end(), boost::bind1st(do_set_name, &person));
-
- std::cout << '\n';
- std::for_each(v2.begin(), v2.end(), boost::bind1st(do_set_name_ref, person));
-
- std::cout << '\n';
- std::for_each(v2.begin(), v2.end(), boost::bind1st(do_set_name_ref, r));
-#endif
-
- // const_mem_fun_t
- std::cout << '\n';
- std::transform(v3.begin(), v3.end(),
- std::ostream_iterator<std::string>(std::cout, " "),
- boost::mem_fun(&Person::get_name));
-
- std::cout << '\n';
- std::transform(cv3.begin(), cv3.end(),
- std::ostream_iterator<std::string>(std::cout, " "),
- boost::mem_fun(&Person::get_name));
-
- std::cout << '\n';
- std::transform(v3c.begin(), v3c.end(),
- std::ostream_iterator<std::string>(std::cout, " "),
- boost::mem_fun(&Person::get_name));
-
- // const_mem_fun_ref_t
- std::cout << '\n';
- std::transform(v1.begin(), v1.end(),
- std::ostream_iterator<std::string>(std::cout, " "),
- boost::mem_fun_ref(&Person::get_name));
-
- std::cout << '\n';
- std::transform(cv1.begin(), cv1.end(),
- std::ostream_iterator<std::string>(std::cout, " "),
- boost::mem_fun_ref(&Person::get_name));
-
-#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- // const_mem_fun1_t, bind2nd
- std::cout << '\n';
- std::for_each(v3.begin(), v3.end(), boost::bind2nd(boost::mem_fun(&Person::print), std::cout));
-
- std::cout << '\n';
- std::for_each(v3.begin(), v3.end(), boost::bind2nd(boost::mem_fun(&Person::print), os));
-
- // const_mem_fun1_ref_t, bind2nd
- std::cout << '\n';
- std::for_each(v1.begin(), v1.end(), boost::bind2nd(boost::mem_fun_ref(&Person::print), std::cout));
-
- std::cout << '\n';
- std::for_each(v1.begin(), v1.end(), boost::bind2nd(boost::mem_fun_ref(&Person::print), os));
-
- // mem_fun1_t, bind1st
- std::cout << '\n';
- std::for_each(v2.begin(), v2.end(), boost::bind1st(boost::mem_fun(&Person::set_name), &person));
-
- // mem_fun1_ref_t, bind1st
- std::cout << '\n';
- std::for_each(v2.begin(), v2.end(), boost::bind1st(boost::mem_fun_ref(&Person::set_name), person));
-
- std::cout << '\n';
- std::for_each(v2.begin(), v2.end(), boost::bind1st(boost::mem_fun_ref(&Person::set_name), r));
-#endif
-
- // mem_fun_t
- std::cout << '\n';
- std::transform(v3.begin(), v3.end(), std::ostream_iterator<std::string>(std::cout, " "),
- boost::mem_fun(&Person::clear_name));
-
- // mem_fun_ref_t
- std::cout << '\n';
- std::transform(v1.begin(), v1.end(), std::ostream_iterator<std::string>(std::cout, " "),
- boost::mem_fun_ref(&Person::clear_name));
-
- std::cout << '\n';
- return 0;
-}
Added: branches/release/libs/functional/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/functional/test/Jamfile.v2 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
@@ -0,0 +1,9 @@
+#~ Copyright Rene Rivera 2008
+#~ 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)
+
+import testing ;
+
+test-suite functional :
+ [ run function_test.cpp ]
+ ;
Deleted: branches/release/libs/integer/cstdint_test.cpp
==============================================================================
--- branches/release/libs/integer/cstdint_test.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,233 +0,0 @@
-// boost cstdint.hpp test program ------------------------------------------//
-
-// Copyright Beman Dawes 2000. 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/libs/integer for documentation.
-
-// Revision History
-// 11 Sep 01 Adapted to work with macros defined in native stdint.h (John Maddock)
-// 12 Nov 00 Adapted to merged <boost/cstdint.hpp>
-// 23 Sep 00 Added INTXX_C constant macro support + int64_t support (John Maddock).
-// 28 Jun 00 Initial version
-#define __STDC_CONSTANT_MACROS
-#include <cassert>
-#include <iostream>
-#include <boost/cstdint.hpp>
-
-#ifdef NDEBUG
-int main()
-{
- std::cout << "This test makes no sense with NDEBUG defined.\n";
- return 0;
-}
-#else
-
-#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
-//
-// the following class is designed to verify
-// that the various INTXX_C macros can be used
-// in integral constant expressions:
-//
-struct integral_constant_checker
-{
- static const boost::int8_t int8 = INT8_C(-127);
- static const boost::int_least8_t int_least8 = INT8_C(-127);
- static const boost::int_fast8_t int_fast8 = INT8_C(-127);
-
- static const boost::uint8_t uint8 = UINT8_C(255);
- static const boost::uint_least8_t uint_least8 = UINT8_C(255);
- static const boost::uint_fast8_t uint_fast8 = UINT8_C(255);
-
- static const boost::int16_t int16 = INT16_C(-32767);
- static const boost::int_least16_t int_least16 = INT16_C(-32767);
- static const boost::int_fast16_t int_fast16 = INT16_C(-32767);
-
- static const boost::uint16_t uint16 = UINT16_C(65535);
- static const boost::uint_least16_t uint_least16 = UINT16_C(65535);
- static const boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
-
- static const boost::int32_t int32 = INT32_C(-2147483647);
- static const boost::int_least32_t int_least32 = INT32_C(-2147483647);
- static const boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
-
- static const boost::uint32_t uint32 = UINT32_C(4294967295);
- static const boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
- static const boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
-
- static void check();
-};
-
-void integral_constant_checker::check()
-{
- assert( int8 == -127 );
- assert( int_least8 == -127 );
- assert( int_fast8 == -127 );
- assert( uint8 == 255u );
- assert( uint_least8 == 255u );
- assert( uint_fast8 == 255u );
- assert( int16 == -32767 );
- assert( int_least16 == -32767 );
- assert( int_fast16 == -32767 );
- assert( uint16 == 65535u );
- assert( uint_least16 == 65535u );
- assert( uint_fast16 == 65535u );
- assert( int32 == -2147483647 );
- assert( int_least32 == -2147483647 );
- assert( int_fast32 == -2147483647 );
- assert( uint32 == 4294967295u );
- assert( uint_least32 == 4294967295u );
- assert( uint_fast32 == 4294967295u );
-}
-#endif // BOOST_NO_INCLASS_MEMBER_INITIALIZATION
-
-//
-// the following function simply verifies that the type
-// of an integral constant is correctly defined:
-//
-#ifdef __BORLANDC__
-#pragma option -w-8008
-#pragma option -w-8066
-#endif
-template <class T1, class T2>
-void integral_constant_type_check(T1, T2)
-{
- //
- // the types T1 and T2 may not be exactly
- // the same type, but they should be the
- // same size and signedness. We could use
- // numeric_limits to verify this, but
- // numeric_limits implementations currently
- // vary too much, or are incomplete or missing.
- //
- T1 t1 = static_cast<T1>(-1); // cast suppresses warnings
- T2 t2 = static_cast<T2>(-1); // ditto
-#if defined(BOOST_HAS_STDINT_H)
- // if we have a native stdint.h
- // then the INTXX_C macros may define
- // a type that's wider than required:
- assert(sizeof(T1) <= sizeof(T2));
-#else
- assert(sizeof(T1) == sizeof(T2));
- assert(t1 == t2);
-#endif
-#if defined(BOOST_HAS_STDINT_H)
- // native headers are permitted to promote small
- // unsigned types to type int:
- if(sizeof(T1) >= sizeof(int))
- {
- if(t1 > 0)
- assert(t2 > 0);
- else
- assert(!(t2 > 0));
- }
- else if(t1 < 0)
- assert(!(t2 > 0));
-#else
- if(t1 > 0)
- assert(t2 > 0);
- else
- assert(!(t2 > 0));
-#endif
-}
-
-
-int main()
-{
-#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
- integral_constant_checker::check();
-#endif
- //
- // verify the types of the integral constants:
- //
- integral_constant_type_check(boost::int8_t(0), INT8_C(0));
- integral_constant_type_check(boost::uint8_t(0), UINT8_C(0));
- integral_constant_type_check(boost::int16_t(0), INT16_C(0));
- integral_constant_type_check(boost::uint16_t(0), UINT16_C(0));
- integral_constant_type_check(boost::int32_t(0), INT32_C(0));
- integral_constant_type_check(boost::uint32_t(0), UINT32_C(0));
-#ifndef BOOST_NO_INT64_T
- integral_constant_type_check(boost::int64_t(0), INT64_C(0));
- integral_constant_type_check(boost::uint64_t(0), UINT64_C(0));
-#endif
- //
- boost::int8_t int8 = INT8_C(-127);
- boost::int_least8_t int_least8 = INT8_C(-127);
- boost::int_fast8_t int_fast8 = INT8_C(-127);
-
- boost::uint8_t uint8 = UINT8_C(255);
- boost::uint_least8_t uint_least8 = UINT8_C(255);
- boost::uint_fast8_t uint_fast8 = UINT8_C(255);
-
- boost::int16_t int16 = INT16_C(-32767);
- boost::int_least16_t int_least16 = INT16_C(-32767);
- boost::int_fast16_t int_fast16 = INT16_C(-32767);
-
- boost::uint16_t uint16 = UINT16_C(65535);
- boost::uint_least16_t uint_least16 = UINT16_C(65535);
- boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
-
- boost::int32_t int32 = INT32_C(-2147483647);
- boost::int_least32_t int_least32 = INT32_C(-2147483647);
- boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
-
- boost::uint32_t uint32 = UINT32_C(4294967295);
- boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
- boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
-
-#ifndef BOOST_NO_INT64_T
- boost::int64_t int64 = INT64_C(-9223372036854775807);
- boost::int_least64_t int_least64 = INT64_C(-9223372036854775807);
- boost::int_fast64_t int_fast64 = INT64_C(-9223372036854775807);
-
- boost::uint64_t uint64 = UINT64_C(18446744073709551615);
- boost::uint_least64_t uint_least64 = UINT64_C(18446744073709551615);
- boost::uint_fast64_t uint_fast64 = UINT64_C(18446744073709551615);
-
- boost::intmax_t intmax = INTMAX_C(-9223372036854775807);
- boost::uintmax_t uintmax = UINTMAX_C(18446744073709551615);
-#else
- boost::intmax_t intmax = INTMAX_C(-2147483647);
- boost::uintmax_t uintmax = UINTMAX_C(4294967295);
-#endif
-
- assert( int8 == -127 );
- assert( int_least8 == -127 );
- assert( int_fast8 == -127 );
- assert( uint8 == 255u );
- assert( uint_least8 == 255u );
- assert( uint_fast8 == 255u );
- assert( int16 == -32767 );
- assert( int_least16 == -32767 );
- assert( int_fast16 == -32767 );
- assert( uint16 == 65535u );
- assert( uint_least16 == 65535u );
- assert( uint_fast16 == 65535u );
- assert( int32 == -2147483647 );
- assert( int_least32 == -2147483647 );
- assert( int_fast32 == -2147483647 );
- assert( uint32 == 4294967295u );
- assert( uint_least32 == 4294967295u );
- assert( uint_fast32 == 4294967295u );
-
-#ifndef BOOST_NO_INT64_T
- assert( int64 == INT64_C(-9223372036854775807) );
- assert( int_least64 == INT64_C(-9223372036854775807) );
- assert( int_fast64 == INT64_C(-9223372036854775807) );
- assert( uint64 == UINT64_C(18446744073709551615) );
- assert( uint_least64 == UINT64_C(18446744073709551615) );
- assert( uint_fast64 == UINT64_C(18446744073709551615) );
- assert( intmax == INT64_C(-9223372036854775807) );
- assert( uintmax == UINT64_C(18446744073709551615) );
-#else
- assert( intmax == -2147483647 );
- assert( uintmax == 4294967295u );
-#endif
-
-
- std::cout << "OK\n";
- return 0;
-}
-#endif
Deleted: branches/release/libs/integer/integer_test.cpp
==============================================================================
--- branches/release/libs/integer/integer_test.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,291 +0,0 @@
-// boost integer.hpp test program ------------------------------------------//
-
-// Copyright Beman Dawes 1999. 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/libs/integer for documentation.
-
-// Revision History
-// 04 Oct 01 Added tests for new templates; rewrote code (Daryle Walker)
-// 10 Mar 01 Boost Test Library now used for tests (Beman Dawes)
-// 31 Aug 99 Initial version
-
-#include <boost/test/minimal.hpp> // for main, BOOST_CHECK
-
-#include <boost/config.hpp> // for BOOST_NO_USING_TEMPLATE
-#include <boost/cstdlib.hpp> // for boost::exit_success
-#include <boost/integer.hpp> // for boost::int_t, boost::uint_t
-
-#include <climits> // for ULONG_MAX, LONG_MAX, LONG_MIN
-#include <iostream> // for std::cout (std::endl indirectly)
-#include <typeinfo> // for std::type_info
-
-
-// Control if the names of the types for each version
-// of the integer templates will be printed.
-#ifndef CONTROL_SHOW_TYPES
-#define CONTROL_SHOW_TYPES 0
-#endif
-
-
-// If specializations have not already been done, then we can confirm
-// the effects of the "fast" types by making a specialization.
-namespace boost
-{
- template < >
- struct int_fast_t< short >
- {
- typedef long fast;
- };
-}
-
-
-// Show the types of an integer template version
-#if CONTROL_SHOW_TYPES
-#define SHOW_TYPE(Template, Number, Type) ::std::cout << "Type \"" \
- #Template "<" #Number ">::" #Type "\" is \"" << typeid(Template < \
- Number > :: Type).name() << ".\"\n"
-#else
-#define SHOW_TYPE(Template, Number, Type)
-#endif
-
-#define SHOW_TYPES(Template, Type) SHOW_TYPE(Template, 32, Type); \
- SHOW_TYPE(Template, 31, Type); SHOW_TYPE(Template, 30, Type); \
- SHOW_TYPE(Template, 29, Type); SHOW_TYPE(Template, 28, Type); \
- SHOW_TYPE(Template, 27, Type); SHOW_TYPE(Template, 26, Type); \
- SHOW_TYPE(Template, 25, Type); SHOW_TYPE(Template, 24, Type); \
- SHOW_TYPE(Template, 23, Type); SHOW_TYPE(Template, 22, Type); \
- SHOW_TYPE(Template, 21, Type); SHOW_TYPE(Template, 20, Type); \
- SHOW_TYPE(Template, 19, Type); SHOW_TYPE(Template, 18, Type); \
- SHOW_TYPE(Template, 17, Type); SHOW_TYPE(Template, 16, Type); \
- SHOW_TYPE(Template, 15, Type); SHOW_TYPE(Template, 14, Type); \
- SHOW_TYPE(Template, 13, Type); SHOW_TYPE(Template, 12, Type); \
- SHOW_TYPE(Template, 11, Type); SHOW_TYPE(Template, 10, Type); \
- SHOW_TYPE(Template, 9, Type); SHOW_TYPE(Template, 8, Type); \
- SHOW_TYPE(Template, 7, Type); SHOW_TYPE(Template, 6, Type); \
- SHOW_TYPE(Template, 5, Type); SHOW_TYPE(Template, 4, Type); \
- SHOW_TYPE(Template, 3, Type); SHOW_TYPE(Template, 2, Type); \
- SHOW_TYPE(Template, 1, Type); SHOW_TYPE(Template, 0, Type)
-
-#define SHOW_SHIFTED_TYPE(Template, Number, Type) SHOW_TYPE(Template, (1UL << Number), Type)
-
-#define SHOW_SHIFTED_TYPES(Template, Type) SHOW_SHIFTED_TYPE(Template, 30, Type); \
- SHOW_SHIFTED_TYPE(Template, 29, Type); SHOW_SHIFTED_TYPE(Template, 28, Type); \
- SHOW_SHIFTED_TYPE(Template, 27, Type); SHOW_SHIFTED_TYPE(Template, 26, Type); \
- SHOW_SHIFTED_TYPE(Template, 25, Type); SHOW_SHIFTED_TYPE(Template, 24, Type); \
- SHOW_SHIFTED_TYPE(Template, 23, Type); SHOW_SHIFTED_TYPE(Template, 22, Type); \
- SHOW_SHIFTED_TYPE(Template, 21, Type); SHOW_SHIFTED_TYPE(Template, 20, Type); \
- SHOW_SHIFTED_TYPE(Template, 19, Type); SHOW_SHIFTED_TYPE(Template, 18, Type); \
- SHOW_SHIFTED_TYPE(Template, 17, Type); SHOW_SHIFTED_TYPE(Template, 16, Type); \
- SHOW_SHIFTED_TYPE(Template, 15, Type); SHOW_SHIFTED_TYPE(Template, 14, Type); \
- SHOW_SHIFTED_TYPE(Template, 13, Type); SHOW_SHIFTED_TYPE(Template, 12, Type); \
- SHOW_SHIFTED_TYPE(Template, 11, Type); SHOW_SHIFTED_TYPE(Template, 10, Type); \
- SHOW_SHIFTED_TYPE(Template, 9, Type); SHOW_SHIFTED_TYPE(Template, 8, Type); \
- SHOW_SHIFTED_TYPE(Template, 7, Type); SHOW_SHIFTED_TYPE(Template, 6, Type); \
- SHOW_SHIFTED_TYPE(Template, 5, Type); SHOW_SHIFTED_TYPE(Template, 4, Type); \
- SHOW_SHIFTED_TYPE(Template, 3, Type); SHOW_SHIFTED_TYPE(Template, 2, Type); \
- SHOW_SHIFTED_TYPE(Template, 1, Type); SHOW_SHIFTED_TYPE(Template, 0, Type)
-
-#define SHOW_POS_SHIFTED_TYPE(Template, Number, Type) SHOW_TYPE(Template, +(1L << Number), Type)
-
-#define SHOW_POS_SHIFTED_TYPES(Template, Type) SHOW_POS_SHIFTED_TYPE(Template, 30, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 29, Type); SHOW_POS_SHIFTED_TYPE(Template, 28, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 27, Type); SHOW_POS_SHIFTED_TYPE(Template, 26, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 25, Type); SHOW_POS_SHIFTED_TYPE(Template, 24, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 23, Type); SHOW_POS_SHIFTED_TYPE(Template, 22, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 21, Type); SHOW_POS_SHIFTED_TYPE(Template, 20, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 19, Type); SHOW_POS_SHIFTED_TYPE(Template, 18, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 17, Type); SHOW_POS_SHIFTED_TYPE(Template, 16, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 15, Type); SHOW_POS_SHIFTED_TYPE(Template, 14, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 13, Type); SHOW_POS_SHIFTED_TYPE(Template, 12, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 11, Type); SHOW_POS_SHIFTED_TYPE(Template, 10, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 9, Type); SHOW_POS_SHIFTED_TYPE(Template, 8, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 7, Type); SHOW_POS_SHIFTED_TYPE(Template, 6, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 5, Type); SHOW_POS_SHIFTED_TYPE(Template, 4, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 3, Type); SHOW_POS_SHIFTED_TYPE(Template, 2, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 1, Type); SHOW_POS_SHIFTED_TYPE(Template, 0, Type)
-
-#define SHOW_NEG_SHIFTED_TYPE(Template, Number, Type) SHOW_TYPE(Template, -(1L << Number), Type)
-
-#define SHOW_NEG_SHIFTED_TYPES(Template, Type) SHOW_NEG_SHIFTED_TYPE(Template, 30, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 29, Type); SHOW_NEG_SHIFTED_TYPE(Template, 28, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 27, Type); SHOW_NEG_SHIFTED_TYPE(Template, 26, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 25, Type); SHOW_NEG_SHIFTED_TYPE(Template, 24, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 23, Type); SHOW_NEG_SHIFTED_TYPE(Template, 22, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 21, Type); SHOW_NEG_SHIFTED_TYPE(Template, 20, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 19, Type); SHOW_NEG_SHIFTED_TYPE(Template, 18, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 17, Type); SHOW_NEG_SHIFTED_TYPE(Template, 16, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 15, Type); SHOW_NEG_SHIFTED_TYPE(Template, 14, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 13, Type); SHOW_NEG_SHIFTED_TYPE(Template, 12, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 11, Type); SHOW_NEG_SHIFTED_TYPE(Template, 10, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 9, Type); SHOW_NEG_SHIFTED_TYPE(Template, 8, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 7, Type); SHOW_NEG_SHIFTED_TYPE(Template, 6, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 5, Type); SHOW_NEG_SHIFTED_TYPE(Template, 4, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 3, Type); SHOW_NEG_SHIFTED_TYPE(Template, 2, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 1, Type); SHOW_NEG_SHIFTED_TYPE(Template, 0, Type)
-
-
-// Test if a constant can fit within a certain type
-#define PRIVATE_FIT_TEST(Template, Number, Type, Value) BOOST_CHECK( Template < Number > :: Type ( Value ) == Value )
-
-#if ULONG_MAX > 0xFFFFFFFFL
-#define PRIVATE_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_FIT_TEST(Template, 64, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 63, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 62, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 61, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 60, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 59, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 58, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 57, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 56, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 55, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 54, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 53, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 52, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 51, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 50, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 49, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 48, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 47, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 46, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 45, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 44, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 43, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 42, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 41, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 40, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 39, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 38, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 37, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 36, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 35, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 34, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 33, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 32, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 31, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 30, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 29, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 28, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 27, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 26, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 25, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 24, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 23, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 22, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 21, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 20, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 19, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 18, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 17, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 16, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 15, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 14, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 13, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 12, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 11, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 10, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 9, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 8, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 7, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 6, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 5, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 4, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 3, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 2, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 1, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 0, Type, v); } while ( false )
-#else
-#define PRIVATE_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_FIT_TEST(Template, 32, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 31, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 30, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 29, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 28, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 27, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 26, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 25, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 24, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 23, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 22, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 21, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 20, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 19, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 18, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 17, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 16, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 15, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 14, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 13, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 12, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 11, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 10, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 9, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 8, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 7, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 6, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 5, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 4, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 3, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 2, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 1, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 0, Type, v); } while ( false )
-#endif
-
-#define PRIVATE_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_CHECK( Template < (ULONG_MAX >> Number) > :: Type ( Value ) == Value )
-
-#define PRIVATE_SHIFTED_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 0, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 1, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 2, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 3, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 4, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 5, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 6, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 7, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 8, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 9, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 10, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 11, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 12, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 13, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 14, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 15, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 16, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 17, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 18, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 19, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 20, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 21, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 22, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 23, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 24, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 25, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 26, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 27, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 28, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 29, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 30, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 31, Type, v); } while ( false )
-
-#define PRIVATE_POS_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_CHECK( Template < (LONG_MAX >> Number) > :: Type ( Value ) == Value )
-
-#define PRIVATE_POS_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 0, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 1, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 2, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 3, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 4, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 5, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 6, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 7, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 8, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 9, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 10, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 11, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 12, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 13, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 14, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 15, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 16, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 17, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 18, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 19, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 20, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 21, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 22, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 23, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 24, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 25, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 26, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 27, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 28, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 29, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 30, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 31, Type, v); } while ( false )
-
-#define PRIVATE_NEG_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_CHECK( Template < (LONG_MIN >> Number) > :: Type ( Value ) == Value )
-
-#define PRIVATE_NEG_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 0, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 1, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 2, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 3, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 4, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 5, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 6, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 7, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 8, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 9, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 10, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 11, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 12, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 13, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 14, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 15, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 16, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 17, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 18, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 19, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 20, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 21, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 22, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 23, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 24, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 25, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 26, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 27, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 28, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 29, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 30, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 31, Type, v); } while ( false )
-
-
-// Test program
-int
-test_main
-(
- int,
- char*[]
-)
-{
-#ifndef BOOST_NO_USING_TEMPLATE
- using boost::int_t;
- using boost::uint_t;
- using boost::int_max_value_t;
- using boost::int_min_value_t;
- using boost::uint_value_t;
-#else
- using namespace boost;
-#endif
-
- SHOW_TYPES( int_t, least );
- SHOW_TYPES( int_t, fast );
- SHOW_TYPES( uint_t, least );
- SHOW_TYPES( uint_t, fast );
- SHOW_POS_SHIFTED_TYPES( int_max_value_t, least );
- SHOW_POS_SHIFTED_TYPES( int_max_value_t, fast );
- SHOW_NEG_SHIFTED_TYPES( int_min_value_t, least );
- SHOW_NEG_SHIFTED_TYPES( int_min_value_t, fast );
- SHOW_SHIFTED_TYPES( uint_value_t, least );
- SHOW_SHIFTED_TYPES( uint_value_t, fast );
-
- PRIVATE_FIT_TESTS( int_t, least, long, LONG_MAX );
- PRIVATE_FIT_TESTS( int_t, fast, long, LONG_MAX );
- PRIVATE_FIT_TESTS( uint_t, least, unsigned long, ULONG_MAX );
- PRIVATE_FIT_TESTS( uint_t, fast, unsigned long, ULONG_MAX );
- PRIVATE_POS_FIT_TESTS( int_max_value_t, least, long, LONG_MAX );
- PRIVATE_POS_FIT_TESTS( int_max_value_t, fast, long, LONG_MAX );
- PRIVATE_NEG_FIT_TESTS( int_min_value_t, least, long, LONG_MIN );
- PRIVATE_NEG_FIT_TESTS( int_min_value_t, fast, long, LONG_MIN );
- PRIVATE_SHIFTED_FIT_TESTS( uint_value_t, least, unsigned long, ULONG_MAX );
- PRIVATE_SHIFTED_FIT_TESTS( uint_value_t, fast, unsigned long, ULONG_MAX );
-
- return boost::exit_success;
-}
Deleted: branches/release/libs/integer/integer_traits_test.cpp
==============================================================================
--- branches/release/libs/integer/integer_traits_test.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,102 +0,0 @@
-/* boost integer_traits.hpp tests
- *
- * Copyright Jens Maurer 2000
- * 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)
- *
- * $Id$
- *
- * Revision history
- * 2000-02-22 Small improvements by Beman Dawes
- * 2000-06-27 Rework for better MSVC and BCC co-operation
- */
-
-#include <iostream>
-#include <boost/integer_traits.hpp>
-// use int64_t instead of long long for better portability
-#include <boost/cstdint.hpp>
-
-#define BOOST_INCLUDE_MAIN
-#include <boost/test/test_tools.hpp>
-
-/*
- * General portability note:
- * MSVC mis-compiles explicit function template instantiations.
- * For example, f<A>() and f<B>() are both compiled to call f<A>().
- * BCC is unable to implicitly convert a "const char *" to a std::string
- * when using explicit function template instantiations.
- *
- * Therefore, avoid explicit function template instantiations.
- */
-
-#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
-template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
-namespace fix{
-inline int make_char_numeric_for_streaming(char c) { return c; }
-inline int make_char_numeric_for_streaming(signed char c) { return c; }
-inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
-}
-using namespace fix;
-#else
-template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
-inline int make_char_numeric_for_streaming(char c) { return c; }
-inline int make_char_numeric_for_streaming(signed char c) { return c; }
-inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
-#endif
-
-template<class T>
-void runtest(const char * type, T)
-{
- typedef boost::integer_traits<T> traits;
- std::cout << "Checking " << type
- << "; min is " << make_char_numeric_for_streaming((traits::min)())
- << ", max is " << make_char_numeric_for_streaming((traits::max)())
- << std::endl;
- BOOST_CHECK(traits::is_specialized);
-#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
- // MSVC++ 6.0 issues a LNK1179 error (duplicate comdat) when the compiler
- // generates different symbol names with a very long common prefix:
- // the dummy "&& true" disambiguates between the symbols generated by this
- // BOOST_CHECK instantiation and the preceding one.
- BOOST_CHECK(traits::is_integer && true);
-#else
- BOOST_CHECK(traits::is_integer);
-#endif
- BOOST_CHECK(traits::is_integral == true);
- BOOST_CHECK(traits::const_min == (traits::min)());
- BOOST_CHECK(traits::const_max == (traits::max)());
-}
-
-int test_main(int, char*[])
-{
- runtest("bool", bool());
- runtest("char", char());
- typedef signed char signed_char;
- runtest("signed char", signed_char());
- typedef unsigned char unsigned_char;
- runtest("unsigned char", unsigned_char());
- runtest("wchar_t", wchar_t());
- runtest("short", short());
- typedef unsigned short unsigned_short;
- runtest("unsigned short", unsigned_short());
- runtest("int", int());
- typedef unsigned int unsigned_int;
- runtest("unsigned int", unsigned_int());
- runtest("long", long());
- typedef unsigned long unsigned_long;
- runtest("unsigned long", unsigned_long());
-#if !defined(BOOST_NO_INT64_T) && (!defined(BOOST_MSVC) || BOOST_MSVC > 1300) && !defined(__BORLANDC__) && !defined(__BEOS__)
- //
- // MS/Borland compilers can't support 64-bit member constants
- // BeOS doesn't have specialisations for long long in SGI's <limits> header.
- runtest("int64_t (possibly long long)", boost::int64_t());
- runtest("uint64_t (possibly unsigned long long)", boost::uint64_t());
-#else
- std::cout << "Skipped int64_t and uint64_t" << std::endl;
-#endif
- // Some compilers don't pay attention to std:3.6.1/5 and issue a
- // warning here if "return 0;" is omitted.
- return 0;
-}
-
Added: branches/release/libs/integer/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/integer/test/Jamfile.v2 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
@@ -0,0 +1,14 @@
+#~ Copyright Rene Rivera 2008
+#~ 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)
+
+import testing ;
+
+test-suite integer
+ : [ run integer_mask_test.cpp
+ /boost/test//boost_unit_test_framework ]
+ [ run static_log2_test.cpp
+ /boost/test//boost_test_exec_monitor/<link>static ]
+ [ run static_min_max_test.cpp
+ /boost/test//boost_test_exec_monitor/<link>static ]
+ ;
Added: branches/release/libs/preprocessor/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/preprocessor/test/Jamfile.v2 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
@@ -0,0 +1,22 @@
+#~ Copyright Rene Rivera 2008
+#~ 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)
+
+import testing ;
+
+test-suite preprocessor
+ : [ compile arithmetic.cpp ]
+ [ compile array.cpp ]
+ [ compile comparison.cpp ]
+ [ compile control.cpp ]
+ [ compile debug.cpp ]
+ [ compile facilities.cpp ]
+ [ compile iteration.cpp ]
+ [ compile list.cpp ]
+ [ compile logical.cpp ]
+ [ compile repetition.cpp ]
+ [ compile selection.cpp ]
+ [ compile seq.cpp ]
+ [ compile slot.cpp ]
+ [ compile tuple.cpp ]
+ ;
Deleted: branches/release/libs/rational/rational_example.cpp
==============================================================================
--- branches/release/libs/rational/rational_example.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,104 +0,0 @@
-// rational number example program ----------------------------------------//
-
-// (C) Copyright Paul Moore 1999. Permission to copy, use, modify, sell
-// and distribute this software is granted provided this copyright notice
-// appears in all copies. This software is provided "as is" without express or
-// implied warranty, and with no claim as to its suitability for any purpose.
-
-// Revision History
-// 14 Dec 99 Initial version
-
-#include <iostream>
-#include <cassert>
-#include <cstdlib>
-#include <boost/config.hpp>
-#ifndef BOOST_NO_LIMITS
-#include <limits>
-#else
-#include <limits.h>
-#endif
-#include <exception>
-#include <boost/rational.hpp>
-
-using std::cout;
-using std::endl;
-using boost::rational;
-
-#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
-// This is a nasty hack, required because MSVC does not implement "Koenig
-// Lookup". Basically, if I call abs(r), the C++ standard says that the
-// compiler should look for a definition of abs in the namespace which
-// contains r's class (in this case boost) - among other places.
-
-// Koenig Lookup is a relatively recent feature, and other compilers may not
-// implement it yet. If so, try including this line.
-
-using boost::abs;
-#endif
-
-int main ()
-{
- rational<int> half(1,2);
- rational<int> one(1);
- rational<int> two(2);
-
- // Some basic checks
- assert(half.numerator() == 1);
- assert(half.denominator() == 2);
- assert(boost::rational_cast<double>(half) == 0.5);
-
- // Arithmetic
- assert(half + half == one);
- assert(one - half == half);
- assert(two * half == one);
- assert(one / half == two);
-
- // With conversions to integer
- assert(half+half == 1);
- assert(2 * half == one);
- assert(2 * half == 1);
- assert(one / half == 2);
- assert(1 / half == 2);
-
- // Sign handling
- rational<int> minus_half(-1,2);
- assert(-half == minus_half);
- assert(abs(minus_half) == half);
-
- // Do we avoid overflow?
-#ifndef BOOST_NO_LIMITS
- int maxint = (std::numeric_limits<int>::max)();
-#else
- int maxint = INT_MAX;
-#endif
- rational<int> big(maxint, 2);
- assert(2 * big == maxint);
-
- // Print some of the above results
- cout << half << "+" << half << "=" << one << endl;
- cout << one << "-" << half << "=" << half << endl;
- cout << two << "*" << half << "=" << one << endl;
- cout << one << "/" << half << "=" << two << endl;
- cout << "abs(" << minus_half << ")=" << half << endl;
- cout << "2 * " << big << "=" << maxint
- << " (rational: " << rational<int>(maxint) << ")" << endl;
-
- // Some extras
- rational<int> pi(22,7);
- cout << "pi = " << boost::rational_cast<double>(pi) << " (nearly)" << endl;
-
- // Exception handling
- try {
- rational<int> r; // Forgot to initialise - set to 0
- r = 1/r; // Boom!
- }
- catch (const boost::bad_rational &e) {
- cout << "Bad rational, as expected: " << e.what() << endl;
- }
- catch (...) {
- cout << "Wrong exception raised!" << endl;
- }
-
- return 0;
-}
-
Deleted: branches/release/libs/rational/rational_test.cpp
==============================================================================
--- branches/release/libs/rational/rational_test.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,968 +0,0 @@
-/*
- * A test program for boost/rational.hpp.
- * Change the typedef at the beginning of run_tests() to try out different
- * integer types. (These tests are designed only for signed integer
- * types. They should work for short, int and long.)
- *
- * (C) Copyright Stephen Silver, 2001. Permission to copy, use, modify, sell
- * and distribute this software is granted provided this copyright notice
- * appears in all copies. This software is provided "as is" without express or
- * implied warranty, and with no claim as to its suitability for any purpose.
- *
- * Incorporated into the boost rational number library, and modified and
- * extended, by Paul Moore, with permission.
- */
-
-// Revision History
-// 05 Nov 06 Add testing of zero-valued denominators & divisors; casting with
-// types that are not implicitly convertible (Daryle Walker)
-// 04 Nov 06 Resolve GCD issue with depreciation (Daryle Walker)
-// 02 Nov 06 Add testing for operator<(int_type) w/ unsigneds (Daryle Walker)
-// 31 Oct 06 Add testing for operator<(rational) overflow (Daryle Walker)
-// 18 Oct 06 Various fixes for old compilers (Joaquín M López Muñoz)
-// 27 Dec 05 Add testing for Boolean conversion operator (Daryle Walker)
-// 24 Dec 05 Change code to use Boost.Test (Daryle Walker)
-// 04 Mar 01 Patches for Intel C++ and GCC (David Abrahams)
-
-#define BOOST_TEST_MAIN "Boost::Rational unit tests"
-
-#include <boost/mpl/list.hpp>
-#include <boost/operators.hpp>
-#include <boost/preprocessor/stringize.hpp>
-#include <boost/math/common_factor_rt.hpp>
-
-#include <boost/rational.hpp>
-
-#include <boost/test/unit_test.hpp>
-#include <boost/test/floating_point_comparison.hpp>
-#include <boost/test/test_case_template.hpp>
-
-#include <climits>
-#include <iostream>
-#include <istream>
-#include <limits>
-#include <ostream>
-#include <sstream>
-#include <stdexcept>
-#include <string>
-
-// We can override this on the compile, as -DINT_TYPE=short or whatever.
-// The default test is against rational<long>.
-#ifndef INT_TYPE
-#define INT_TYPE long
-#endif
-
-namespace {
-
-class MyOverflowingUnsigned;
-
-// This is a trivial user-defined wrapper around the built in int type.
-// It can be used as a test type for rational<>
-class MyInt : boost::operators<MyInt>
-{
- friend class MyOverflowingUnsigned;
- int val;
-public:
- MyInt(int n = 0) : val(n) {}
- friend MyInt operator+ (const MyInt&);
- friend MyInt operator- (const MyInt&);
- MyInt& operator+= (const MyInt& rhs) { val += rhs.val; return *this; }
- MyInt& operator-= (const MyInt& rhs) { val -= rhs.val; return *this; }
- MyInt& operator*= (const MyInt& rhs) { val *= rhs.val; return *this; }
- MyInt& operator/= (const MyInt& rhs) { val /= rhs.val; return *this; }
- MyInt& operator%= (const MyInt& rhs) { val %= rhs.val; return *this; }
- MyInt& operator|= (const MyInt& rhs) { val |= rhs.val; return *this; }
- MyInt& operator&= (const MyInt& rhs) { val &= rhs.val; return *this; }
- MyInt& operator^= (const MyInt& rhs) { val ^= rhs.val; return *this; }
- const MyInt& operator++() { ++val; return *this; }
- const MyInt& operator--() { --val; return *this; }
- bool operator< (const MyInt& rhs) const { return val < rhs.val; }
- bool operator== (const MyInt& rhs) const { return val == rhs.val; }
- bool operator! () const { return !val; }
- friend std::istream& operator>>(std::istream&, MyInt&);
- friend std::ostream& operator<<(std::ostream&, const MyInt&);
-};
-
-inline MyInt operator+(const MyInt& rhs) { return rhs; }
-inline MyInt operator-(const MyInt& rhs) { return MyInt(-rhs.val); }
-inline std::istream& operator>>(std::istream& is, MyInt& i) { is >> i.val; return is; }
-inline std::ostream& operator<<(std::ostream& os, const MyInt& i) { os << i.val; return os; }
-inline MyInt abs(MyInt rhs) { if (rhs < MyInt()) rhs = -rhs; return rhs; }
-
-// This is an "unsigned" wrapper, that throws on overflow. It can be used to
-// test rational<> when an operation goes out of bounds.
-class MyOverflowingUnsigned
- : private boost::unit_steppable<MyOverflowingUnsigned>
- , private boost::ordered_euclidian_ring_operators1<MyOverflowingUnsigned>
-{
- // Helper type-aliases
- typedef MyOverflowingUnsigned self_type;
- typedef unsigned self_type::* bool_type;
-
- // Member data
- unsigned v_;
-
-public:
- // Exception base class
- class exception_base { protected: virtual ~exception_base() throw() {} };
-
- // Divide-by-zero exception class
- class divide_by_0_error
- : public virtual exception_base
- , public std::domain_error
- {
- public:
- explicit divide_by_0_error( std::string const &w )
- : std::domain_error( w ) {}
-
- virtual ~divide_by_0_error() throw() {}
- };
-
- // Overflow exception class
- class overflowing_error
- : public virtual exception_base
- , public std::overflow_error
- {
- public:
- explicit overflowing_error( std::string const &w )
- : std::overflow_error( w ) {}
-
- virtual ~overflowing_error() throw() {}
- };
-
- // Lifetime management (use automatic dtr & copy-ctr)
- MyOverflowingUnsigned( unsigned v = 0 ) : v_( v ) {}
- explicit MyOverflowingUnsigned( MyInt const &m ) : v_( m.val ) {}
-
- // Operators (use automatic copy-assignment); arithmetic & comparison only
- self_type & operator ++()
- {
- if ( this->v_ == UINT_MAX ) throw overflowing_error( "increment" );
- else ++this->v_;
- return *this;
- }
- self_type & operator --()
- {
- if ( !this->v_ ) throw overflowing_error( "decrement" );
- else --this->v_;
- return *this;
- }
-
- operator bool_type() const { return this->v_ ? &self_type::v_ : 0; }
-
- bool operator !() const { return !this->v_; }
- self_type operator +() const { return self_type( +this->v_ ); }
- self_type operator -() const { return self_type( -this->v_ ); }
-
- bool operator <(self_type const &r) const { return this->v_ < r.v_; }
- bool operator ==(self_type const &r) const { return this->v_ == r.v_; }
-
- self_type & operator *=( self_type const &r )
- {
- if ( r.v_ && this->v_ > UINT_MAX / r.v_ )
- {
- throw overflowing_error( "oversized factors" );
- }
- this->v_ *= r.v_;
- return *this;
- }
- self_type & operator /=( self_type const &r )
- {
- if ( !r.v_ ) throw divide_by_0_error( "division" );
- this->v_ /= r.v_;
- return *this;
- }
- self_type & operator %=( self_type const &r )
- {
- if ( !r.v_ ) throw divide_by_0_error( "modulus" );
- this->v_ %= r.v_;
- return *this;
- }
- self_type & operator +=( self_type const &r )
- {
- if ( this->v_ > UINT_MAX - r.v_ )
- {
- throw overflowing_error( "oversized addends" );
- }
- this->v_ += r.v_;
- return *this;
- }
- self_type & operator -=( self_type const &r )
- {
- if ( this->v_ < r.v_ )
- {
- throw overflowing_error( "oversized subtrahend" );
- }
- this->v_ -= r.v_;
- return *this;
- }
-
- // Input & output
- template < typename Ch, class Tr >
- friend std::basic_istream<Ch, Tr> &
- operator >>( std::basic_istream<Ch, Tr> &i, self_type &x )
- { return i >> x.v_; }
-
- template < typename Ch, class Tr >
- friend std::basic_ostream<Ch, Tr> &
- operator <<( std::basic_ostream<Ch, Tr> &o, self_type const &x )
- { return o << x.v_; }
-
-}; // MyOverflowingUnsigned
-
-inline MyOverflowingUnsigned abs( MyOverflowingUnsigned const &x ) { return x; }
-
-} // namespace
-
-
-// Specialize numeric_limits for the custom types
-namespace std
-{
-
-template < >
-class numeric_limits< MyInt >
-{
- typedef numeric_limits<int> limits_type;
-
-public:
- static const bool is_specialized = limits_type::is_specialized;
-
- static MyInt min() throw() { return limits_type::min(); }
- static MyInt max() throw() { return limits_type::max(); }
-
- static const int digits = limits_type::digits;
- static const int digits10 = limits_type::digits10;
- static const bool is_signed = limits_type::is_signed;
- static const bool is_integer = limits_type::is_integer;
- static const bool is_exact = limits_type::is_exact;
- static const int radix = limits_type::radix;
- static MyInt epsilon() throw() { return limits_type::epsilon(); }
- static MyInt round_error() throw() { return limits_type::round_error(); }
-
- static const int min_exponent = limits_type::min_exponent;
- static const int min_exponent10 = limits_type::min_exponent10;
- static const int max_exponent = limits_type::max_exponent;
- static const int max_exponent10 = limits_type::max_exponent10;
-
- static const bool has_infinity = limits_type::has_infinity;
- static const bool has_quiet_NaN = limits_type::has_quiet_NaN;
- static const bool has_signaling_NaN = limits_type::has_signaling_NaN;
- static const float_denorm_style has_denorm = limits_type::has_denorm;
- static const bool has_denorm_loss = limits_type::has_denorm_loss;
-
- static MyInt infinity() throw() { return limits_type::infinity(); }
- static MyInt quiet_NaN() throw() { return limits_type::quiet_NaN(); }
- static MyInt signaling_NaN() throw() {return limits_type::signaling_NaN();}
- static MyInt denorm_min() throw() { return limits_type::denorm_min(); }
-
- static const bool is_iec559 = limits_type::is_iec559;
- static const bool is_bounded = limits_type::is_bounded;
- static const bool is_modulo = limits_type::is_modulo;
-
- static const bool traps = limits_type::traps;
- static const bool tinyness_before = limits_type::tinyness_before;
- static const float_round_style round_style = limits_type::round_style;
-
-}; // std::numeric_limits<MyInt>
-
-template < >
-class numeric_limits< MyOverflowingUnsigned >
-{
- typedef numeric_limits<unsigned> limits_type;
-
-public:
- static const bool is_specialized = limits_type::is_specialized;
-
- static MyOverflowingUnsigned min() throw() { return limits_type::min(); }
- static MyOverflowingUnsigned max() throw() { return limits_type::max(); }
-
- static const int digits = limits_type::digits;
- static const int digits10 = limits_type::digits10;
- static const bool is_signed = limits_type::is_signed;
- static const bool is_integer = limits_type::is_integer;
- static const bool is_exact = limits_type::is_exact;
- static const int radix = limits_type::radix;
- static MyOverflowingUnsigned epsilon() throw()
- { return limits_type::epsilon(); }
- static MyOverflowingUnsigned round_error() throw()
- {return limits_type::round_error();}
-
- static const int min_exponent = limits_type::min_exponent;
- static const int min_exponent10 = limits_type::min_exponent10;
- static const int max_exponent = limits_type::max_exponent;
- static const int max_exponent10 = limits_type::max_exponent10;
-
- static const bool has_infinity = limits_type::has_infinity;
- static const bool has_quiet_NaN = limits_type::has_quiet_NaN;
- static const bool has_signaling_NaN = limits_type::has_signaling_NaN;
- static const float_denorm_style has_denorm = limits_type::has_denorm;
- static const bool has_denorm_loss = limits_type::has_denorm_loss;
-
- static MyOverflowingUnsigned infinity() throw()
- { return limits_type::infinity(); }
- static MyOverflowingUnsigned quiet_NaN() throw()
- { return limits_type::quiet_NaN(); }
- static MyOverflowingUnsigned signaling_NaN() throw()
- { return limits_type::signaling_NaN(); }
- static MyOverflowingUnsigned denorm_min() throw()
- { return limits_type::denorm_min(); }
-
- static const bool is_iec559 = limits_type::is_iec559;
- static const bool is_bounded = limits_type::is_bounded;
- static const bool is_modulo = limits_type::is_modulo;
-
- static const bool traps = limits_type::traps;
- static const bool tinyness_before = limits_type::tinyness_before;
- static const float_round_style round_style = limits_type::round_style;
-
-}; // std::numeric_limits<MyOverflowingUnsigned>
-
-} // namespace std
-
-
-namespace {
-
-// This fixture replaces the check of rational's packing at the start of main.
-class rational_size_check
-{
- typedef INT_TYPE int_type;
- typedef ::boost::rational<int_type> rational_type;
-
-public:
- rational_size_check()
- {
- using ::std::cout;
-
- char const * const int_name = BOOST_PP_STRINGIZE( INT_TYPE );
-
- cout << "Running tests for boost::rational<" << int_name << ">\n\n";
-
- cout << "Implementation issue: the minimal size for a rational\n"
- << "is twice the size of the underlying integer type.\n\n";
-
- cout << "Checking to see if space is being wasted.\n"
- << "\tsizeof(" << int_name << ") == " << sizeof( int_type )
- << "\n";
- cout << "\tsizeof(boost::rational<" << int_name << ">) == "
- << sizeof( rational_type ) << "\n\n";
-
- cout << "Implementation has "
- << (
- (sizeof( rational_type ) > 2u * sizeof( int_type ))
- ? "included padding bytes"
- : "minimal size"
- )
- << "\n\n";
- }
-};
-
-// This fixture groups all the common settings.
-class my_configuration
-{
-public:
- template < typename T >
- class hook
- {
- public:
- typedef ::boost::rational<T> rational_type;
-
- private:
- struct parts { rational_type parts_[ 9 ]; };
-
- static parts generate_rationals()
- {
- rational_type r1, r2( 0 ), r3( 1 ), r4( -3 ), r5( 7, 2 ),
- r6( 5, 15 ), r7( 14, -21 ), r8( -4, 6 ),
- r9( -14, -70 );
- parts result;
- result.parts_[0] = r1;
- result.parts_[1] = r2;
- result.parts_[2] = r3;
- result.parts_[3] = r4;
- result.parts_[4] = r5;
- result.parts_[5] = r6;
- result.parts_[6] = r7;
- result.parts_[7] = r8;
- result.parts_[8] = r9;
-
- return result;
- }
-
- parts p_; // Order Dependency
-
- public:
- rational_type ( &r_ )[ 9 ]; // Order Dependency
-
- hook() : p_( generate_rationals() ), r_( p_.parts_ ) {}
- };
-};
-
-// Instead of controlling the integer type needed with a #define, use a list of
-// all available types. Since the headers #included don't change because of the
-// integer #define, only the built-in types and MyInt are available. (Any other
-// arbitrary integer type introduced by the #define would get compiler errors
-// because its header can't be #included.)
-typedef ::boost::mpl::list<short, int, long> builtin_signed_test_types;
-typedef ::boost::mpl::list<short, int, long, MyInt> all_signed_test_types;
-
-// Without these explicit instantiations, MSVC++ 6.5/7.0 does not find
-// some friend operators in certain contexts.
-::boost::rational<short> dummy1;
-::boost::rational<int> dummy2;
-::boost::rational<long> dummy3;
-::boost::rational<MyInt> dummy4;
-::boost::rational<MyOverflowingUnsigned> dummy5;
-
-// Should there be regular tests with unsigned integer types?
-
-} // namespace
-
-
-// Check if rational is the smallest size possible
-BOOST_GLOBAL_FIXTURE( rational_size_check )
-
-
-#if BOOST_CONTROL_RATIONAL_HAS_GCD
-// The factoring function template suite
-BOOST_AUTO_TEST_SUITE( factoring_suite )
-
-// GCD tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( gcd_test, T, all_signed_test_types )
-{
- BOOST_CHECK_EQUAL( boost::gcd<T>( 1, -1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( -1, 1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( 1, 1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( -1, -1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( 0, 0), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( 7, 0), static_cast<T>( 7) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( 0, 9), static_cast<T>( 9) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( -7, 0), static_cast<T>( 7) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( 0, -9), static_cast<T>( 9) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( 42, 30), static_cast<T>( 6) );
- BOOST_CHECK_EQUAL( boost::gcd<T>( 6, -9), static_cast<T>( 3) );
- BOOST_CHECK_EQUAL( boost::gcd<T>(-10, -10), static_cast<T>(10) );
- BOOST_CHECK_EQUAL( boost::gcd<T>(-25, -10), static_cast<T>( 5) );
-}
-
-// LCM tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( lcm_test, T, all_signed_test_types )
-{
- BOOST_CHECK_EQUAL( boost::lcm<T>( 1, -1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( -1, 1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( 1, 1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( -1, -1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( 0, 0), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( 6, 0), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( 0, 7), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( -5, 0), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( 0, -4), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( 18, 30), static_cast<T>(90) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( -6, 9), static_cast<T>(18) );
- BOOST_CHECK_EQUAL( boost::lcm<T>(-10, -10), static_cast<T>(10) );
- BOOST_CHECK_EQUAL( boost::lcm<T>( 25, -10), static_cast<T>(50) );
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-#endif // BOOST_CONTROL_RATIONAL_HAS_GCD
-
-
-// The basic test suite
-BOOST_FIXTURE_TEST_SUITE( basic_rational_suite, my_configuration )
-
-// Initialization tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_initialization_test, T,
- all_signed_test_types )
-{
- my_configuration::hook<T> h;
- boost::rational<T> &r1 = h.r_[ 0 ], &r2 = h.r_[ 1 ], &r3 = h.r_[ 2 ],
- &r4 = h.r_[ 3 ], &r5 = h.r_[ 4 ], &r6 = h.r_[ 5 ],
- &r7 = h.r_[ 6 ], &r8 = h.r_[ 7 ], &r9 = h.r_[ 8 ];
-
- BOOST_CHECK_EQUAL( r1.numerator(), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( r2.numerator(), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( r3.numerator(), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( r4.numerator(), static_cast<T>(-3) );
- BOOST_CHECK_EQUAL( r5.numerator(), static_cast<T>( 7) );
- BOOST_CHECK_EQUAL( r6.numerator(), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( r7.numerator(), static_cast<T>(-2) );
- BOOST_CHECK_EQUAL( r8.numerator(), static_cast<T>(-2) );
- BOOST_CHECK_EQUAL( r9.numerator(), static_cast<T>( 1) );
-
- BOOST_CHECK_EQUAL( r1.denominator(), static_cast<T>(1) );
- BOOST_CHECK_EQUAL( r2.denominator(), static_cast<T>(1) );
- BOOST_CHECK_EQUAL( r3.denominator(), static_cast<T>(1) );
- BOOST_CHECK_EQUAL( r4.denominator(), static_cast<T>(1) );
- BOOST_CHECK_EQUAL( r5.denominator(), static_cast<T>(2) );
- BOOST_CHECK_EQUAL( r6.denominator(), static_cast<T>(3) );
- BOOST_CHECK_EQUAL( r7.denominator(), static_cast<T>(3) );
- BOOST_CHECK_EQUAL( r8.denominator(), static_cast<T>(3) );
- BOOST_CHECK_EQUAL( r9.denominator(), static_cast<T>(5) );
-
- BOOST_CHECK_THROW( boost::rational<T>( 3, 0), boost::bad_rational );
- BOOST_CHECK_THROW( boost::rational<T>(-2, 0), boost::bad_rational );
- BOOST_CHECK_THROW( boost::rational<T>( 0, 0), boost::bad_rational );
-}
-
-// Assignment (non-operator) tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_assign_test, T, all_signed_test_types )
-{
- my_configuration::hook<T> h;
- boost::rational<T> & r = h.r_[ 0 ];
-
- r.assign( 6, 8 );
- BOOST_CHECK_EQUAL( r.numerator(), static_cast<T>(3) );
- BOOST_CHECK_EQUAL( r.denominator(), static_cast<T>(4) );
-
- r.assign( 0, -7 );
- BOOST_CHECK_EQUAL( r.numerator(), static_cast<T>(0) );
- BOOST_CHECK_EQUAL( r.denominator(), static_cast<T>(1) );
-
- BOOST_CHECK_THROW( r.assign( 4, 0), boost::bad_rational );
- BOOST_CHECK_THROW( r.assign( 0, 0), boost::bad_rational );
- BOOST_CHECK_THROW( r.assign(-7, 0), boost::bad_rational );
-}
-
-// Comparison tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_comparison_test, T,
- all_signed_test_types )
-{
- my_configuration::hook<T> h;
- boost::rational<T> &r1 = h.r_[ 0 ], &r2 = h.r_[ 1 ], &r3 = h.r_[ 2 ],
- &r4 = h.r_[ 3 ], &r5 = h.r_[ 4 ], &r6 = h.r_[ 5 ],
- &r7 = h.r_[ 6 ], &r8 = h.r_[ 7 ], &r9 = h.r_[ 8 ];
-
- BOOST_CHECK( r1 == r2 );
- BOOST_CHECK( r2 != r3 );
- BOOST_CHECK( r4 < r3 );
- BOOST_CHECK( r4 <= r5 );
- BOOST_CHECK( r1 <= r2 );
- BOOST_CHECK( r5 > r6 );
- BOOST_CHECK( r5 >= r6 );
- BOOST_CHECK( r7 >= r8 );
-
- BOOST_CHECK( !(r3 == r2) );
- BOOST_CHECK( !(r1 != r2) );
- BOOST_CHECK( !(r1 < r2) );
- BOOST_CHECK( !(r5 < r6) );
- BOOST_CHECK( !(r9 <= r2) );
- BOOST_CHECK( !(r8 > r7) );
- BOOST_CHECK( !(r8 > r2) );
- BOOST_CHECK( !(r4 >= r6) );
-
- BOOST_CHECK( r1 == static_cast<T>( 0) );
- BOOST_CHECK( r2 != static_cast<T>(-1) );
- BOOST_CHECK( r3 < static_cast<T>( 2) );
- BOOST_CHECK( r4 <= static_cast<T>(-3) );
- BOOST_CHECK( r5 > static_cast<T>( 3) );
- BOOST_CHECK( r6 >= static_cast<T>( 0) );
-
- BOOST_CHECK( static_cast<T>( 0) == r2 );
- BOOST_CHECK( static_cast<T>( 0) != r7 );
- BOOST_CHECK( static_cast<T>(-1) < r8 );
- BOOST_CHECK( static_cast<T>(-2) <= r9 );
- BOOST_CHECK( static_cast<T>( 1) > r1 );
- BOOST_CHECK( static_cast<T>( 1) >= r3 );
-
- // Extra tests with values close in continued-fraction notation
- boost::rational<T> const x1( static_cast<T>(9), static_cast<T>(4) );
- boost::rational<T> const x2( static_cast<T>(61), static_cast<T>(27) );
- boost::rational<T> const x3( static_cast<T>(52), static_cast<T>(23) );
- boost::rational<T> const x4( static_cast<T>(70), static_cast<T>(31) );
-
- BOOST_CHECK( x1 < x2 );
- BOOST_CHECK( !(x1 < x1) );
- BOOST_CHECK( !(x2 < x2) );
- BOOST_CHECK( !(x2 < x1) );
- BOOST_CHECK( x2 < x3 );
- BOOST_CHECK( x4 < x2 );
- BOOST_CHECK( !(x3 < x4) );
- BOOST_CHECK( r7 < x1 ); // not actually close; wanted -ve v. +ve instead
- BOOST_CHECK( !(x2 < r7) );
-}
-
-// Increment & decrement tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_1step_test, T, all_signed_test_types )
-{
- my_configuration::hook<T> h;
- boost::rational<T> &r1 = h.r_[ 0 ], &r2 = h.r_[ 1 ], &r3 = h.r_[ 2 ],
- &r7 = h.r_[ 6 ], &r8 = h.r_[ 7 ];
-
- BOOST_CHECK( r1++ == r2 );
- BOOST_CHECK( r1 != r2 );
- BOOST_CHECK( r1 == r3 );
- BOOST_CHECK( --r1 == r2 );
- BOOST_CHECK( r8-- == r7 );
- BOOST_CHECK( r8 != r7 );
- BOOST_CHECK( ++r8 == r7 );
-}
-
-// Absolute value tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_abs_test, T, all_signed_test_types )
-{
- typedef my_configuration::hook<T> hook_type;
- typedef typename hook_type::rational_type rational_type;
-
- hook_type h;
- rational_type &r2 = h.r_[ 1 ], &r5 = h.r_[ 4 ], &r8 = h.r_[ 7 ];
-
-#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
- // This is a nasty hack, required because some compilers do not implement
- // "Koenig Lookup." Basically, if I call abs(r), the C++ standard says that
- // the compiler should look for a definition of abs in the namespace which
- // contains r's class (in this case boost)--among other places.
-
- using boost::abs;
-#endif
-
- BOOST_CHECK_EQUAL( abs(r2), r2 );
- BOOST_CHECK_EQUAL( abs(r5), r5 );
- BOOST_CHECK_EQUAL( abs(r8), rational_type(2, 3) );
-}
-
-// Unary operator tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_unary_test, T, all_signed_test_types )
-{
- my_configuration::hook<T> h;
- boost::rational<T> &r2 = h.r_[ 1 ], &r3 = h.r_[ 2 ],
- &r4 = h.r_[ 3 ], &r5 = h.r_[ 4 ];
-
- BOOST_CHECK_EQUAL( +r5, r5 );
-
- BOOST_CHECK( -r3 != r3 );
- BOOST_CHECK_EQUAL( -(-r3), r3 );
- BOOST_CHECK_EQUAL( -r4, static_cast<T>(3) );
-
- BOOST_CHECK( !r2 );
- BOOST_CHECK( !!r3 );
-
- BOOST_CHECK( ! static_cast<bool>(r2) );
- BOOST_CHECK( r3 );
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-
-// The rational arithmetic operations suite
-BOOST_AUTO_TEST_SUITE( rational_arithmetic_suite )
-
-// Addition & subtraction tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_additive_test, T,
- all_signed_test_types )
-{
- typedef boost::rational<T> rational_type;
-
- BOOST_CHECK_EQUAL( rational_type( 1, 2) + rational_type(1, 2),
- static_cast<T>(1) );
- BOOST_CHECK_EQUAL( rational_type(11, 3) + rational_type(1, 2),
- rational_type( 25, 6) );
- BOOST_CHECK_EQUAL( rational_type(-8, 3) + rational_type(1, 5),
- rational_type(-37, 15) );
- BOOST_CHECK_EQUAL( rational_type(-7, 6) + rational_type(1, 7),
- rational_type( 1, 7) - rational_type(7, 6) );
- BOOST_CHECK_EQUAL( rational_type(13, 5) - rational_type(1, 2),
- rational_type( 21, 10) );
- BOOST_CHECK_EQUAL( rational_type(22, 3) + static_cast<T>(1),
- rational_type( 25, 3) );
- BOOST_CHECK_EQUAL( rational_type(12, 7) - static_cast<T>(2),
- rational_type( -2, 7) );
- BOOST_CHECK_EQUAL( static_cast<T>(3) + rational_type(4, 5),
- rational_type( 19, 5) );
- BOOST_CHECK_EQUAL( static_cast<T>(4) - rational_type(9, 2),
- rational_type( -1, 2) );
-
- rational_type r( 11 );
-
- r -= rational_type( 20, 3 );
- BOOST_CHECK_EQUAL( r, rational_type(13, 3) );
-
- r += rational_type( 1, 2 );
- BOOST_CHECK_EQUAL( r, rational_type(29, 6) );
-
- r -= static_cast<T>( 5 );
- BOOST_CHECK_EQUAL( r, rational_type( 1, -6) );
-
- r += rational_type( 1, 5 );
- BOOST_CHECK_EQUAL( r, rational_type( 1, 30) );
-
- r += static_cast<T>( 2 );
- BOOST_CHECK_EQUAL( r, rational_type(61, 30) );
-}
-
-// Assignment tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_assignment_test, T,
- all_signed_test_types )
-{
- typedef boost::rational<T> rational_type;
-
- rational_type r;
-
- r = rational_type( 1, 10 );
- BOOST_CHECK_EQUAL( r, rational_type( 1, 10) );
-
- r = static_cast<T>( -9 );
- BOOST_CHECK_EQUAL( r, rational_type(-9, 1) );
-}
-
-// Multiplication tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_multiplication_test, T,
- all_signed_test_types )
-{
- typedef boost::rational<T> rational_type;
-
- BOOST_CHECK_EQUAL( rational_type(1, 3) * rational_type(-3, 4),
- rational_type(-1, 4) );
- BOOST_CHECK_EQUAL( rational_type(2, 5) * static_cast<T>(7),
- rational_type(14, 5) );
- BOOST_CHECK_EQUAL( static_cast<T>(-2) * rational_type(1, 6),
- rational_type(-1, 3) );
-
- rational_type r = rational_type( 3, 7 );
-
- r *= static_cast<T>( 14 );
- BOOST_CHECK_EQUAL( r, static_cast<T>(6) );
-
- r *= rational_type( 3, 8 );
- BOOST_CHECK_EQUAL( r, rational_type(9, 4) );
-}
-
-// Division tests
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_division_test, T,
- all_signed_test_types )
-{
- typedef boost::rational<T> rational_type;
-
- BOOST_CHECK_EQUAL( rational_type(-1, 20) / rational_type(4, 5),
- rational_type(-1, 16) );
- BOOST_CHECK_EQUAL( rational_type( 5, 6) / static_cast<T>(7),
- rational_type( 5, 42) );
- BOOST_CHECK_EQUAL( static_cast<T>(8) / rational_type(2, 7),
- static_cast<T>(28) );
-
- BOOST_CHECK_THROW( rational_type(23, 17) / rational_type(),
- boost::bad_rational );
- BOOST_CHECK_THROW( rational_type( 4, 15) / static_cast<T>(0),
- boost::bad_rational );
-
- rational_type r = rational_type( 4, 3 );
-
- r /= rational_type( 5, 4 );
- BOOST_CHECK_EQUAL( r, rational_type(16, 15) );
-
- r /= static_cast<T>( 4 );
- BOOST_CHECK_EQUAL( r, rational_type( 4, 15) );
-
- BOOST_CHECK_THROW( r /= rational_type(), boost::bad_rational );
- BOOST_CHECK_THROW( r /= static_cast<T>(0), boost::bad_rational );
-
- BOOST_CHECK_EQUAL( rational_type(-1) / rational_type(-3),
- rational_type(1, 3) );
-}
-
-// Tests for operations on self
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_self_operations_test, T,
- all_signed_test_types )
-{
- typedef boost::rational<T> rational_type;
-
- rational_type r = rational_type( 4, 3 );
-
- r += r;
- BOOST_CHECK_EQUAL( r, rational_type( 8, 3) );
-
- r *= r;
- BOOST_CHECK_EQUAL( r, rational_type(64, 9) );
-
- r /= r;
- BOOST_CHECK_EQUAL( r, rational_type( 1, 1) );
-
- r -= r;
- BOOST_CHECK_EQUAL( r, rational_type( 0, 1) );
-
- BOOST_CHECK_THROW( r /= r, boost::bad_rational );
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-
-// The non-basic rational operations suite
-BOOST_AUTO_TEST_SUITE( rational_extras_suite )
-
-// Output test
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_output_test, T, all_signed_test_types )
-{
- std::ostringstream oss;
-
- oss << boost::rational<T>( 44, 14 );
- BOOST_CHECK_EQUAL( oss.str(), "22/7" );
-}
-
-// Input test, failing
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_input_failing_test, T,
- all_signed_test_types )
-{
- std::istringstream iss( "" );
- boost::rational<T> r;
-
- iss >> r;
- BOOST_CHECK( !iss );
-
- iss.clear();
- iss.str( "42" );
- iss >> r;
- BOOST_CHECK( !iss );
-
- iss.clear();
- iss.str( "57A" );
- iss >> r;
- BOOST_CHECK( !iss );
-
- iss.clear();
- iss.str( "20-20" );
- iss >> r;
- BOOST_CHECK( !iss );
-
- iss.clear();
- iss.str( "1/" );
- iss >> r;
- BOOST_CHECK( !iss );
-
- iss.clear();
- iss.str( "1/ 2" );
- iss >> r;
- BOOST_CHECK( !iss );
-
- iss.clear();
- iss.str( "1 /2" );
- iss >> r;
- BOOST_CHECK( !iss );
-}
-
-// Input test, passing
-BOOST_AUTO_TEST_CASE_TEMPLATE( rational_input_passing_test, T,
- all_signed_test_types )
-{
- typedef boost::rational<T> rational_type;
-
- std::istringstream iss( "1/2 12" );
- rational_type r;
- int n = 0;
-
- BOOST_CHECK( iss >> r >> n );
- BOOST_CHECK_EQUAL( r, rational_type(1, 2) );
- BOOST_CHECK_EQUAL( n, 12 );
-
- iss.clear();
- iss.str( "34/67" );
- BOOST_CHECK( iss >> r );
- BOOST_CHECK_EQUAL( r, rational_type(34, 67) );
-
- iss.clear();
- iss.str( "-3/-6" );
- BOOST_CHECK( iss >> r );
- BOOST_CHECK_EQUAL( r, rational_type(1, 2) );
-}
-
-// Conversion test
-BOOST_AUTO_TEST_CASE( rational_cast_test )
-{
- // Note that these are not generic. The problem is that rational_cast<T>
- // requires a conversion from IntType to T. However, for a user-defined
- // IntType, it is not possible to define such a conversion except as an
- // "operator T()". This causes problems with overloading resolution.
- boost::rational<int> const half( 1, 2 );
-
- BOOST_CHECK_CLOSE( boost::rational_cast<double>(half), 0.5, 0.01 );
- BOOST_CHECK_EQUAL( boost::rational_cast<int>(half), 0 );
- BOOST_CHECK_EQUAL( boost::rational_cast<MyInt>(half), MyInt() );
- BOOST_CHECK_EQUAL( boost::rational_cast<boost::rational<MyInt> >(half),
- boost::rational<MyInt>(1, 2) );
-
- // Conversions via explicit-marked constructors
- // (Note that the "explicit" mark prevents conversion to
- // boost::rational<MyOverflowingUnsigned>.)
- boost::rational<MyInt> const threehalves( 3, 2 );
-
- BOOST_CHECK_EQUAL( boost::rational_cast<MyOverflowingUnsigned>(threehalves),
- MyOverflowingUnsigned(1u) );
-}
-
-// Dice tests (a non-main test)
-BOOST_AUTO_TEST_CASE_TEMPLATE( dice_roll_test, T, all_signed_test_types )
-{
- typedef boost::rational<T> rational_type;
-
- // Determine the mean number of times a fair six-sided die
- // must be thrown until each side has appeared at least once.
- rational_type r = T( 0 );
-
- for ( int i = 1 ; i <= 6 ; ++i )
- {
- r += rational_type( 1, i );
- }
- r *= static_cast<T>( 6 );
-
- BOOST_CHECK_EQUAL( r, rational_type(147, 10) );
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-
-// The bugs, patches, and requests checking suite
-BOOST_AUTO_TEST_SUITE( bug_patch_request_suite )
-
-// "rational operator< can overflow"
-BOOST_AUTO_TEST_CASE( bug_798357_test )
-{
- // Choose values such that rational-number comparisons will overflow if
- // the multiplication method (n1/d1 ? n2/d2 == n1*d2 ? n2*d1) is used.
- // (And make sure that the large components are relatively prime, so they
- // won't partially cancel to make smaller, more reasonable, values.)
- unsigned const n1 = UINT_MAX - 2u, d1 = UINT_MAX - 1u;
- unsigned const n2 = d1, d2 = UINT_MAX;
- boost::rational<MyOverflowingUnsigned> const r1( n1, d1 ), r2( n2, d2 );
-
- BOOST_REQUIRE_EQUAL( boost::math::gcd(n1, d1), 1u );
- BOOST_REQUIRE_EQUAL( boost::math::gcd(n2, d2), 1u );
- BOOST_REQUIRE( n1 > UINT_MAX / d2 );
- BOOST_REQUIRE( n2 > UINT_MAX / d1 );
- BOOST_CHECK( r1 < r2 );
- BOOST_CHECK( !(r1 < r1) );
- BOOST_CHECK( !(r2 < r1) );
-}
-
-// "rational::operator< fails for unsigned value types"
-BOOST_AUTO_TEST_CASE( patch_1434821_test )
-{
- // If a zero-rational v. positive-integer comparison involves negation, then
- // it may fail with unsigned types, which wrap around (for built-ins) or
- // throw/be-undefined (for user-defined types).
- boost::rational<unsigned> const r( 0u );
-
- BOOST_CHECK( r < 1u );
-}
-
-// "rational.hpp::gcd returns a negative value sometimes"
-BOOST_AUTO_TEST_CASE( patch_1438626_test )
-{
- // The issue only manifests with 2's-complement integers that use their
- // entire range of bits. [This means that ln(-INT_MIN)/ln(2) is an integer
- // and INT_MAX + INT_MIN == -1.] The common computer platforms match this.
-#if (INT_MAX + INT_MIN == -1) && ((INT_MAX ^ INT_MIN) == -1)
- // If a GCD routine takes the absolute value of an argument only before
- // processing, it won't realize that -INT_MIN -> INT_MIN (i.e. no change
- // from negation) and will propagate a negative sign to its result.
- BOOST_REQUIRE_EQUAL( boost::math::gcd(INT_MIN, 6), 2 );
-
- // That is bad if the rational number type does not check for that
- // possibility during normalization.
- boost::rational<int> const r1( INT_MIN / 2 + 3, 6 ),
- r2( INT_MIN / 2 - 3, 6 ), r3 = r1 + r2;
-
- // If the error happens, the signs of the components will be switched.
- // (The numerators' sum is INT_MIN, and its GCD with 6 would be negated.)
- BOOST_CHECK_EQUAL( r3.numerator(), INT_MIN / 2 );
- BOOST_CHECK_EQUAL( r3.denominator(), 3 );
-#endif
-}
-
-BOOST_AUTO_TEST_SUITE_END()
Added: branches/release/libs/rational/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/rational/test/Jamfile.v2 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
@@ -0,0 +1,11 @@
+#~ Copyright Rene Rivera 2008
+#~ 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)
+
+import testing ;
+
+test-suite rational
+ : [ run rational_example.cpp ]
+ [ run rational_test.cpp
+ /boost/test//boost_unit_test_framework/<link>static ]
+ ;
Added: branches/release/libs/timer/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/timer/test/Jamfile.v2 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
@@ -0,0 +1,9 @@
+#~ Copyright Rene Rivera 2008
+#~ 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)
+
+import testing ;
+
+test-suite timer
+ : [ compile timer_test.cpp ]
+ ;
Deleted: branches/release/libs/timer/timer_test.cpp
==============================================================================
--- branches/release/libs/timer/timer_test.cpp 2009-01-04 00:17:02 EST (Sun, 04 Jan 2009)
+++ (empty file)
@@ -1,89 +0,0 @@
-// timer, job_timer, and progress_display sample program -------------------//
-
-// Copyright Beman Dawes 1998. 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/libs/timer for documentation.
-
-// Revision History
-// 12 Jan 01 Cut time to 1.0 secs to speed regression tests (Beman Dawes)
-// 25 Sep 99 added elapsed_min() and elapsed_max() reporting
-// 16 Jul 99 Second beta
-// 6 Jul 99 Initial boost version
-
-#include <boost/progress.hpp>
-#include <iostream>
-#include <climits>
-
-using boost::timer;
-using boost::progress_timer;
-using boost::progress_display;
-using std::cout;
-using std::endl;
-
-int main() {
-
- timer t0; // used only for elapsed_max() and elapsed_min()
-
- cout << "timer::elapased_min() reports " << t0.elapsed_min() << " seconds\n";
- cout << "timer::elapased_max() reports " << t0.elapsed_max()
- << " seconds, which is " << t0.elapsed_max()/3600.0 << " hours\n";
-
- cout << "\nverify progress_display(0) doesn't divide by zero" << endl;
- progress_display zero( 0 ); // verify 0 doesn't divide by zero
- ++zero;
-
- long loops;
- timer loop_timer;
- const double time = 1.0;
-
- cout << "\ndetermine " << time << " second iteration count" << endl;
- for ( loops = 0; loops < LONG_MAX
- && loop_timer.elapsed() < time; ++loops ) {}
- cout << loops << " iterations"<< endl;
-
- long i;
- bool time_waster; // defeat [some] optimizers by storing result here
-
- progress_timer pt;
- timer t1;
- timer t4;
- timer t5;
-
- cout << "\nburn about " << time << " seconds" << endl;
- progress_display pd( loops );
- for ( i = loops; i--; )
- { time_waster = loop_timer.elapsed() < time; ++pd; }
-
- timer t2( t1 );
- timer t3;
- t4 = t3;
- t5.restart();
-
- cout << "\nburn about " << time << " seconds again" << endl;
- pd.restart( loops );
- for ( i = loops; i--; )
- { time_waster = loop_timer.elapsed() < time; ++pd; }
-
- if ( time_waster ) cout << ' '; // using time_waster quiets compiler warnings
- progress_display pd2( 50, cout, "\nLead string 1 ", "Lead string 2 ", "Lead string 3 " );
- for ( ; pd2.count() < 50; ++pd2 ) {}
-
- cout << "\nt1 elapsed: " << t1.elapsed() << '\n';
- cout << "t2 elapsed: " << t2.elapsed() << '\n';
- cout << "t3 elapsed: " << t3.elapsed() << '\n';
- cout << "t4 elapsed: " << t4.elapsed() << '\n';
- cout << "t5 elapsed: " << t5.elapsed() << '\n';
- cout << "t1 and t2 should report the same times (very approximately "
- << 2*time << " seconds).\n";
- cout << "t3, t4 and t5 should report about the same times,\n";
- cout << "and these should be about half the t1 and t2 times.\n";
- cout << "The following elapsed time should be slightly greater than t1."
- << endl;
- return 0;
- } // main
-
-
-
-
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