Revert the revert 253497 and 253539 - These commits aren't the cause of the clang-cmake-mips failures.
Sorry for the noise.
llvm-svn: 253662
diff --git a/llvm/unittests/Support/MathExtrasTest.cpp b/llvm/unittests/Support/MathExtrasTest.cpp
index 8bd47e3..0f38546 100644
--- a/llvm/unittests/Support/MathExtrasTest.cpp
+++ b/llvm/unittests/Support/MathExtrasTest.cpp
@@ -190,4 +190,21 @@
EXPECT_EQ(552u, RoundUpToAlignment(321, 255, 42));
}
+template<typename T>
+void SaturatingAddTestHelper()
+{
+ const T Max = std::numeric_limits<T>::max();
+ EXPECT_EQ(T(3), SaturatingAdd(T(1), T(2)));
+ EXPECT_EQ(Max, SaturatingAdd(Max, T(1)));
+ EXPECT_EQ(Max, SaturatingAdd(T(1), Max));
+ EXPECT_EQ(Max, SaturatingAdd(Max, Max));
+}
+
+TEST(MathExtras, SaturatingAdd) {
+ SaturatingAddTestHelper<uint8_t>();
+ SaturatingAddTestHelper<uint16_t>();
+ SaturatingAddTestHelper<uint32_t>();
+ SaturatingAddTestHelper<uint64_t>();
+}
+
}