1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

Unit tests for the getSwappedBytes(double) fix from r237673.

llvm-svn: 237795
This commit is contained in:
Pawel Bylica 2015-05-20 14:57:43 +00:00
parent 61af0b4fda
commit b258368697

View File

@ -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);
}
}