Support: Clean up getRounded() tests
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 20 Jun 2014 02:31:07 +0000 (02:31 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 20 Jun 2014 02:31:07 +0000 (02:31 +0000)
llvm-svn: 211337

llvm/include/llvm/Support/ScaledNumber.h
llvm/unittests/Support/ScaledNumberTest.cpp

index 54b5386..f6594ec 100644 (file)
@@ -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
index dac2405..d1277d0 100644 (file)
@@ -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) {