|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63134 - sandbox/endian_ext/libs/integer/test
From: vicente.botet_at_[hidden]
Date: 2010-06-20 08:36:57
Author: viboes
Date: 2010-06-20 08:36:56 EDT (Sun, 20 Jun 2010)
New Revision: 63134
URL: http://svn.boost.org/trac/boost/changeset/63134
Log:
* test UDT for endian_pack + check data
Text files modified:
sandbox/endian_ext/libs/integer/test/Jamfile.v2 | 3
sandbox/endian_ext/libs/integer/test/endian_operations_test.cpp | 18 ++++
sandbox/endian_ext/libs/integer/test/endian_test.cpp | 151 +++++++++++++++++++++++++++++++++++++++
3 files changed, 170 insertions(+), 2 deletions(-)
Modified: sandbox/endian_ext/libs/integer/test/Jamfile.v2
==============================================================================
--- sandbox/endian_ext/libs/integer/test/Jamfile.v2 (original)
+++ sandbox/endian_ext/libs/integer/test/Jamfile.v2 2010-06-20 08:36:56 EDT (Sun, 20 Jun 2010)
@@ -35,5 +35,8 @@
:
[ run ../example/endian_example.cpp ]
[ run ../example/endian_hello_world.cpp ]
+ [ run ../example/endian_hello_world_1.cpp ]
+ [ run ../example/endian_hello_world_2.cpp ]
+ [ run ../example/endian_quantity.cpp ]
[ run ../example/packet_example.cpp ]
;
Modified: sandbox/endian_ext/libs/integer/test/endian_operations_test.cpp
==============================================================================
--- sandbox/endian_ext/libs/integer/test/endian_operations_test.cpp (original)
+++ sandbox/endian_ext/libs/integer/test/endian_operations_test.cpp 2010-06-20 08:36:56 EDT (Sun, 20 Jun 2010)
@@ -264,6 +264,8 @@
#endif
}
+// main ------------------------------------------------------------------------------//
+
int main()
{
bi::endian_log = false;
@@ -339,7 +341,21 @@
std::clog << "\n";
bi::endian_log = false;
-
+
+ // test from Roland Schwarz that detected ambiguities
+ unsigned u;
+ bi::ulittle32_t u1;
+ bi::ulittle32_t u2;
+
+ u = 1;
+ u1 = 1;
+ u2 = u1 + u;
+
+ // one more wrinkle
+ bi::ulittle16_t u3(3);
+ u3 = 3;
+ u2 = u1 + u3;
+
// perform the indicated test on ~60*60 operand types
op_test<default_construct>();
Modified: sandbox/endian_ext/libs/integer/test/endian_test.cpp
==============================================================================
--- sandbox/endian_ext/libs/integer/test/endian_test.cpp (original)
+++ sandbox/endian_ext/libs/integer/test/endian_test.cpp 2010-06-20 08:36:56 EDT (Sun, 20 Jun 2010)
@@ -142,6 +142,152 @@
cout << "That should not matter and is presented for your information only.\n";
} // detect_endianness
+ // check_data ------------------------------------------------------------//
+
+ void check_data()
+ {
+ big8_t big8;
+ big16_t big16;
+ big24_t big24;
+ big32_t big32;
+ big40_t big40;
+ big48_t big48;
+ big56_t big56;
+ big64_t big64;
+
+ ubig8_t ubig8;
+ ubig16_t ubig16;
+ ubig24_t ubig24;
+ ubig32_t ubig32;
+ ubig40_t ubig40;
+ ubig48_t ubig48;
+ ubig56_t ubig56;
+ ubig64_t ubig64;
+
+ little8_t little8;
+ little16_t little16;
+ little24_t little24;
+ little32_t little32;
+ little40_t little40;
+ little48_t little48;
+ little56_t little56;
+ little64_t little64;
+
+ ulittle8_t ulittle8;
+ ulittle16_t ulittle16;
+ ulittle24_t ulittle24;
+ ulittle32_t ulittle32;
+ ulittle40_t ulittle40;
+ ulittle48_t ulittle48;
+ ulittle56_t ulittle56;
+ ulittle64_t ulittle64;
+
+ native8_t native8;
+ native16_t native16;
+ native24_t native24;
+ native32_t native32;
+ native40_t native40;
+ native48_t native48;
+ native56_t native56;
+ native64_t native64;
+
+ unative8_t unative8;
+ unative16_t unative16;
+ unative24_t unative24;
+ unative32_t unative32;
+ unative40_t unative40;
+ unative48_t unative48;
+ unative56_t unative56;
+ unative64_t unative64;
+
+ aligned_big16_t aligned_big16;
+ aligned_big32_t aligned_big32;
+ aligned_big64_t aligned_big64;
+
+ aligned_ubig16_t aligned_ubig16;
+ aligned_ubig32_t aligned_ubig32;
+ aligned_ubig64_t aligned_ubig64;
+
+ aligned_little16_t aligned_little16;
+ aligned_little32_t aligned_little32;
+ aligned_little64_t aligned_little64;
+
+ aligned_ulittle16_t aligned_ulittle16 ;
+ aligned_ulittle32_t aligned_ulittle32 ;
+ aligned_ulittle64_t aligned_ulittle64 ;
+
+ VERIFY(big8.data() == reinterpret_cast<const char *>(&big8));
+ VERIFY(big16.data() == reinterpret_cast<const char *>(&big16));
+ VERIFY(big24.data() == reinterpret_cast<const char *>(&big24));
+ VERIFY(big32.data() == reinterpret_cast<const char *>(&big32));
+ VERIFY(big40.data() == reinterpret_cast<const char *>(&big40));
+ VERIFY(big48.data() == reinterpret_cast<const char *>(&big48));
+ VERIFY(big56.data() == reinterpret_cast<const char *>(&big56));
+ VERIFY(big64.data() == reinterpret_cast<const char *>(&big64));
+
+ VERIFY(ubig8.data() == reinterpret_cast<const char *>(&ubig8));
+ VERIFY(ubig16.data() == reinterpret_cast<const char *>(&ubig16));
+ VERIFY(ubig24.data() == reinterpret_cast<const char *>(&ubig24));
+ VERIFY(ubig32.data() == reinterpret_cast<const char *>(&ubig32));
+ VERIFY(ubig40.data() == reinterpret_cast<const char *>(&ubig40));
+ VERIFY(ubig48.data() == reinterpret_cast<const char *>(&ubig48));
+ VERIFY(ubig56.data() == reinterpret_cast<const char *>(&ubig56));
+ VERIFY(ubig64.data() == reinterpret_cast<const char *>(&ubig64));
+
+ VERIFY(little8.data() == reinterpret_cast<const char *>(&little8));
+ VERIFY(little16.data() == reinterpret_cast<const char *>(&little16));
+ VERIFY(little24.data() == reinterpret_cast<const char *>(&little24));
+ VERIFY(little32.data() == reinterpret_cast<const char *>(&little32));
+ VERIFY(little40.data() == reinterpret_cast<const char *>(&little40));
+ VERIFY(little48.data() == reinterpret_cast<const char *>(&little48));
+ VERIFY(little56.data() == reinterpret_cast<const char *>(&little56));
+ VERIFY(little64.data() == reinterpret_cast<const char *>(&little64));
+
+ VERIFY(ulittle8.data() == reinterpret_cast<const char *>(&ulittle8));
+ VERIFY(ulittle16.data() == reinterpret_cast<const char *>(&ulittle16));
+ VERIFY(ulittle24.data() == reinterpret_cast<const char *>(&ulittle24));
+ VERIFY(ulittle32.data() == reinterpret_cast<const char *>(&ulittle32));
+ VERIFY(ulittle40.data() == reinterpret_cast<const char *>(&ulittle40));
+ VERIFY(ulittle48.data() == reinterpret_cast<const char *>(&ulittle48));
+ VERIFY(ulittle56.data() == reinterpret_cast<const char *>(&ulittle56));
+ VERIFY(ulittle64.data() == reinterpret_cast<const char *>(&ulittle64));
+
+ VERIFY(native8.data() == reinterpret_cast<const char *>(&native8));
+ VERIFY(native16.data() == reinterpret_cast<const char *>(&native16));
+ VERIFY(native24.data() == reinterpret_cast<const char *>(&native24));
+ VERIFY(native32.data() == reinterpret_cast<const char *>(&native32));
+ VERIFY(native40.data() == reinterpret_cast<const char *>(&native40));
+ VERIFY(native48.data() == reinterpret_cast<const char *>(&native48));
+ VERIFY(native56.data() == reinterpret_cast<const char *>(&native56));
+ VERIFY(native64.data() == reinterpret_cast<const char *>(&native64));
+
+ VERIFY(unative8.data() == reinterpret_cast<const char *>(&unative8));
+ VERIFY(unative16.data() == reinterpret_cast<const char *>(&unative16));
+ VERIFY(unative24.data() == reinterpret_cast<const char *>(&unative24));
+ VERIFY(unative32.data() == reinterpret_cast<const char *>(&unative32));
+ VERIFY(unative40.data() == reinterpret_cast<const char *>(&unative40));
+ VERIFY(unative48.data() == reinterpret_cast<const char *>(&unative48));
+ VERIFY(unative56.data() == reinterpret_cast<const char *>(&unative56));
+ VERIFY(unative64.data() == reinterpret_cast<const char *>(&unative64));
+
+ VERIFY(aligned_big16.data() == reinterpret_cast<const char *>(&aligned_big16));
+ VERIFY(aligned_big32.data() == reinterpret_cast<const char *>(&aligned_big32));
+ VERIFY(aligned_big64.data() == reinterpret_cast<const char *>(&aligned_big64));
+
+ VERIFY(aligned_ubig16.data() == reinterpret_cast<const char *>(&aligned_ubig16));
+ VERIFY(aligned_ubig32.data() == reinterpret_cast<const char *>(&aligned_ubig32));
+ VERIFY(aligned_ubig64.data() == reinterpret_cast<const char *>(&aligned_ubig64));
+
+ VERIFY(aligned_little16.data() == reinterpret_cast<const char *>(&aligned_little16));
+ VERIFY(aligned_little32.data() == reinterpret_cast<const char *>(&aligned_little32));
+ VERIFY(aligned_little64.data() == reinterpret_cast<const char *>(&aligned_little64));
+
+ VERIFY(aligned_ulittle16.data() == reinterpret_cast<const char *>(&aligned_ulittle16));
+ VERIFY(aligned_ulittle32.data() == reinterpret_cast<const char *>(&aligned_ulittle32));
+ VERIFY(aligned_ulittle64.data() == reinterpret_cast<const char *>(&aligned_ulittle64));
+
+ }
+
// check_size ------------------------------------------------------------//
void check_size()
@@ -572,6 +718,8 @@
} // unnamed namespace
+// main ------------------------------------------------------------------------------//
+
int main( int argc, char * argv[] )
{
cout << "Usage: "
@@ -586,7 +734,8 @@
check_size();
check_alignment();
check_representation_and_range_and_ops();
-
+ check_data();
+
//timing_test<big32_t> ( "big32_t" );
//timing_test<aligned_big32_t>( "aligned_big32_t" );
//timing_test<little32_t> ( "little32_t" );
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