Boost logo

Boost-Commit :

From: bdawes_at_[hidden]
Date: 2008-08-06 14:34:16


Author: bemandawes
Date: 2008-08-06 14:34:15 EDT (Wed, 06 Aug 2008)
New Revision: 48004
URL: http://svn.boost.org/trac/boost/changeset/48004

Log:
Add BOOST_MINIMAL_INTEGER_COVER_OPERATORS to reduce coupling to boost/operators.hpp, make constructor from T explicit to eliminate unintended consequences, add logging feature, extend test coverage.
Text files modified:
   sandbox/endian/boost/integer/cover_operators.hpp | 40 +++
   sandbox/endian/boost/integer/endian.hpp | 82 ++++++--
   sandbox/endian/libs/integer/test/endian-in-sandbox/endian_operations_test/endian_operations_test.vcproj | 1
   sandbox/endian/libs/integer/test/endian_operations_test.cpp | 351 +++++++++++++++++++++++++++------------
   sandbox/endian/libs/integer/test/endian_test.cpp | 20 +
   5 files changed, 347 insertions(+), 147 deletions(-)

Modified: sandbox/endian/boost/integer/cover_operators.hpp
==============================================================================
--- sandbox/endian/boost/integer/cover_operators.hpp (original)
+++ sandbox/endian/boost/integer/cover_operators.hpp 2008-08-06 14:34:15 EDT (Wed, 06 Aug 2008)
@@ -1,16 +1,26 @@
 // boost/integer/cover_operators.hpp ----------------------------------------//
 
-// (C) Copyright Darin Adler 2000
+// Copyright Darin Adler 2000
+// Copyright Beman Dawes 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)
 
 //----------------------------------------------------------------------------//
 
+// If the class being covered has a non-explicit conversion to an integer type
+// then a smaller number of cover operations are needed. Define the macro
+// BOOST_MINIMAL_INTEGER_COVER_OPERATORS to indicate this.
+
+//----------------------------------------------------------------------------//
+
 #ifndef BOOST_INTEGER_COVER_OPERATORS_HPP
 #define BOOST_INTEGER_COVER_OPERATORS_HPP
 
-#include <boost/operators.hpp>
+# ifndef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
+# include <boost/operators.hpp>
+# endif
+
 #include <iosfwd>
 
 namespace boost
@@ -21,13 +31,17 @@
   // A class that adds integer operators to an integer cover class
 
     template <typename T, typename IntegerType>
- class cover_operators : boost::operators<T>
+ class cover_operators
+# ifndef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
+ : boost::operators<T>
+# endif
     {
       // The other operations take advantage of the type conversion that's
       // built into unary +.
 
       // Unary operations.
       friend IntegerType operator+(const T& x) { return x; }
+# ifndef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
       friend IntegerType operator-(const T& x) { return -+x; }
       friend IntegerType operator~(const T& x) { return ~+x; }
       friend IntegerType operator!(const T& x) { return !+x; }
@@ -35,6 +49,7 @@
       // The basic ordering operations.
       friend bool operator==(const T& x, IntegerType y) { return +x == y; }
       friend bool operator<(const T& x, IntegerType y) { return +x < y; }
+# endif
       
       // The basic arithmetic operations.
       friend T& operator+=(T& x, IntegerType y) { return x = +x + y; }
@@ -57,8 +72,23 @@
       friend T& operator++(T& x) { return x += 1; }
       friend T& operator--(T& x) { return x -= 1; }
 
- /// TODO: stream I/O needs to be templatized on the stream type, so will
- /// work with wide streams, etc.
+# ifdef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
+ friend T operator++(T& x, int)
+ {
+ T tmp(x);
+ x += 1;
+ return tmp;
+ }
+ friend T operator--(T& x, int)
+ {
+ T tmp(x);
+ x -= 1;
+ return tmp;
+ }
+# endif
+
+ // TODO: stream I/O needs to be templatized on the stream type, so will
+ // work with wide streams, etc.
 
       // Stream input and output.
       friend std::ostream& operator<<(std::ostream& s, const T& x)

Modified: sandbox/endian/boost/integer/endian.hpp
==============================================================================
--- sandbox/endian/boost/integer/endian.hpp (original)
+++ sandbox/endian/boost/integer/endian.hpp 2008-08-06 14:34:15 EDT (Wed, 06 Aug 2008)
@@ -26,8 +26,15 @@
 #ifndef BOOST_ENDIAN_HPP
 #define BOOST_ENDIAN_HPP
 
+// Pending updates to boost/config.hpp for C++0x, assume that the C++0x feature
+// we care about is not present:
+#define BOOST_NO_DEFAULTED_FUNCTIONS
+
+#include <boost/config.hpp>
 #include <boost/detail/endian.hpp>
-//#include <boost/integer/cover_operators.hpp>
+#define BOOST_MINIMAL_INTEGER_COVER_OPERATORS
+#include <boost/integer/cover_operators.hpp>
+#undef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
 #include <boost/type_traits/is_signed.hpp>
 #include <boost/cstdint.hpp>
 #include <boost/static_assert.hpp>
@@ -39,9 +46,9 @@
 # endif
 
 # ifndef BOOST_NO_DEFAULTED_FUNCTIONS
-# define BOOST_ENDIAN_DEFAULTED = default; // C++0x
+# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
 # else
-# define BOOST_ENDIAN_DEFAULTED {} // C++03
+# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03
 # endif
 
 # if defined(BOOST_NO_DEFAULTED_FUNCTIONS) && defined(BOOST_ENDIANS_IN_UNIONS)
@@ -142,6 +149,11 @@
   namespace integer
   {
 
+# ifdef BOOST_ENDIAN_LOG
+ bool endian_log(true);
+# endif
+
+
   // endian class template and specializations -----------------------------//
 
   // simulate C++0x scoped enums
@@ -160,17 +172,31 @@
     // unaligned big endian specialization
     template <typename T, std::size_t n_bits>
     class endian< endianness::big, T, n_bits, alignment::unaligned >
- // : cover_operators< endian< endianness::big, T, n_bits >, T >
+ : cover_operators< endian< endianness::big, T, n_bits >, T >
     {
         BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
       public:
         typedef T value_type;
 # ifndef BOOST_ENDIAN_NO_CTORS
- endian() BOOST_ENDIAN_DEFAULTED
- endian(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); }
+ endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
+ explicit endian(T val)
+ {
+# ifdef BOOST_ENDIAN_LOG
+ if ( endian_log )
+ std::clog << "big, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
+# endif
+ detail::store_big_endian<T, n_bits/8>(m_value, val);
+ }
 # endif
         endian & operator=(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); return *this; }
- operator T() const { return detail::load_big_endian<T, n_bits/8>(m_value); }
+ operator T() const
+ {
+# ifdef BOOST_ENDIAN_LOG
+ if ( endian_log )
+ std::clog << "big, unaligned, " << n_bits << "-bits, convert(" << detail::load_big_endian<T, n_bits/8>(m_value) << ")\n";
+# endif
+ return detail::load_big_endian<T, n_bits/8>(m_value);
+ }
       private:
               char m_value[n_bits/8];
     };
@@ -178,17 +204,31 @@
     // unaligned little endian specialization
     template <typename T, std::size_t n_bits>
     class endian< endianness::little, T, n_bits, alignment::unaligned >
-// : cover_operators< endian< endianness::little, T, n_bits >, T >
+ : cover_operators< endian< endianness::little, T, n_bits >, T >
     {
         BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
       public:
         typedef T value_type;
 # ifndef BOOST_ENDIAN_NO_CTORS
- endian() BOOST_ENDIAN_DEFAULTED
- endian(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); }
+ endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
+ explicit endian(T val)
+ {
+# ifdef BOOST_ENDIAN_LOG
+ if ( endian_log )
+ std::clog << "little, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
+# endif
+ detail::store_little_endian<T, n_bits/8>(m_value, val);
+ }
 # endif
         endian & operator=(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); return *this; }
- operator T() const { return detail::load_little_endian<T, n_bits/8>(m_value); }
+ operator T() const
+ {
+# ifdef BOOST_ENDIAN_LOG
+ if ( endian_log )
+ std::clog << "little, unaligned, " << n_bits << "-bits, convert(" << detail::load_little_endian<T, n_bits/8>(m_value) << ")\n";
+# endif
+ return detail::load_little_endian<T, n_bits/8>(m_value);
+ }
       private:
               char m_value[n_bits/8];
     };
@@ -196,17 +236,17 @@
     // unaligned native endian specialization
     template <typename T, std::size_t n_bits>
     class endian< endianness::native, T, n_bits, alignment::unaligned >
-// : cover_operators< endian< endianness::native, T, n_bits >, T >
+ : cover_operators< endian< endianness::native, T, n_bits >, T >
     {
         BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
       public:
         typedef T value_type;
 # ifndef BOOST_ENDIAN_NO_CTORS
- endian() BOOST_ENDIAN_DEFAULTED
+ endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
 # ifdef BOOST_BIG_ENDIAN
- endian(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); }
+ explicit endian(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); }
 # else
- endian(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); }
+ explicit endian(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); }
 # endif
 # endif
 # ifdef BOOST_BIG_ENDIAN
@@ -226,18 +266,18 @@
     // aligned big endian specialization
     template <typename T, std::size_t n_bits>
     class endian< endianness::big, T, n_bits, alignment::aligned >
-// : cover_operators< endian< endianness::big, T, n_bits, alignment::aligned >, T >
+ : cover_operators< endian< endianness::big, T, n_bits, alignment::aligned >, T >
     {
         BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
         BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
       public:
         typedef T value_type;
 # ifndef BOOST_ENDIAN_NO_CTORS
- endian() BOOST_ENDIAN_DEFAULTED
+ endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
 # ifdef BOOST_BIG_ENDIAN
         endian(T val) : m_value(val) { }
 # else
- endian(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); }
+ explicit endian(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); }
 # endif
 # endif
 # ifdef BOOST_BIG_ENDIAN
@@ -254,18 +294,18 @@
     // aligned little endian specialization
     template <typename T, std::size_t n_bits>
     class endian< endianness::little, T, n_bits, alignment::aligned >
-// : cover_operators< endian< endianness::little, T, n_bits, alignment::aligned >, T >
+ : cover_operators< endian< endianness::little, T, n_bits, alignment::aligned >, T >
     {
         BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
         BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
       public:
         typedef T value_type;
 # ifndef BOOST_ENDIAN_NO_CTORS
- endian() BOOST_ENDIAN_DEFAULTED
+ endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
 # ifdef BOOST_BIG_ENDIAN
         endian(T val) : m_value(val) { }
 # else
- endian(T val) { detail::store_little_endian<T, sizeof(T)>(&m_value, val); }
+ explicit endian(T val) { detail::store_little_endian<T, sizeof(T)>(&m_value, val); }
 # endif
 # endif
 # ifdef BOOST_LITTLE_ENDIAN

Modified: sandbox/endian/libs/integer/test/endian-in-sandbox/endian_operations_test/endian_operations_test.vcproj
==============================================================================
--- sandbox/endian/libs/integer/test/endian-in-sandbox/endian_operations_test/endian_operations_test.vcproj (original)
+++ sandbox/endian/libs/integer/test/endian-in-sandbox/endian_operations_test/endian_operations_test.vcproj 2008-08-06 14:34:15 EDT (Wed, 06 Aug 2008)
@@ -49,6 +49,7 @@
                                 UsePrecompiledHeader="0"
                                 WarningLevel="3"
                                 DebugInformationFormat="4"
+ DisableSpecificWarnings="4552"
                         />
                         <Tool
                                 Name="VCManagedResourceCompilerTool"

Modified: sandbox/endian/libs/integer/test/endian_operations_test.cpp
==============================================================================
--- sandbox/endian/libs/integer/test/endian_operations_test.cpp (original)
+++ sandbox/endian/libs/integer/test/endian_operations_test.cpp 2008-08-06 14:34:15 EDT (Wed, 06 Aug 2008)
@@ -2,22 +2,33 @@
 
 // Copyright Beman Dawes 2008
 
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// 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 library home page at http://www.boost.org/libs/endian
 
 //----------------------------------------------------------------------------//
 
+// This test probes operator overloading, including interaction between
+// operand types.
+
+// See endian_test for tests of endianess correctness, size, and value.
+
+//----------------------------------------------------------------------------//
+
+#define BOOST_ENDIAN_LOG
+
 #include <boost/integer/endian.hpp>
 #include <cassert>
+#include <iostream>
+
+namespace bi = boost::integer;
 
 #ifdef _MSC_VER
-# pragma warning( disable : 4244 )
+# pragma warning( disable : 4244 ) // conversion ..., possible loss of data
+# pragma warning( disable : 4018 ) // signed/unsigned mismatch
 #endif
 
-using namespace boost::integer;
-
 template <class T1, class T2>
 struct default_construct
 {
@@ -39,33 +50,72 @@
 };
 
 template <class T1, class T2>
+struct initialize
+{
+ static void test()
+ {
+ T1 o2(2);
+ T1 o1 = o2;
+ }
+};
+
+template <class T1, class T2>
 struct assign
 {
   static void test()
   {
     T2 o2;
- o2 = 123;
+ o2 = 1;
     T1 o1;
- o1 = 02;
+ o1 = o2;
   }
 };
 
 template <class T1, class T2>
-struct pass
+struct relational
 {
   static void test()
   {
+ T1 o1(1);
+ T2 o2(2);
+ if ( o1 == o2 ) return;
+ if ( o1 != o2 ) return;
+ if ( o1 < o2 ) return;
+ if ( o1 <= o2 ) return;
+ if ( o1 > o2 ) return;
+ if ( o1 >= o2 ) return;
   }
 };
 
 template <class T1, class T2>
-struct compare
+struct op_plus
 {
   static void test()
   {
- T1 o1 = 1;
- T2 o2 = 2;
- if (o1 == o2) return;
+ T1 o1(1);
+ T2 o2(2);
+ T1 o3;
+
+ o3 = +o1;
+
+ o3 = o1 + o2;
+
+ o1 += o2;
+ }
+};
+
+template <class T1, class T2>
+struct op_star
+{
+ static void test()
+ {
+ T1 o1(1);
+ T2 o2(2);
+ T1 o3;
+
+ o3 = o1 * o2;
+
+ o1 *= o2;
   }
 };
 
@@ -83,54 +133,54 @@
   Test<T1, unsigned long>::test();
   Test<T1, long long>::test();
   Test<T1, unsigned long long>::test();
- Test<T1, big8_t>::test();
- Test<T1, big16_t>::test();
- Test<T1, big24_t>::test();
- Test<T1, big32_t>::test();
- Test<T1, big40_t>::test();
- Test<T1, big48_t>::test();
- Test<T1, big56_t>::test();
- Test<T1, big64_t>::test();
- Test<T1, ubig8_t>::test();
- Test<T1, ubig16_t>::test();
- Test<T1, ubig24_t>::test();
- Test<T1, ubig32_t>::test();
- Test<T1, ubig40_t>::test();
- Test<T1, ubig48_t>::test();
- Test<T1, ubig56_t>::test();
- Test<T1, ubig64_t>::test();
- Test<T1, little8_t>::test();
- Test<T1, little16_t>::test();
- Test<T1, little24_t>::test();
- Test<T1, little32_t>::test();
- Test<T1, little40_t>::test();
- Test<T1, little48_t>::test();
- Test<T1, little56_t>::test();
- Test<T1, little64_t>::test();
- Test<T1, ulittle8_t>::test();
- Test<T1, ulittle16_t>::test();
- Test<T1, ulittle24_t>::test();
- Test<T1, ulittle32_t>::test();
- Test<T1, ulittle40_t>::test();
- Test<T1, ulittle48_t>::test();
- Test<T1, ulittle56_t>::test();
- Test<T1, ulittle64_t>::test();
- Test<T1, native8_t>::test();
- Test<T1, native16_t>::test();
- Test<T1, native24_t>::test();
- Test<T1, native32_t>::test();
- Test<T1, native40_t>::test();
- Test<T1, native48_t>::test();
- Test<T1, native56_t>::test();
- Test<T1, native64_t>::test();
- Test<T1, unative8_t>::test();
- Test<T1, unative16_t>::test();
- Test<T1, unative24_t>::test();
- Test<T1, unative32_t>::test();
- Test<T1, unative40_t>::test();
- Test<T1, unative48_t>::test();
- Test<T1, unative56_t>::test();
- Test<T1, unative64_t>::test();
+ Test<T1, bi::big8_t>::test();
+ Test<T1, bi::big16_t>::test();
+ Test<T1, bi::big24_t>::test();
+ Test<T1, bi::big32_t>::test();
+ Test<T1, bi::big40_t>::test();
+ Test<T1, bi::big48_t>::test();
+ Test<T1, bi::big56_t>::test();
+ Test<T1, bi::big64_t>::test();
+ Test<T1, bi::ubig8_t>::test();
+ Test<T1, bi::ubig16_t>::test();
+ Test<T1, bi::ubig24_t>::test();
+ Test<T1, bi::ubig32_t>::test();
+ Test<T1, bi::ubig40_t>::test();
+ Test<T1, bi::ubig48_t>::test();
+ Test<T1, bi::ubig56_t>::test();
+ Test<T1, bi::ubig64_t>::test();
+ Test<T1, bi::little8_t>::test();
+ Test<T1, bi::little16_t>::test();
+ Test<T1, bi::little24_t>::test();
+ Test<T1, bi::little32_t>::test();
+ Test<T1, bi::little40_t>::test();
+ Test<T1, bi::little48_t>::test();
+ Test<T1, bi::little56_t>::test();
+ Test<T1, bi::little64_t>::test();
+ Test<T1, bi::ulittle8_t>::test();
+ Test<T1, bi::ulittle16_t>::test();
+ Test<T1, bi::ulittle24_t>::test();
+ Test<T1, bi::ulittle32_t>::test();
+ Test<T1, bi::ulittle40_t>::test();
+ Test<T1, bi::ulittle48_t>::test();
+ Test<T1, bi::ulittle56_t>::test();
+ Test<T1, bi::ulittle64_t>::test();
+ Test<T1, bi::native8_t>::test();
+ Test<T1, bi::native16_t>::test();
+ Test<T1, bi::native24_t>::test();
+ Test<T1, bi::native32_t>::test();
+ Test<T1, bi::native40_t>::test();
+ Test<T1, bi::native48_t>::test();
+ Test<T1, bi::native56_t>::test();
+ Test<T1, bi::native64_t>::test();
+ Test<T1, bi::unative8_t>::test();
+ Test<T1, bi::unative16_t>::test();
+ Test<T1, bi::unative24_t>::test();
+ Test<T1, bi::unative32_t>::test();
+ Test<T1, bi::unative40_t>::test();
+ Test<T1, bi::unative48_t>::test();
+ Test<T1, bi::unative56_t>::test();
+ Test<T1, bi::unative64_t>::test();
 
 }
 
@@ -148,68 +198,141 @@
   op_test_aux<Test, unsigned long>();
   op_test_aux<Test, long long>();
   op_test_aux<Test, unsigned long long>();
- op_test_aux<Test, big8_t>();
- op_test_aux<Test, big16_t>();
- op_test_aux<Test, big24_t>();
- op_test_aux<Test, big32_t>();
- op_test_aux<Test, big40_t>();
- op_test_aux<Test, big48_t>();
- op_test_aux<Test, big56_t>();
- op_test_aux<Test, big64_t>();
- op_test_aux<Test, ubig8_t>();
- op_test_aux<Test, ubig16_t>();
- op_test_aux<Test, ubig24_t>();
- op_test_aux<Test, ubig32_t>();
- op_test_aux<Test, ubig40_t>();
- op_test_aux<Test, ubig48_t>();
- op_test_aux<Test, ubig56_t>();
- op_test_aux<Test, ubig64_t>();
- op_test_aux<Test, little8_t>();
- op_test_aux<Test, little16_t>();
- op_test_aux<Test, little24_t>();
- op_test_aux<Test, little32_t>();
- op_test_aux<Test, little40_t>();
- op_test_aux<Test, little48_t>();
- op_test_aux<Test, little56_t>();
- op_test_aux<Test, little64_t>();
- op_test_aux<Test, ulittle8_t>();
- op_test_aux<Test, ulittle16_t>();
- op_test_aux<Test, ulittle24_t>();
- op_test_aux<Test, ulittle32_t>();
- op_test_aux<Test, ulittle40_t>();
- op_test_aux<Test, ulittle48_t>();
- op_test_aux<Test, ulittle56_t>();
- op_test_aux<Test, ulittle64_t>();
- op_test_aux<Test, native8_t>();
- op_test_aux<Test, native16_t>();
- op_test_aux<Test, native24_t>();
- op_test_aux<Test, native32_t>();
- op_test_aux<Test, native40_t>();
- op_test_aux<Test, native48_t>();
- op_test_aux<Test, native56_t>();
- op_test_aux<Test, native64_t>();
- op_test_aux<Test, unative8_t>();
- op_test_aux<Test, unative16_t>();
- op_test_aux<Test, unative24_t>();
- op_test_aux<Test, unative32_t>();
- op_test_aux<Test, unative40_t>();
- op_test_aux<Test, unative48_t>();
- op_test_aux<Test, unative56_t>();
- op_test_aux<Test, unative64_t>();
+ op_test_aux<Test, bi::big8_t>();
+ op_test_aux<Test, bi::big16_t>();
+ op_test_aux<Test, bi::big24_t>();
+ op_test_aux<Test, bi::big32_t>();
+ op_test_aux<Test, bi::big40_t>();
+ op_test_aux<Test, bi::big48_t>();
+ op_test_aux<Test, bi::big56_t>();
+ op_test_aux<Test, bi::big64_t>();
+ op_test_aux<Test, bi::ubig8_t>();
+ op_test_aux<Test, bi::ubig16_t>();
+ op_test_aux<Test, bi::ubig24_t>();
+ op_test_aux<Test, bi::ubig32_t>();
+ op_test_aux<Test, bi::ubig40_t>();
+ op_test_aux<Test, bi::ubig48_t>();
+ op_test_aux<Test, bi::ubig56_t>();
+ op_test_aux<Test, bi::ubig64_t>();
+ op_test_aux<Test, bi::little8_t>();
+ op_test_aux<Test, bi::little16_t>();
+ op_test_aux<Test, bi::little24_t>();
+ op_test_aux<Test, bi::little32_t>();
+ op_test_aux<Test, bi::little40_t>();
+ op_test_aux<Test, bi::little48_t>();
+ op_test_aux<Test, bi::little56_t>();
+ op_test_aux<Test, bi::little64_t>();
+ op_test_aux<Test, bi::ulittle8_t>();
+ op_test_aux<Test, bi::ulittle16_t>();
+ op_test_aux<Test, bi::ulittle24_t>();
+ op_test_aux<Test, bi::ulittle32_t>();
+ op_test_aux<Test, bi::ulittle40_t>();
+ op_test_aux<Test, bi::ulittle48_t>();
+ op_test_aux<Test, bi::ulittle56_t>();
+ op_test_aux<Test, bi::ulittle64_t>();
+ op_test_aux<Test, bi::native8_t>();
+ op_test_aux<Test, bi::native16_t>();
+ op_test_aux<Test, bi::native24_t>();
+ op_test_aux<Test, bi::native32_t>();
+ op_test_aux<Test, bi::native40_t>();
+ op_test_aux<Test, bi::native48_t>();
+ op_test_aux<Test, bi::native56_t>();
+ op_test_aux<Test, bi::native64_t>();
+ op_test_aux<Test, bi::unative8_t>();
+ op_test_aux<Test, bi::unative16_t>();
+ op_test_aux<Test, bi::unative24_t>();
+ op_test_aux<Test, bi::unative32_t>();
+ op_test_aux<Test, bi::unative40_t>();
+ op_test_aux<Test, bi::unative48_t>();
+ op_test_aux<Test, bi::unative56_t>();
+ op_test_aux<Test, bi::unative64_t>();
 }
 
 int main()
 {
-
+ bi::endian_log = false;
+
+ // make sure some simple things work
+
+ bi::big32_t o1(1);
+ bi::big32_t o2(2L);
+ bi::big32_t o3(3LL);
+ bi::big64_t o4(1);
+
+ // use cases; if BOOST_ENDIAN_LOG is defined, will output to clog info on
+ // what overloads and conversions are actually being performed.
+
+ bi::endian_log = true;
+
+ std::clog << "set up test values\n";
+ bi::big32_t big(12345);
+ bi::ulittle16_t ulittle(10);
+ bi::big64_t result;
+
+
+ std::clog << "\nresult = +big\n";
+ result = +big;
+
+ std::clog << "\nresult = -big\n";
+ result = -big;
+
+ std::clog << "\n++big\n";
+ ++big;
+
+ std::clog << "\nresult = big++\n";
+ big++;
+
+ std::clog << "\n--big\n";
+ --big;
+
+ std::clog << "\nbig--\n";
+ big--;
 
- big32_t o1(1);
- big32_t o2(2L);
- big32_t o3(3LL);
+ std::clog << "\nresult = big * big\n";
+ result = big * big;
+
+ std::clog << "\nresult = big * big\n";
+ result = big * big;
+
+ std::clog << "\nresult = big * ulittle\n";
+ result = big * ulittle;
+
+ std::clog << "\nbig *= ulittle\n";
+ big *= ulittle;
+
+ std::clog << "\nresult = ulittle * big\n";
+ result = ulittle * big;
+
+ std::clog << "\nresult = big * 5\n";
+ result = big * 5;
+
+ std::clog << "\nbig *= 5\n";
+ big *= 5;
+
+ std::clog << "\nresult = 5 * big\n";
+ result = 5 * big;
+
+ std::clog << "\nresult = ulittle * 5\n";
+ result = ulittle * 5;
+
+ std::clog << "\nresult = 5 * ulittle\n";
+ result = 5 * ulittle;
+
+ std::clog << "\nresult = 5 * 10\n";
+ result = 5 * 10;
+ std::clog << "\n";
+
+ bi::endian_log = false;
+
+ // perform the indicated test on ~60*60 operand types
 
   op_test<default_construct>();
- op_test<construct>();
+ op_test<construct>(); // includes copy construction
+ op_test<initialize>();
   op_test<assign>();
- op_test<pass>();
- op_test<compare>();
+ op_test<relational>();
+ op_test<op_plus>();
+ op_test<op_star>();
+
   return 0;
 }

Modified: sandbox/endian/libs/integer/test/endian_test.cpp
==============================================================================
--- sandbox/endian/libs/integer/test/endian_test.cpp (original)
+++ sandbox/endian/libs/integer/test/endian_test.cpp 2008-08-06 14:34:15 EDT (Wed, 06 Aug 2008)
@@ -1,6 +1,6 @@
 // endian_test.cpp ---------------------------------------------------------//
 
-// Copyright Beman Dawes, 1999-2006
+// Copyright Beman Dawes, 1999-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)
@@ -9,6 +9,13 @@
 
 //----------------------------------------------------------------------------//
 
+// This test probes for correct endianess, size, and value.
+
+// See endian_operations_test for tests of operator correctness and interaction
+// between operand types.
+
+//----------------------------------------------------------------------------//
+
 #include <boost/integer/endian.hpp>
 #include <boost/cstdint.hpp>
 #include <boost/progress.hpp>
@@ -19,9 +26,10 @@
 #include <cstdlib> // for atoi(), exit()
 #include <cstring> // for memcmp()
 
-using namespace std; // not the best programming practice, but I
+using namespace std; // Not the best programming practice, but I
 using namespace boost; // want to verify this combination of using
-using namespace boost::integer; // namespaces works.
+using namespace boost::integer; // namespaces works. See endian_operations_test
+// // for tests that don't do "using namespace".
 
 #define VERIFY(predicate) verify( predicate, __LINE__ )
 #define VERIFY_SIZE(actual, expected) verify_size( actual, expected, __LINE__ )
@@ -72,8 +80,8 @@
   void verify_representation( bool is_big, int line )
   {
     int silence = 0;
- Endian x = static_cast<typename Endian::value_type>
- (0x123456789abcdef0LL + silence); // will truncate
+ Endian x ( static_cast<typename Endian::value_type>
+ (0x123456789abcdef0LL + silence) ); // will truncate
 
     if ( is_big )
       verify( memcmp( &x,
@@ -93,8 +101,6 @@
 # endif
   }
 
-
-
   // detect_endianness -----------------------------------------------------//
 
   void detect_endianness()


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