SaturatingAddTestHelper<uint64_t>();
}
-template<typename T>
-void SaturatingMultiplyTestHelper()
-{
- const T Max = std::numeric_limits<T>::max();
- EXPECT_EQ(T(0), SaturatingMultiply(T(1), T(0)));
- EXPECT_EQ(T(0), SaturatingMultiply(T(0), T(1)));
- EXPECT_EQ(T(6), SaturatingMultiply(T(2), T(3)));
- EXPECT_EQ(Max, SaturatingMultiply(Max, T(2)));
- EXPECT_EQ(Max, SaturatingMultiply(T(2),Max));
- EXPECT_EQ(Max, SaturatingMultiply(Max, Max));
-}
-
-TEST(MathExtras, SaturatingMultiply) {
- SaturatingMultiplyTestHelper<uint8_t>();
- SaturatingMultiplyTestHelper<uint16_t>();
- SaturatingMultiplyTestHelper<uint32_t>();
- SaturatingMultiplyTestHelper<uint64_t>();
-}
-
}