|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72128 - sandbox/endian/libs/endian/test
From: bdawes_at_[hidden]
Date: 2011-05-24 06:45:47
Author: bemandawes
Date: 2011-05-24 06:45:46 EDT (Tue, 24 May 2011)
New Revision: 72128
URL: http://svn.boost.org/trac/boost/changeset/72128
Log:
Add test_copying_conditional_flip()
Text files modified:
sandbox/endian/libs/endian/test/conversion_test.cpp | 156 +++++++++++++++++++++++++++++----------
1 files changed, 114 insertions(+), 42 deletions(-)
Modified: sandbox/endian/libs/endian/test/conversion_test.cpp
==============================================================================
--- sandbox/endian/libs/endian/test/conversion_test.cpp (original)
+++ sandbox/endian/libs/endian/test/conversion_test.cpp 2011-05-24 06:45:46 EDT (Tue, 24 May 2011)
@@ -307,52 +307,123 @@
ui16 = lui16;
be::from_little(ui16);
BOOST_TEST_EQ(ui16, nui16);
+
+ std::cout << " test_in_place_conditional_flip complete\n";
+ }
+
+ void test_copying_conditional_flip()
+ {
+ std::cout << "test_copying_conditional_flip...\n";
+
+ boost::int64_t i64, ti64;
+
+ i64 = ni64;
+ be::to_big(i64, ti64);
+ BOOST_TEST_EQ(ti64, bi64);
+
+ i64 = ni64;
+ be::to_little(i64, ti64);
+ BOOST_TEST_EQ(ti64, li64);
+
+ i64 = bi64;
+ be::from_big(i64, ti64);
+ BOOST_TEST_EQ(ti64, ni64);
+
+ i64 = li64;
+ be::from_little(i64, ti64);
+ BOOST_TEST_EQ(ti64, ni64);
+
+ boost::uint64_t ui64, tui64;
+
+ ui64 = nui64;
+ be::to_big(ui64, tui64);
+ BOOST_TEST_EQ(tui64, bui64);
+
+ ui64 = nui64;
+ be::to_little(ui64, tui64);
+ BOOST_TEST_EQ(tui64, lui64);
+
+ ui64 = bui64;
+ be::from_big(ui64, tui64);
+ BOOST_TEST_EQ(tui64, nui64);
+
+ ui64 = lui64;
+ be::from_little(ui64, tui64);
+ BOOST_TEST_EQ(tui64, nui64);
+
+ boost::int32_t i32, ti32;
+
+ i32 = ni32;
+ be::to_big(i32, ti32);
+ BOOST_TEST_EQ(ti32, bi32);
+
+ i32 = ni32;
+ be::to_little(i32, ti32);
+ BOOST_TEST_EQ(ti32, li32);
+ i32 = bi32;
+ be::from_big(i32, ti32);
+ BOOST_TEST_EQ(ti32, ni32);
+ i32 = li32;
+ be::from_little(i32, ti32);
+ BOOST_TEST_EQ(ti32, ni32);
- i32 = 0x01020304;
- be::flip(i32);
- BOOST_TEST_EQ(i32, 0x04030201);
- be::flip(i32);
- BOOST_TEST_EQ(i32, 0x01020304);
-
- i32 = 0xfefdfcfb;
- be::flip(i32);
- BOOST_TEST_EQ(i32, static_cast<boost::int32_t>(0xfbfcfdfe));
- be::flip(i32);
- BOOST_TEST_EQ(i32, static_cast<boost::int32_t>(0xfefdfcfb));
-
- i16 = 0x0102;
- be::flip(i16);
- BOOST_TEST_EQ(i16, 0x0201);
- be::flip(i16);
- BOOST_TEST_EQ(i16, 0x0102);
-
- i16 = static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd));
- be::flip(i16);
- BOOST_TEST_EQ(i16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfdfe)));
- be::flip(i16);
- BOOST_TEST_EQ(i16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd)));
-
- ui64 = 0x0102030405060708ULL;
- be::flip(ui64);
- BOOST_TEST_EQ(ui64, static_cast<boost::uint64_t>(0x0807060504030201ULL));
- be::flip(ui64);
- BOOST_TEST_EQ(ui64, static_cast<boost::uint64_t>(0x0102030405060708ULL));
-
- ui32 = 0x01020304;
- be::flip(ui32);
- BOOST_TEST_EQ(ui32, static_cast<boost::uint32_t>(0x04030201));
- be::flip(ui32);
- BOOST_TEST_EQ(ui32, static_cast<boost::uint32_t>(0x01020304));
-
- ui16 = 0x0102;
- be::flip(ui16);
- BOOST_TEST_EQ(ui16, 0x0201);
- be::flip(ui16);
- BOOST_TEST_EQ(ui16, 0x0102);
+ boost::uint32_t ui32, tui32;
+
+ ui32 = nui32;
+ be::to_big(ui32, tui32);
+ BOOST_TEST_EQ(tui32, bui32);
+
+ ui32 = nui32;
+ be::to_little(ui32, tui32);
+ BOOST_TEST_EQ(tui32, lui32);
+
+ ui32 = bui32;
+ be::from_big(ui32, tui32);
+ BOOST_TEST_EQ(tui32, nui32);
+
+ ui32 = lui32;
+ be::from_little(ui32, tui32);
+ BOOST_TEST_EQ(tui32, nui32);
+
+ boost::int16_t i16, ti16;
+
+ i16 = ni16;
+ be::to_big(i16, ti16);
+ BOOST_TEST_EQ(ti16, bi16);
+
+ i16 = ni16;
+ be::to_little(i16, ti16);
+ BOOST_TEST_EQ(ti16, li16);
+
+ i16 = bi16;
+ be::from_big(i16, ti16);
+ BOOST_TEST_EQ(ti16, ni16);
+
+ i16 = li16;
+ be::from_little(i16, ti16);
+ BOOST_TEST_EQ(ti16, ni16);
+
+ boost::uint16_t ui16, tui16;
+
+ ui16 = nui16;
+ be::to_big(ui16, tui16);
+ BOOST_TEST_EQ(tui16, bui16);
+
+ ui16 = nui16;
+ be::to_little(ui16, tui16);
+ BOOST_TEST_EQ(tui16, lui16);
+
+ ui16 = bui16;
+ be::from_big(ui16, tui16);
+ BOOST_TEST_EQ(tui16, nui16);
+
+ ui16 = lui16;
+ be::from_little(ui16, tui16);
+ BOOST_TEST_EQ(tui16, nui16);
- std::cout << " test_in_place_conditional_flip complete\n";
+ std::cout << " test_copying_conditional_flip complete\n";
}
} // unnamed namespace
@@ -363,6 +434,7 @@
test_in_place_flip();
test_copying_flip();
test_in_place_conditional_flip();
+ test_copying_conditional_flip();
return ::boost::report_errors();
}
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