mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Support: Clean up getRounded() tests
llvm-svn: 211337
This commit is contained in:
parent
4d04667b18
commit
d63ac88ff6
@ -53,6 +53,18 @@ inline std::pair<DigitsT, int16_t> getRounded(DigitsT Digits, int16_t Scale,
|
||||
return std::make_pair(Digits, Scale);
|
||||
}
|
||||
|
||||
/// \brief Convenience helper for 32-bit rounding.
|
||||
inline std::pair<uint32_t, int16_t> getRounded32(uint32_t Digits, int16_t Scale,
|
||||
bool ShouldRound) {
|
||||
return getRounded(Digits, Scale, ShouldRound);
|
||||
}
|
||||
|
||||
/// \brief Convenience helper for 64-bit rounding.
|
||||
inline std::pair<uint64_t, int16_t> getRounded64(uint64_t Digits, int16_t Scale,
|
||||
bool ShouldRound) {
|
||||
return getRounded(Digits, Scale, ShouldRound);
|
||||
}
|
||||
|
||||
/// \brief Adjust a 64-bit scaled number down to the appropriate width.
|
||||
///
|
||||
/// Adjust a soft float with 64-bits of digits down, keeping as much
|
||||
|
@ -41,21 +41,19 @@ typedef ScaledPair<uint32_t> SP32;
|
||||
typedef ScaledPair<uint64_t> SP64;
|
||||
|
||||
TEST(ScaledNumberHelpersTest, getRounded) {
|
||||
EXPECT_EQ(getRounded<uint32_t>(0, 0, false), SP32(0, 0));
|
||||
EXPECT_EQ(getRounded<uint32_t>(0, 0, true), SP32(1, 0));
|
||||
EXPECT_EQ(getRounded<uint32_t>(20, 21, true), SP32(21, 21));
|
||||
EXPECT_EQ(getRounded<uint32_t>(UINT32_MAX, 0, false), SP32(UINT32_MAX, 0));
|
||||
EXPECT_EQ(getRounded<uint32_t>(UINT32_MAX, 0, true), SP32(1 << 31, 1));
|
||||
EXPECT_EQ(getRounded32(0, 0, false), SP32(0, 0));
|
||||
EXPECT_EQ(getRounded32(0, 0, true), SP32(1, 0));
|
||||
EXPECT_EQ(getRounded32(20, 21, true), SP32(21, 21));
|
||||
EXPECT_EQ(getRounded32(UINT32_MAX, 0, false), SP32(UINT32_MAX, 0));
|
||||
EXPECT_EQ(getRounded32(UINT32_MAX, 0, true), SP32(1 << 31, 1));
|
||||
|
||||
EXPECT_EQ(getRounded<uint64_t>(0, 0, false), SP64(0, 0));
|
||||
EXPECT_EQ(getRounded<uint64_t>(0, 0, true), SP64(1, 0));
|
||||
EXPECT_EQ(getRounded<uint64_t>(20, 21, true), SP64(21, 21));
|
||||
EXPECT_EQ(getRounded<uint64_t>(UINT32_MAX, 0, false), SP64(UINT32_MAX, 0));
|
||||
EXPECT_EQ(getRounded<uint64_t>(UINT32_MAX, 0, true),
|
||||
SP64(UINT64_C(1) << 32, 0));
|
||||
EXPECT_EQ(getRounded<uint64_t>(UINT64_MAX, 0, false), SP64(UINT64_MAX, 0));
|
||||
EXPECT_EQ(getRounded<uint64_t>(UINT64_MAX, 0, true),
|
||||
SP64(UINT64_C(1) << 63, 1));
|
||||
EXPECT_EQ(getRounded64(0, 0, false), SP64(0, 0));
|
||||
EXPECT_EQ(getRounded64(0, 0, true), SP64(1, 0));
|
||||
EXPECT_EQ(getRounded64(20, 21, true), SP64(21, 21));
|
||||
EXPECT_EQ(getRounded64(UINT32_MAX, 0, false), SP64(UINT32_MAX, 0));
|
||||
EXPECT_EQ(getRounded64(UINT32_MAX, 0, true), SP64(UINT64_C(1) << 32, 0));
|
||||
EXPECT_EQ(getRounded64(UINT64_MAX, 0, false), SP64(UINT64_MAX, 0));
|
||||
EXPECT_EQ(getRounded64(UINT64_MAX, 0, true), SP64(UINT64_C(1) << 63, 1));
|
||||
}
|
||||
|
||||
TEST(FloatsTest, getAdjusted) {
|
||||
|
Loading…
Reference in New Issue
Block a user