From: Giacomo Travaglini Date: Wed, 20 Nov 2019 10:09:20 +0000 (+0000) Subject: base: Remove tests making use of Big/LittleEndianOrder Namespace X-Git-Tag: v19.0.0.0~281 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fb888a48f58a7b2b44fa4f63f7492e9d59eb167f;p=gem5.git base: Remove tests making use of Big/LittleEndianOrder Namespace Unit tests are currently broken. commit d40f0bc579fb8b10da7181d3a144cd3e9a0a0e59 is removing the BigEndianOrder and LittleEndianOrder namespace. Therefore we shouldn't test them and their helpers. Change-Id: I68a45f264b782334d0a0f725c2c435c27337e757 Signed-off-by: Giacomo Travaglini Reviewed-by: Nikos Nikoleris Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22943 Reviewed-by: Bobby R. Bruce Reviewed-by: Gabe Black Maintainer: Bobby R. Bruce Tested-by: kokoro --- diff --git a/src/sim/byteswap.test.cc b/src/sim/byteswap.test.cc index ef4143784..8ebc58404 100644 --- a/src/sim/byteswap.test.cc +++ b/src/sim/byteswap.test.cc @@ -337,455 +337,3 @@ TEST(ByteswapTest, letobe) EXPECT_EQ(0x5555, letobe((uint16_t)0x5555)); EXPECT_EQ(0xa0a0, letobe((uint16_t)0xa0a0)); } - -TEST(ByteswapTest, beg_gtole) -{ - EXPECT_EQ(0x0123456789abcdef, - BigEndianGuest::gtole((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0xfedcba9876543210, - BigEndianGuest::gtole((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0x0b1cb071b77141b1, - BigEndianGuest::gtole((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0x00000000ffffffff, - BigEndianGuest::gtole((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - BigEndianGuest::gtole((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - BigEndianGuest::gtole((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0x0123cdef, BigEndianGuest::gtole((uint32_t)0xefcd2301)); - EXPECT_EQ(0xfedc3210, BigEndianGuest::gtole((uint32_t)0x1032dcfe)); - EXPECT_EQ(0x0b1c41b1, BigEndianGuest::gtole((uint32_t)0xb1411c0b)); - EXPECT_EQ(0x0000ffff, BigEndianGuest::gtole((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, BigEndianGuest::gtole((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, BigEndianGuest::gtole((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0x01ef, BigEndianGuest::gtole((uint16_t)0xef01)); - EXPECT_EQ(0xfe10, BigEndianGuest::gtole((uint16_t)0x10fe)); - EXPECT_EQ(0x0bb1, BigEndianGuest::gtole((uint16_t)0xb10b)); - EXPECT_EQ(0x00ff, BigEndianGuest::gtole((uint16_t)0xff00)); - EXPECT_EQ(0x5555, BigEndianGuest::gtole((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, BigEndianGuest::gtole((uint16_t)0xa0a0)); -} - -TEST(ByteswapTest, beg_letog) -{ - EXPECT_EQ(0x0123456789abcdef, - BigEndianGuest::letog((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0xfedcba9876543210, - BigEndianGuest::letog((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0x0b1cb071b77141b1, - BigEndianGuest::letog((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0x00000000ffffffff, - BigEndianGuest::letog((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - BigEndianGuest::letog((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - BigEndianGuest::letog((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0x0123cdef, BigEndianGuest::letog((uint32_t)0xefcd2301)); - EXPECT_EQ(0xfedc3210, BigEndianGuest::letog((uint32_t)0x1032dcfe)); - EXPECT_EQ(0x0b1c41b1, BigEndianGuest::letog((uint32_t)0xb1411c0b)); - EXPECT_EQ(0x0000ffff, BigEndianGuest::letog((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, BigEndianGuest::letog((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, BigEndianGuest::letog((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0x01ef, BigEndianGuest::letog((uint16_t)0xef01)); - EXPECT_EQ(0xfe10, BigEndianGuest::letog((uint16_t)0x10fe)); - EXPECT_EQ(0x0bb1, BigEndianGuest::letog((uint16_t)0xb10b)); - EXPECT_EQ(0x00ff, BigEndianGuest::letog((uint16_t)0xff00)); - EXPECT_EQ(0x5555, BigEndianGuest::letog((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, BigEndianGuest::letog((uint16_t)0xa0a0)); -} - -TEST(ByteswapTest, beg_gtobe) -{ - EXPECT_EQ(0xefcdab8967452301, - BigEndianGuest::gtobe((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0x1032547698badcfe, - BigEndianGuest::gtobe((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0xb14171b771b01c0b, - BigEndianGuest::gtobe((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0xffffffff00000000, - BigEndianGuest::gtobe((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - BigEndianGuest::gtobe((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - BigEndianGuest::gtobe((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0xefcd2301, BigEndianGuest::gtobe((uint32_t)0xefcd2301)); - EXPECT_EQ(0x1032dcfe, BigEndianGuest::gtobe((uint32_t)0x1032dcfe)); - EXPECT_EQ(0xb1411c0b, BigEndianGuest::gtobe((uint32_t)0xb1411c0b)); - EXPECT_EQ(0xffff0000, BigEndianGuest::gtobe((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, BigEndianGuest::gtobe((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, BigEndianGuest::gtobe((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0xef01, BigEndianGuest::gtobe((uint16_t)0xef01)); - EXPECT_EQ(0x10fe, BigEndianGuest::gtobe((uint16_t)0x10fe)); - EXPECT_EQ(0xb10b, BigEndianGuest::gtobe((uint16_t)0xb10b)); - EXPECT_EQ(0xff00, BigEndianGuest::gtobe((uint16_t)0xff00)); - EXPECT_EQ(0x5555, BigEndianGuest::gtobe((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, BigEndianGuest::gtobe((uint16_t)0xa0a0)); -} - -TEST(ByteswapTest, beg_betog) -{ - EXPECT_EQ(0xefcdab8967452301, - BigEndianGuest::betog((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0x1032547698badcfe, - BigEndianGuest::betog((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0xb14171b771b01c0b, - BigEndianGuest::betog((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0xffffffff00000000, - BigEndianGuest::betog((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - BigEndianGuest::betog((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - BigEndianGuest::betog((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0xefcd2301, BigEndianGuest::betog((uint32_t)0xefcd2301)); - EXPECT_EQ(0x1032dcfe, BigEndianGuest::betog((uint32_t)0x1032dcfe)); - EXPECT_EQ(0xb1411c0b, BigEndianGuest::betog((uint32_t)0xb1411c0b)); - EXPECT_EQ(0xffff0000, BigEndianGuest::betog((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, BigEndianGuest::betog((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, BigEndianGuest::betog((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0xef01, BigEndianGuest::betog((uint16_t)0xef01)); - EXPECT_EQ(0x10fe, BigEndianGuest::betog((uint16_t)0x10fe)); - EXPECT_EQ(0xb10b, BigEndianGuest::betog((uint16_t)0xb10b)); - EXPECT_EQ(0xff00, BigEndianGuest::betog((uint16_t)0xff00)); - EXPECT_EQ(0x5555, BigEndianGuest::betog((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, BigEndianGuest::betog((uint16_t)0xa0a0)); -} - -TEST(ByteswapTest, beg_htog) -{ -#if (defined(_BIG_ENDIAN)||!defined(_LITTLE_ENDIAN)) && BYTE_ORDER==BIG_ENDIAN - EXPECT_EQ(0xefcdab8967452301, - BigEndianGuest::htog((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0x1032547698badcfe, - BigEndianGuest::htog((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0xb14171b771b01c0b, - BigEndianGuest::htog((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0xffffffff00000000, - BigEndianGuest::htog((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - BigEndianGuest::htog((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - BigEndianGuest::htog((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0xefcd2301, BigEndianGuest::htog((uint32_t)0xefcd2301)); - EXPECT_EQ(0x1032dcfe, BigEndianGuest::htog((uint32_t)0x1032dcfe)); - EXPECT_EQ(0xb1411c0b, BigEndianGuest::htog((uint32_t)0xb1411c0b)); - EXPECT_EQ(0xffff0000, BigEndianGuest::htog((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, BigEndianGuest::htog((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, BigEndianGuest::htog((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0xef01, BigEndianGuest::htog((uint16_t)0xef01)); - EXPECT_EQ(0x10fe, BigEndianGuest::htog((uint16_t)0x10fe)); - EXPECT_EQ(0xb10b, BigEndianGuest::htog((uint16_t)0xb10b)); - EXPECT_EQ(0xff00, BigEndianGuest::htog((uint16_t)0xff00)); - EXPECT_EQ(0x5555, BigEndianGuest::htog((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, BigEndianGuest::htog((uint16_t)0xa0a0)); -#elif defined(_LITTLE_ENDIAN) || BYTE_ORDER==LITTLE_ENDIAN - EXPECT_EQ(0x0123456789abcdef, - BigEndianGuest::htog((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0xfedcba9876543210, - BigEndianGuest::htog((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0x0b1cb071b77141b1, - BigEndianGuest::htog((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0x00000000ffffffff, - BigEndianGuest::htog((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - BigEndianGuest::htog((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - BigEndianGuest::htog((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0x0123cdef, BigEndianGuest::htog((uint32_t)0xefcd2301)); - EXPECT_EQ(0xfedc3210, BigEndianGuest::htog((uint32_t)0x1032dcfe)); - EXPECT_EQ(0x0b1c41b1, BigEndianGuest::htog((uint32_t)0xb1411c0b)); - EXPECT_EQ(0x0000ffff, BigEndianGuest::htog((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, BigEndianGuest::htog((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, BigEndianGuest::htog((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0x01ef, BigEndianGuest::htog((uint16_t)0xef01)); - EXPECT_EQ(0xfe10, BigEndianGuest::htog((uint16_t)0x10fe)); - EXPECT_EQ(0x0bb1, BigEndianGuest::htog((uint16_t)0xb10b)); - EXPECT_EQ(0x00ff, BigEndianGuest::htog((uint16_t)0xff00)); - EXPECT_EQ(0x5555, BigEndianGuest::htog((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, BigEndianGuest::htog((uint16_t)0xa0a0)); -#else - #error Invalid Endianess -#endif -} - -TEST(ByteswapTest, beg_gtoh) -{ -#if (defined(_BIG_ENDIAN)||!defined(_LITTLE_ENDIAN)) && BYTE_ORDER==BIG_ENDIAN - EXPECT_EQ(0xefcdab8967452301, - BigEndianGuest::gtoh((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0x1032547698badcfe, - BigEndianGuest::gtoh((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0xb14171b771b01c0b, - BigEndianGuest::gtoh((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0xffffffff00000000, - BigEndianGuest::gtoh((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - BigEndianGuest::gtoh((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - BigEndianGuest::gtoh((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0xefcd2301, BigEndianGuest::gtoh((uint32_t)0xefcd2301)); - EXPECT_EQ(0x1032dcfe, BigEndianGuest::gtoh((uint32_t)0x1032dcfe)); - EXPECT_EQ(0xb1411c0b, BigEndianGuest::gtoh((uint32_t)0xb1411c0b)); - EXPECT_EQ(0xffff0000, BigEndianGuest::gtoh((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, BigEndianGuest::gtoh((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, BigEndianGuest::gtoh((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0xef01, BigEndianGuest::gtoh((uint16_t)0xef01)); - EXPECT_EQ(0x10fe, BigEndianGuest::gtoh((uint16_t)0x10fe)); - EXPECT_EQ(0xb10b, BigEndianGuest::gtoh((uint16_t)0xb10b)); - EXPECT_EQ(0xff00, BigEndianGuest::gtoh((uint16_t)0xff00)); - EXPECT_EQ(0x5555, BigEndianGuest::gtoh((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, BigEndianGuest::gtoh((uint16_t)0xa0a0)); -#elif defined(_LITTLE_ENDIAN) || BYTE_ORDER==LITTLE_ENDIAN - EXPECT_EQ(0x0123456789abcdef, - BigEndianGuest::gtoh((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0xfedcba9876543210, - BigEndianGuest::gtoh((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0x0b1cb071b77141b1, - BigEndianGuest::gtoh((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0x00000000ffffffff, - BigEndianGuest::gtoh((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - BigEndianGuest::gtoh((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - BigEndianGuest::gtoh((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0x0123cdef, BigEndianGuest::gtoh((uint32_t)0xefcd2301)); - EXPECT_EQ(0xfedc3210, BigEndianGuest::gtoh((uint32_t)0x1032dcfe)); - EXPECT_EQ(0x0b1c41b1, BigEndianGuest::gtoh((uint32_t)0xb1411c0b)); - EXPECT_EQ(0x0000ffff, BigEndianGuest::gtoh((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, BigEndianGuest::gtoh((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, BigEndianGuest::gtoh((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0x01ef, BigEndianGuest::gtoh((uint16_t)0xef01)); - EXPECT_EQ(0xfe10, BigEndianGuest::gtoh((uint16_t)0x10fe)); - EXPECT_EQ(0x0bb1, BigEndianGuest::gtoh((uint16_t)0xb10b)); - EXPECT_EQ(0x00ff, BigEndianGuest::gtoh((uint16_t)0xff00)); - EXPECT_EQ(0x5555, BigEndianGuest::gtoh((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, BigEndianGuest::gtoh((uint16_t)0xa0a0)); -#else - #error Invalid Endianess -#endif -} - -TEST(ByteswapTest, leg_gtole) -{ - EXPECT_EQ(0xefcdab8967452301, - LittleEndianGuest::gtole((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0x1032547698badcfe, - LittleEndianGuest::gtole((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0xb14171b771b01c0b, - LittleEndianGuest::gtole((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0xffffffff00000000, - LittleEndianGuest::gtole((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - LittleEndianGuest::gtole((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - LittleEndianGuest::gtole((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0xefcd2301, LittleEndianGuest::gtole((uint32_t)0xefcd2301)); - EXPECT_EQ(0x1032dcfe, LittleEndianGuest::gtole((uint32_t)0x1032dcfe)); - EXPECT_EQ(0xb1411c0b, LittleEndianGuest::gtole((uint32_t)0xb1411c0b)); - EXPECT_EQ(0xffff0000, LittleEndianGuest::gtole((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, LittleEndianGuest::gtole((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, LittleEndianGuest::gtole((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0xef01, LittleEndianGuest::gtole((uint16_t)0xef01)); - EXPECT_EQ(0x10fe, LittleEndianGuest::gtole((uint16_t)0x10fe)); - EXPECT_EQ(0xb10b, LittleEndianGuest::gtole((uint16_t)0xb10b)); - EXPECT_EQ(0xff00, LittleEndianGuest::gtole((uint16_t)0xff00)); - EXPECT_EQ(0x5555, LittleEndianGuest::gtole((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, LittleEndianGuest::gtole((uint16_t)0xa0a0)); -} - -TEST(ByteswapTest, leg_letog) -{ - EXPECT_EQ(0xefcdab8967452301, - LittleEndianGuest::letog((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0x1032547698badcfe, - LittleEndianGuest::letog((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0xb14171b771b01c0b, - LittleEndianGuest::letog((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0xffffffff00000000, - LittleEndianGuest::letog((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - LittleEndianGuest::letog((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - LittleEndianGuest::letog((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0xefcd2301, LittleEndianGuest::letog((uint32_t)0xefcd2301)); - EXPECT_EQ(0x1032dcfe, LittleEndianGuest::letog((uint32_t)0x1032dcfe)); - EXPECT_EQ(0xb1411c0b, LittleEndianGuest::letog((uint32_t)0xb1411c0b)); - EXPECT_EQ(0xffff0000, LittleEndianGuest::letog((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, LittleEndianGuest::letog((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, LittleEndianGuest::letog((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0xef01, LittleEndianGuest::letog((uint16_t)0xef01)); - EXPECT_EQ(0x10fe, LittleEndianGuest::letog((uint16_t)0x10fe)); - EXPECT_EQ(0xb10b, LittleEndianGuest::letog((uint16_t)0xb10b)); - EXPECT_EQ(0xff00, LittleEndianGuest::letog((uint16_t)0xff00)); - EXPECT_EQ(0x5555, LittleEndianGuest::letog((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, LittleEndianGuest::letog((uint16_t)0xa0a0)); -} - -TEST(ByteswapTest, leg_gtobe) -{ - EXPECT_EQ(0x0123456789abcdef, - LittleEndianGuest::gtobe((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0xfedcba9876543210, - LittleEndianGuest::gtobe((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0x0b1cb071b77141b1, - LittleEndianGuest::gtobe((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0x00000000ffffffff, - LittleEndianGuest::gtobe((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - LittleEndianGuest::gtobe((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - LittleEndianGuest::gtobe((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0x0123cdef, LittleEndianGuest::gtobe((uint32_t)0xefcd2301)); - EXPECT_EQ(0xfedc3210, LittleEndianGuest::gtobe((uint32_t)0x1032dcfe)); - EXPECT_EQ(0x0b1c41b1, LittleEndianGuest::gtobe((uint32_t)0xb1411c0b)); - EXPECT_EQ(0x0000ffff, LittleEndianGuest::gtobe((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, LittleEndianGuest::gtobe((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, LittleEndianGuest::gtobe((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0x01ef, LittleEndianGuest::gtobe((uint16_t)0xef01)); - EXPECT_EQ(0xfe10, LittleEndianGuest::gtobe((uint16_t)0x10fe)); - EXPECT_EQ(0x0bb1, LittleEndianGuest::gtobe((uint16_t)0xb10b)); - EXPECT_EQ(0x00ff, LittleEndianGuest::gtobe((uint16_t)0xff00)); - EXPECT_EQ(0x5555, LittleEndianGuest::gtobe((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, LittleEndianGuest::gtobe((uint16_t)0xa0a0)); -} - -TEST(ByteswapTest, leg_betog) -{ - EXPECT_EQ(0x0123456789abcdef, - LittleEndianGuest::betog((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0xfedcba9876543210, - LittleEndianGuest::betog((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0x0b1cb071b77141b1, - LittleEndianGuest::betog((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0x00000000ffffffff, - LittleEndianGuest::betog((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - LittleEndianGuest::betog((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - LittleEndianGuest::betog((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0x0123cdef, LittleEndianGuest::betog((uint32_t)0xefcd2301)); - EXPECT_EQ(0xfedc3210, LittleEndianGuest::betog((uint32_t)0x1032dcfe)); - EXPECT_EQ(0x0b1c41b1, LittleEndianGuest::betog((uint32_t)0xb1411c0b)); - EXPECT_EQ(0x0000ffff, LittleEndianGuest::betog((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, LittleEndianGuest::betog((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, LittleEndianGuest::betog((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0x01ef, LittleEndianGuest::betog((uint16_t)0xef01)); - EXPECT_EQ(0xfe10, LittleEndianGuest::betog((uint16_t)0x10fe)); - EXPECT_EQ(0x0bb1, LittleEndianGuest::betog((uint16_t)0xb10b)); - EXPECT_EQ(0x00ff, LittleEndianGuest::betog((uint16_t)0xff00)); - EXPECT_EQ(0x5555, LittleEndianGuest::betog((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, LittleEndianGuest::betog((uint16_t)0xa0a0)); -} - -TEST(ByteswapTest, leg_htog) -{ -#if (defined(_BIG_ENDIAN)||!defined(_LITTLE_ENDIAN)) && BYTE_ORDER==BIG_ENDIAN - EXPECT_EQ(0x0123456789abcdef, - LittleEndianGuest::htog((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0xfedcba9876543210, - LittleEndianGuest::htog((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0x0b1cb071b77141b1, - LittleEndianGuest::htog((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0x00000000ffffffff, - LittleEndianGuest::htog((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - LittleEndianGuest::htog((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - LittleEndianGuest::htog((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0x0123cdef, LittleEndianGuest::htog((uint32_t)0xefcd2301)); - EXPECT_EQ(0xfedc3210, LittleEndianGuest::htog((uint32_t)0x1032dcfe)); - EXPECT_EQ(0x0b1c41b1, LittleEndianGuest::htog((uint32_t)0xb1411c0b)); - EXPECT_EQ(0x0000ffff, LittleEndianGuest::htog((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, LittleEndianGuest::htog((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, LittleEndianGuest::htog((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0x01ef, LittleEndianGuest::htog((uint16_t)0xef01)); - EXPECT_EQ(0xfe10, LittleEndianGuest::htog((uint16_t)0x10fe)); - EXPECT_EQ(0x0bb1, LittleEndianGuest::htog((uint16_t)0xb10b)); - EXPECT_EQ(0x00ff, LittleEndianGuest::htog((uint16_t)0xff00)); - EXPECT_EQ(0x5555, LittleEndianGuest::htog((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, LittleEndianGuest::htog((uint16_t)0xa0a0)); -#elif defined(_LITTLE_ENDIAN) || BYTE_ORDER==LITTLE_ENDIAN - EXPECT_EQ(0xefcdab8967452301, - LittleEndianGuest::htog((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0x1032547698badcfe, - LittleEndianGuest::htog((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0xb14171b771b01c0b, - LittleEndianGuest::htog((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0xffffffff00000000, - LittleEndianGuest::htog((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - LittleEndianGuest::htog((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - LittleEndianGuest::htog((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0xefcd2301, LittleEndianGuest::htog((uint32_t)0xefcd2301)); - EXPECT_EQ(0x1032dcfe, LittleEndianGuest::htog((uint32_t)0x1032dcfe)); - EXPECT_EQ(0xb1411c0b, LittleEndianGuest::htog((uint32_t)0xb1411c0b)); - EXPECT_EQ(0xffff0000, LittleEndianGuest::htog((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, LittleEndianGuest::htog((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, LittleEndianGuest::htog((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0xef01, LittleEndianGuest::htog((uint16_t)0xef01)); - EXPECT_EQ(0x10fe, LittleEndianGuest::htog((uint16_t)0x10fe)); - EXPECT_EQ(0xb10b, LittleEndianGuest::htog((uint16_t)0xb10b)); - EXPECT_EQ(0xff00, LittleEndianGuest::htog((uint16_t)0xff00)); - EXPECT_EQ(0x5555, LittleEndianGuest::htog((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, LittleEndianGuest::htog((uint16_t)0xa0a0)); -#else - #error Invalid Endianess -#endif -} - -TEST(ByteswapTest, leg_gtoh) -{ -#if (defined(_BIG_ENDIAN)||!defined(_LITTLE_ENDIAN)) && BYTE_ORDER==BIG_ENDIAN - EXPECT_EQ(0x0123456789abcdef, - LittleEndianGuest::gtoh((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0xfedcba9876543210, - LittleEndianGuest::gtoh((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0x0b1cb071b77141b1, - LittleEndianGuest::gtoh((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0x00000000ffffffff, - LittleEndianGuest::gtoh((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - LittleEndianGuest::gtoh((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - LittleEndianGuest::gtoh((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0x0123cdef, LittleEndianGuest::gtoh((uint32_t)0xefcd2301)); - EXPECT_EQ(0xfedc3210, LittleEndianGuest::gtoh((uint32_t)0x1032dcfe)); - EXPECT_EQ(0x0b1c41b1, LittleEndianGuest::gtoh((uint32_t)0xb1411c0b)); - EXPECT_EQ(0x0000ffff, LittleEndianGuest::gtoh((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, LittleEndianGuest::gtoh((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, LittleEndianGuest::gtoh((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0x01ef, LittleEndianGuest::gtoh((uint16_t)0xef01)); - EXPECT_EQ(0xfe10, LittleEndianGuest::gtoh((uint16_t)0x10fe)); - EXPECT_EQ(0x0bb1, LittleEndianGuest::gtoh((uint16_t)0xb10b)); - EXPECT_EQ(0x00ff, LittleEndianGuest::gtoh((uint16_t)0xff00)); - EXPECT_EQ(0x5555, LittleEndianGuest::gtoh((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, LittleEndianGuest::gtoh((uint16_t)0xa0a0)); -#elif defined(_LITTLE_ENDIAN) || BYTE_ORDER==LITTLE_ENDIAN - EXPECT_EQ(0xefcdab8967452301, - LittleEndianGuest::gtoh((uint64_t)0xefcdab8967452301)); - EXPECT_EQ(0x1032547698badcfe, - LittleEndianGuest::gtoh((uint64_t)0x1032547698badcfe)); - EXPECT_EQ(0xb14171b771b01c0b, - LittleEndianGuest::gtoh((uint64_t)0xb14171b771b01c0b)); - EXPECT_EQ(0xffffffff00000000, - LittleEndianGuest::gtoh((uint64_t)0xffffffff00000000)); - EXPECT_EQ(0x5555555555555555, - LittleEndianGuest::gtoh((uint64_t)0x5555555555555555)); - EXPECT_EQ(0xa0a0a0a0a0a0a0a0, - LittleEndianGuest::gtoh((uint64_t)0xa0a0a0a0a0a0a0a0)); - EXPECT_EQ(0xefcd2301, LittleEndianGuest::gtoh((uint32_t)0xefcd2301)); - EXPECT_EQ(0x1032dcfe, LittleEndianGuest::gtoh((uint32_t)0x1032dcfe)); - EXPECT_EQ(0xb1411c0b, LittleEndianGuest::gtoh((uint32_t)0xb1411c0b)); - EXPECT_EQ(0xffff0000, LittleEndianGuest::gtoh((uint32_t)0xffff0000)); - EXPECT_EQ(0x55555555, LittleEndianGuest::gtoh((uint32_t)0x55555555)); - EXPECT_EQ(0xa0a0a0a0, LittleEndianGuest::gtoh((uint32_t)0xa0a0a0a0)); - EXPECT_EQ(0xef01, LittleEndianGuest::gtoh((uint16_t)0xef01)); - EXPECT_EQ(0x10fe, LittleEndianGuest::gtoh((uint16_t)0x10fe)); - EXPECT_EQ(0xb10b, LittleEndianGuest::gtoh((uint16_t)0xb10b)); - EXPECT_EQ(0xff00, LittleEndianGuest::gtoh((uint16_t)0xff00)); - EXPECT_EQ(0x5555, LittleEndianGuest::gtoh((uint16_t)0x5555)); - EXPECT_EQ(0xa0a0, LittleEndianGuest::gtoh((uint16_t)0xa0a0)); -#else - #error Invalid Endianess -#endif -}