Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51866 - in sandbox/endian: boost boost/integer libs/integer/test
From: bdawes_at_[hidden]
Date: 2009-03-20 09:40:25


Author: bemandawes
Date: 2009-03-20 09:40:24 EDT (Fri, 20 Mar 2009)
New Revision: 51866
URL: http://svn.boost.org/trac/boost/changeset/51866

Log:
Endian: get tests working on more compilers, eliminate compiler warnings
Text files modified:
   sandbox/endian/boost/binary_stream.hpp | 10 ++
   sandbox/endian/boost/integer/cover_operators.hpp | 10 +-
   sandbox/endian/boost/integer/endian.hpp | 12 +++
   sandbox/endian/libs/integer/test/Jamfile.v2 | 3
   sandbox/endian/libs/integer/test/endian_operations_test.cpp | 20 +++++
   sandbox/endian/libs/integer/test/endian_test.cpp | 140 ++++++++++++++++++++--------------------
   6 files changed, 116 insertions(+), 79 deletions(-)

Modified: sandbox/endian/boost/binary_stream.hpp
==============================================================================
--- sandbox/endian/boost/binary_stream.hpp (original)
+++ sandbox/endian/boost/binary_stream.hpp 2009-03-20 09:40:24 EDT (Fri, 20 Mar 2009)
@@ -10,11 +10,15 @@
 #ifndef BOOST_BINARY_STREAM_HPP
 #define BOOST_BINARY_STREAM_HPP
 
+#include <boost/config.hpp>
 #include <ostream>
 #include <istream>
 #include <string>
 #include <cstring> // for strlen
-#include <cwchar> // for wcslen
+
+#ifndef BOOST_NO_CWCHAR
+# include <cwchar> // for wcslen
+#endif
 
 // unformatted binary (as opposed to formatted character-set) input and output
 
@@ -127,8 +131,10 @@
   inline std::ostream& operator<=(std::ostream& os, const unsigned char* p)
     { return os.write( reinterpret_cast<const char*>(p), std::strlen(reinterpret_cast<const char*>(p))+1 ); }
 
+#ifndef BOOST_NO_CWCHAR
   inline std::ostream& operator<=(std::ostream& os, const wchar_t* p)
     { return os.write( reinterpret_cast<const char*>(p), (std::wcslen(p)+1)*sizeof(wchar_t) ); }
+#endif
 
   // Caution: note the asymmetry between output and input; a string with embedded
   // nulls will be output with the embedded nulls, but input will stop at the first null.
@@ -138,9 +144,11 @@
   inline std::istream& operator>=(std::istream& is, std::string& s)
     { return getline(is, s, '\0'); }
 
+#ifndef BOOST_NO_STD_WSTRING
   inline std::ostream& operator<=(std::ostream& os, const std::wstring& s)
     { return os.write( reinterpret_cast<const char*>(s.c_str()), (s.size()+1)*sizeof(wchar_t) ); }
   // TODO: provide input function
+#endif
 
 } // namespace boost
 

Modified: sandbox/endian/boost/integer/cover_operators.hpp
==============================================================================
--- sandbox/endian/boost/integer/cover_operators.hpp (original)
+++ sandbox/endian/boost/integer/cover_operators.hpp 2009-03-20 09:40:24 EDT (Fri, 20 Mar 2009)
@@ -65,16 +65,16 @@
       friend T& operator<<=(T& x, IntegerType y) { return x = +x << y; }
       friend T& operator>>=(T& x, IntegerType y) { return x = +x >> y; }
       
+ // A few binary arithmetic operations not covered by operators base class.
+ friend IntegerType operator<<(const T& x, IntegerType y) { return +x << y; }
+ friend IntegerType operator>>(const T& x, IntegerType y) { return +x >> y; }
+
       // Auto-increment and auto-decrement can be defined in terms of the
       // arithmetic operations.
       friend T& operator++(T& x) { return x += 1; }
       friend T& operator--(T& x) { return x -= 1; }
 
-# ifndef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
- // A few binary arithmetic operations not covered by operators base class.
- friend IntegerType operator<<(const T& x, IntegerType y) { return +x << y; }
- friend IntegerType operator>>(const T& x, IntegerType y) { return +x >> y; }
-
+# ifdef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
       friend T operator++(T& x, int)
       {
         T tmp(x);

Modified: sandbox/endian/boost/integer/endian.hpp
==============================================================================
--- sandbox/endian/boost/integer/endian.hpp (original)
+++ sandbox/endian/boost/integer/endian.hpp 2009-03-20 09:40:24 EDT (Fri, 20 Mar 2009)
@@ -21,6 +21,14 @@
 #ifndef BOOST_ENDIAN_HPP
 #define BOOST_ENDIAN_HPP
 
+#ifdef BOOST_ENDIAN_LOG
+# include <iostream>
+#endif
+
+#if defined(__BORLANDC__) || defined( __CODEGEARC__)
+# pragma pack(push, 1)
+#endif
+
 #include <boost/config.hpp>
 #include <boost/detail/endian.hpp>
 #define BOOST_MINIMAL_INTEGER_COVER_OPERATORS
@@ -411,4 +419,8 @@
   } // namespace integer
 } // namespace boost
 
+#if defined(__BORLANDC__) || defined( __CODEGEARC__)
+# pragma pack(pop)
+#endif
+
 #endif // BOOST_ENDIAN_HPP

Modified: sandbox/endian/libs/integer/test/Jamfile.v2
==============================================================================
--- sandbox/endian/libs/integer/test/Jamfile.v2 (original)
+++ sandbox/endian/libs/integer/test/Jamfile.v2 2009-03-20 09:40:24 EDT (Fri, 20 Mar 2009)
@@ -14,7 +14,8 @@
          [ run binary_stream_test.cpp ]
          [ run endian_binary_stream_test.cpp ]
          [ run endian_test.cpp ]
- [ run endian_operations_test.cpp ]
+ [ run endian_operations_test.cpp
+ : : : <toolset>gcc:<cxxflags>-Wno-sign-compare ]
          [ run endian_in_union_test.cpp ]
          [ run scoped_enum_emulation_test.cpp ]
       ;

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 2009-03-20 09:40:24 EDT (Fri, 20 Mar 2009)
@@ -46,6 +46,7 @@
   {
     T2 o2(1);
     T1 o1(o2);
+ ++o1; // quiet gcc unused variable warning
   }
 };
 
@@ -56,6 +57,7 @@
   {
     T1 o2(2);
     T1 o1 = o2;
+ ++o1; // quiet gcc unused variable warning
   }
 };
 
@@ -122,6 +124,12 @@
 template <template<class, class> class Test, class T1>
 void op_test_aux()
 {
+#ifdef BOOST_SHORT_ENDIAN_TEST
+ Test<T1, int>::test();
+ Test<T1, unsigned int>::test();
+ Test<T1, bi::big16_t>::test();
+ Test<T1, bi::ubig64_t>::test();
+#else
   Test<T1, char>::test();
   Test<T1, unsigned char>::test();
   Test<T1, signed char>::test();
@@ -181,12 +189,19 @@
   Test<T1, bi::unative48_t>::test();
   Test<T1, bi::unative56_t>::test();
   Test<T1, bi::unative64_t>::test();
-
+#endif
 }
 
 template <template<class, class> class Test>
 void op_test()
 {
+#ifdef BOOST_SHORT_ENDIAN_TEST
+ op_test_aux<Test, unsigned short>();
+ op_test_aux<Test, int>();
+ op_test_aux<Test, bi::big32_t>();
+ op_test_aux<Test, bi::ubig32_t>();
+ op_test_aux<Test, bi::little48_t>();
+#else
   op_test_aux<Test, char>();
   op_test_aux<Test, unsigned char>();
   op_test_aux<Test, signed char>();
@@ -246,6 +261,7 @@
   op_test_aux<Test, bi::unative48_t>();
   op_test_aux<Test, bi::unative56_t>();
   op_test_aux<Test, bi::unative64_t>();
+#endif
 }
 
 int main()
@@ -280,7 +296,7 @@
   ++big;
 
   std::clog << "\nresult = big++\n";
- big++;
+ result = big++;
 
   std::clog << "\n--big\n";
   --big;

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 2009-03-20 09:40:24 EDT (Fri, 20 Mar 2009)
@@ -53,7 +53,7 @@
   {
     if ( actual == expected ) return;
     ++err_count;
- cout << "Error: verify failed on line " << line << endl;
+ cout << "Error: verify size failed on line " << line << endl;
     cout << " A structure with an expected sizeof() " << expected
          << " had an actual sizeof() " << actual
          << "\n This will cause common uses of <boost/endian.hpp> to fail\n";
@@ -149,75 +149,75 @@
     VERIFY( numeric_limits<signed char>::digits == 7 );
     VERIFY( numeric_limits<unsigned char>::digits == 8 );
 
- VERIFY( sizeof( big8_t ) == 1 );
- VERIFY( sizeof( big16_t ) == 2 );
- VERIFY( sizeof( big24_t ) == 3 );
- VERIFY( sizeof( big32_t ) == 4 );
- VERIFY( sizeof( big40_t ) == 5 );
- VERIFY( sizeof( big48_t ) == 6 );
- VERIFY( sizeof( big56_t ) == 7 );
- VERIFY( sizeof( big64_t ) == 8 );
-
- VERIFY( sizeof( ubig8_t ) == 1 );
- VERIFY( sizeof( ubig16_t ) == 2 );
- VERIFY( sizeof( ubig24_t ) == 3 );
- VERIFY( sizeof( ubig32_t ) == 4 );
- VERIFY( sizeof( ubig40_t ) == 5 );
- VERIFY( sizeof( ubig48_t ) == 6 );
- VERIFY( sizeof( ubig56_t ) == 7 );
- VERIFY( sizeof( ubig64_t ) == 8 );
-
- VERIFY( sizeof( little8_t ) == 1 );
- VERIFY( sizeof( little16_t ) == 2 );
- VERIFY( sizeof( little24_t ) == 3 );
- VERIFY( sizeof( little32_t ) == 4 );
- VERIFY( sizeof( little40_t ) == 5 );
- VERIFY( sizeof( little48_t ) == 6 );
- VERIFY( sizeof( little56_t ) == 7 );
- VERIFY( sizeof( little64_t ) == 8 );
-
- VERIFY( sizeof( ulittle8_t ) == 1 );
- VERIFY( sizeof( ulittle16_t ) == 2 );
- VERIFY( sizeof( ulittle24_t ) == 3 );
- VERIFY( sizeof( ulittle32_t ) == 4 );
- VERIFY( sizeof( ulittle40_t ) == 5 );
- VERIFY( sizeof( ulittle48_t ) == 6 );
- VERIFY( sizeof( ulittle56_t ) == 7 );
- VERIFY( sizeof( ulittle64_t ) == 8 );
-
- VERIFY( sizeof( native8_t ) == 1 );
- VERIFY( sizeof( native16_t ) == 2 );
- VERIFY( sizeof( native24_t ) == 3 );
- VERIFY( sizeof( native32_t ) == 4 );
- VERIFY( sizeof( native40_t ) == 5 );
- VERIFY( sizeof( native48_t ) == 6 );
- VERIFY( sizeof( native56_t ) == 7 );
- VERIFY( sizeof( native64_t ) == 8 );
-
- VERIFY( sizeof( unative8_t ) == 1 );
- VERIFY( sizeof( unative16_t ) == 2 );
- VERIFY( sizeof( unative24_t ) == 3 );
- VERIFY( sizeof( unative32_t ) == 4 );
- VERIFY( sizeof( unative40_t ) == 5 );
- VERIFY( sizeof( unative48_t ) == 6 );
- VERIFY( sizeof( unative56_t ) == 7 );
- VERIFY( sizeof( unative64_t ) == 8 );
-
- VERIFY( sizeof( aligned_big16_t ) == 2 );
- VERIFY( sizeof( aligned_big32_t ) == 4 );
- VERIFY( sizeof( aligned_big64_t ) == 8 );
-
- VERIFY( sizeof( aligned_ubig16_t ) == 2 );
- VERIFY( sizeof( aligned_ubig32_t ) == 4 );
- VERIFY( sizeof( aligned_ubig64_t ) == 8 );
-
- VERIFY( sizeof( aligned_little16_t ) == 2 );
- VERIFY( sizeof( aligned_little32_t ) == 4 );
- VERIFY( sizeof( aligned_little64_t ) == 8 );
-
- VERIFY( sizeof( aligned_ulittle16_t ) == 2 );
- VERIFY( sizeof( aligned_ulittle32_t ) == 4 );
- VERIFY( sizeof( aligned_ulittle64_t ) == 8 );
+ VERIFY_SIZE( sizeof( big8_t ), 1 );
+ VERIFY_SIZE( sizeof( big16_t ), 2 );
+ VERIFY_SIZE( sizeof( big24_t ), 3 );
+ VERIFY_SIZE( sizeof( big32_t ), 4 );
+ VERIFY_SIZE( sizeof( big40_t ), 5 );
+ VERIFY_SIZE( sizeof( big48_t ), 6 );
+ VERIFY_SIZE( sizeof( big56_t ), 7 );
+ VERIFY_SIZE( sizeof( big64_t ), 8 );
+
+ VERIFY_SIZE( sizeof( ubig8_t ), 1 );
+ VERIFY_SIZE( sizeof( ubig16_t ), 2 );
+ VERIFY_SIZE( sizeof( ubig24_t ), 3 );
+ VERIFY_SIZE( sizeof( ubig32_t ), 4 );
+ VERIFY_SIZE( sizeof( ubig40_t ), 5 );
+ VERIFY_SIZE( sizeof( ubig48_t ), 6 );
+ VERIFY_SIZE( sizeof( ubig56_t ), 7 );
+ VERIFY_SIZE( sizeof( ubig64_t ), 8 );
+
+ VERIFY_SIZE( sizeof( little8_t ), 1 );
+ VERIFY_SIZE( sizeof( little16_t ), 2 );
+ VERIFY_SIZE( sizeof( little24_t ), 3 );
+ VERIFY_SIZE( sizeof( little32_t ), 4 );
+ VERIFY_SIZE( sizeof( little40_t ), 5 );
+ VERIFY_SIZE( sizeof( little48_t ), 6 );
+ VERIFY_SIZE( sizeof( little56_t ), 7 );
+ VERIFY_SIZE( sizeof( little64_t ), 8 );
+
+ VERIFY_SIZE( sizeof( ulittle8_t ), 1 );
+ VERIFY_SIZE( sizeof( ulittle16_t ), 2 );
+ VERIFY_SIZE( sizeof( ulittle24_t ), 3 );
+ VERIFY_SIZE( sizeof( ulittle32_t ), 4 );
+ VERIFY_SIZE( sizeof( ulittle40_t ), 5 );
+ VERIFY_SIZE( sizeof( ulittle48_t ), 6 );
+ VERIFY_SIZE( sizeof( ulittle56_t ), 7 );
+ VERIFY_SIZE( sizeof( ulittle64_t ), 8 );
+
+ VERIFY_SIZE( sizeof( native8_t ), 1 );
+ VERIFY_SIZE( sizeof( native16_t ), 2 );
+ VERIFY_SIZE( sizeof( native24_t ), 3 );
+ VERIFY_SIZE( sizeof( native32_t ), 4 );
+ VERIFY_SIZE( sizeof( native40_t ), 5 );
+ VERIFY_SIZE( sizeof( native48_t ), 6 );
+ VERIFY_SIZE( sizeof( native56_t ), 7 );
+ VERIFY_SIZE( sizeof( native64_t ), 8 );
+
+ VERIFY_SIZE( sizeof( unative8_t ), 1 );
+ VERIFY_SIZE( sizeof( unative16_t ), 2 );
+ VERIFY_SIZE( sizeof( unative24_t ), 3 );
+ VERIFY_SIZE( sizeof( unative32_t ), 4 );
+ VERIFY_SIZE( sizeof( unative40_t ), 5 );
+ VERIFY_SIZE( sizeof( unative48_t ), 6 );
+ VERIFY_SIZE( sizeof( unative56_t ), 7 );
+ VERIFY_SIZE( sizeof( unative64_t ), 8 );
+
+ VERIFY_SIZE( sizeof( aligned_big16_t ), 2 );
+ VERIFY_SIZE( sizeof( aligned_big32_t ), 4 );
+ VERIFY_SIZE( sizeof( aligned_big64_t ), 8 );
+
+ VERIFY_SIZE( sizeof( aligned_ubig16_t ), 2 );
+ VERIFY_SIZE( sizeof( aligned_ubig32_t ), 4 );
+ VERIFY_SIZE( sizeof( aligned_ubig64_t ), 8 );
+
+ VERIFY_SIZE( sizeof( aligned_little16_t ), 2 );
+ VERIFY_SIZE( sizeof( aligned_little32_t ), 4 );
+ VERIFY_SIZE( sizeof( aligned_little64_t ), 8 );
+
+ VERIFY_SIZE( sizeof( aligned_ulittle16_t ), 2 );
+ VERIFY_SIZE( sizeof( aligned_ulittle32_t ), 4 );
+ VERIFY_SIZE( sizeof( aligned_ulittle64_t ), 8 );
   } // check_size
 
   // check_alignment -------------------------------------------------------//


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