diff options
author | Daniel Sanders <daniel.sanders@imgtec.com> | 2015-11-20 13:13:53 +0000 |
---|---|---|
committer | Daniel Sanders <daniel.sanders@imgtec.com> | 2015-11-20 13:13:53 +0000 |
commit | be9db3c00a1d3e2d88be1ce0edc1cc059ce4f785 (patch) | |
tree | 761866dd8788c89ac922959896ed7349ddaeb7e0 /llvm/unittests/Support/MathExtrasTest.cpp | |
parent | 1e929f97f67f4e7c98d8eaa0b87abee415dc35e5 (diff) | |
download | bcm5719-llvm-be9db3c00a1d3e2d88be1ce0edc1cc059ce4f785.tar.gz bcm5719-llvm-be9db3c00a1d3e2d88be1ce0edc1cc059ce4f785.zip |
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
Diffstat (limited to 'llvm/unittests/Support/MathExtrasTest.cpp')
-rw-r--r-- | llvm/unittests/Support/MathExtrasTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/unittests/Support/MathExtrasTest.cpp b/llvm/unittests/Support/MathExtrasTest.cpp index 8bd47e34c7e..0f3854680ac 100644 --- a/llvm/unittests/Support/MathExtrasTest.cpp +++ b/llvm/unittests/Support/MathExtrasTest.cpp @@ -190,4 +190,21 @@ TEST(MathExtras, RoundUpToAlignment) { 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>(); +} + } |