mirror of
https://github.com/boostorg/endian.git
synced 2025-08-02 05:54:31 +02:00
Add light test of modify-in-place interface
This commit is contained in:
@@ -100,11 +100,10 @@ namespace endian
|
|||||||
|
|
||||||
// reverse unless native endianness is big
|
// reverse unless native endianness is big
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void big_endianx(T& x) BOOST_NOEXCEPT;
|
inline void big_endian(T& x) BOOST_NOEXCEPT;
|
||||||
// Effects: none if native endian order is big, otherwise reverse(x)
|
// Effects: none if native endian order is big, otherwise reverse(x)
|
||||||
|
|
||||||
// reverse unless native endianness is little
|
// reverse unless native endianness is little
|
||||||
// possible names: reverse_unless_native_little, reverse_bytes_unless_little, reverse_unless_little
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void little_endian(T& x) BOOST_NOEXCEPT;
|
inline void little_endian(T& x) BOOST_NOEXCEPT;
|
||||||
// Effects: none if native endian order is little, otherwise reverse(x);
|
// Effects: none if native endian order is little, otherwise reverse(x);
|
||||||
@@ -383,7 +382,7 @@ namespace endian
|
|||||||
|
|
||||||
// reverse unless native endianness is big
|
// reverse unless native endianness is big
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void big_endianx(T& x) BOOST_NOEXCEPT
|
inline void big_endian(T& x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifndef BOOST_BIG_ENDIAN
|
# ifndef BOOST_BIG_ENDIAN
|
||||||
reverse(x);
|
reverse(x);
|
||||||
|
@@ -170,6 +170,31 @@ namespace
|
|||||||
BOOST_TEST_EQ((be::convert_value(little, be::order::little, be::order::native)), native);
|
BOOST_TEST_EQ((be::convert_value(little, be::order::little, be::order::native)), native);
|
||||||
BOOST_TEST_EQ((be::convert_value(native, be::order::native, be::order::big)), big);
|
BOOST_TEST_EQ((be::convert_value(native, be::order::native, be::order::big)), big);
|
||||||
BOOST_TEST_EQ((be::convert_value(native, be::order::native, be::order::little)), native);
|
BOOST_TEST_EQ((be::convert_value(native, be::order::native, be::order::little)), native);
|
||||||
|
|
||||||
|
// light test of modify-in-place functions
|
||||||
|
|
||||||
|
T x;
|
||||||
|
|
||||||
|
x = big; be::reverse(x); BOOST_TEST_EQ(x, little);
|
||||||
|
x = big; be::convert<be::order::big, be::order::little>(x); BOOST_TEST_EQ(x, little);
|
||||||
|
x = big; be::convert(x, be::order::big, be::order::little); BOOST_TEST_EQ(x, little);
|
||||||
|
|
||||||
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
|
x = native; be::big_endian(x); BOOST_TEST_EQ(x, big);
|
||||||
|
x = big; be::big_endian(x); BOOST_TEST_EQ(x, big);
|
||||||
|
x = little; be::big_endian(x); BOOST_TEST_EQ(x, little);
|
||||||
|
x = native; be::little_endian(x); BOOST_TEST_EQ(x, little);
|
||||||
|
x = big; be::little_endian(x); BOOST_TEST_EQ(x, little);
|
||||||
|
x = little; be::little_endian(x); BOOST_TEST_EQ(x, big);
|
||||||
|
# else
|
||||||
|
x = native; be::big_endian(x); BOOST_TEST_EQ(x, big);
|
||||||
|
x = big; be::big_endian(x); BOOST_TEST_EQ(x, little);
|
||||||
|
x = little; be::big_endian(x); BOOST_TEST_EQ(x, big);
|
||||||
|
x = native; be::little_endian(x); BOOST_TEST_EQ(x, little);
|
||||||
|
x = big; be::little_endian(x); BOOST_TEST_EQ(x, big);
|
||||||
|
x = little; be::little_endian(x); BOOST_TEST_EQ(x, little);
|
||||||
|
# endif
|
||||||
|
|
||||||
}
|
}
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user