summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/SwapByteOrderTest.cpp
diff options
context:
space:
mode:
authorPawel Bylica <chfast@gmail.com>2015-05-20 14:57:43 +0000
committerPawel Bylica <chfast@gmail.com>2015-05-20 14:57:43 +0000
commitc3aeb85fe52eb0999bed20c0ee11cb014bd924c3 (patch)
treed68bc4cf07d2006fade2eb9542ff47481ae967c9 /llvm/unittests/Support/SwapByteOrderTest.cpp
parentff7d4fad5477c4a88c748f1c468476095ddc7fba (diff)
downloadbcm5719-llvm-c3aeb85fe52eb0999bed20c0ee11cb014bd924c3.tar.gz
bcm5719-llvm-c3aeb85fe52eb0999bed20c0ee11cb014bd924c3.zip
Unit tests for the getSwappedBytes(double) fix from r237673.
llvm-svn: 237795
Diffstat (limited to 'llvm/unittests/Support/SwapByteOrderTest.cpp')
-rw-r--r--llvm/unittests/Support/SwapByteOrderTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/unittests/Support/SwapByteOrderTest.cpp b/llvm/unittests/Support/SwapByteOrderTest.cpp
index 525cfc1aea8..4f2537c4d5d 100644
--- a/llvm/unittests/Support/SwapByteOrderTest.cpp
+++ b/llvm/unittests/Support/SwapByteOrderTest.cpp
@@ -125,6 +125,19 @@ TEST(getSwappedBytes, int64_t) {
sys::getSwappedBytes(int64_t(0x8877665544332211LL)));
}
+TEST(getSwappedBytes, float) {
+ EXPECT_EQ(1.79366203433576585078237386661e-43f, sys::getSwappedBytes(-0.0f));
+ // 0x11223344
+ EXPECT_EQ(7.1653228759765625e2f, sys::getSwappedBytes(1.2795344e-28f));
+}
+
+TEST(getSwappedBytes, double) {
+ EXPECT_EQ(6.32404026676795576546008054871e-322, sys::getSwappedBytes(-0.0));
+ // 0x1122334455667788
+ EXPECT_EQ(-7.08687663657301358331704585496e-268,
+ sys::getSwappedBytes(3.84141202447173065923064450234e-226));
+}
+
TEST(swapByteOrder, uint8_t) {
uint8_t value = 0x11;
sys::swapByteOrder(value);
@@ -173,4 +186,16 @@ TEST(swapByteOrder, int64_t) {
EXPECT_EQ(int64_t(0x1122334455667788LL), value);
}
+TEST(swapByteOrder, float) {
+ float value = 7.1653228759765625e2f; // 0x44332211
+ sys::swapByteOrder(value);
+ EXPECT_EQ(1.2795344e-28f, value);
+}
+
+TEST(swapByteOrder, double) {
+ double value = -7.08687663657301358331704585496e-268; // 0x8877665544332211
+ sys::swapByteOrder(value);
+ EXPECT_EQ(3.84141202447173065923064450234e-226, value);
+}
+
}
OpenPOWER on IntegriCloud