Chromium Code Reviews| Index: webrtc/common_audio/signal_processing/signal_processing_unittest.cc |
| diff --git a/webrtc/common_audio/signal_processing/signal_processing_unittest.cc b/webrtc/common_audio/signal_processing/signal_processing_unittest.cc |
| index 108f459c894898e837dec760dd9f634601c08fa4..0b6f468adf3563919225c63823b687134b816843 100644 |
| --- a/webrtc/common_audio/signal_processing/signal_processing_unittest.cc |
| +++ b/webrtc/common_audio/signal_processing/signal_processing_unittest.cc |
| @@ -8,6 +8,9 @@ |
| * be found in the AUTHORS file in the root of the source tree. |
| */ |
| +#include <algorithm> |
| +#include <sstream> |
| + |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" |
| @@ -118,26 +121,25 @@ TEST_F(SplTest, InlineTest) { |
| EXPECT_EQ(104, WebRtcSpl_AddSatW16(a16, b16)); |
| EXPECT_EQ(138, WebRtcSpl_SubSatW16(a16, b16)); |
| +} |
| - EXPECT_EQ(109410, WebRtcSpl_AddSatW32(a32, b32)); |
| - EXPECT_EQ(112832, WebRtcSpl_SubSatW32(a32, b32)); |
| - |
| - a32 = 0x80000000; |
| - b32 = 0x80000000; |
| - // Cast to signed int to avoid compiler complaint on gtest.h. |
| - EXPECT_EQ(static_cast<int>(0x80000000), WebRtcSpl_AddSatW32(a32, b32)); |
| - a32 = 0x7fffffff; |
| - b32 = 0x7fffffff; |
| - EXPECT_EQ(0x7fffffff, WebRtcSpl_AddSatW32(a32, b32)); |
| - a32 = 0; |
| - b32 = 0x80000000; |
| - EXPECT_EQ(0x7fffffff, WebRtcSpl_SubSatW32(a32, b32)); |
| - a32 = 0x7fffffff; |
| - b32 = 0x80000000; |
| - EXPECT_EQ(0x7fffffff, WebRtcSpl_SubSatW32(a32, b32)); |
| - a32 = 0x80000000; |
| - b32 = 0x7fffffff; |
| - EXPECT_EQ(static_cast<int>(0x80000000), WebRtcSpl_SubSatW32(a32, b32)); |
| +TEST_F(SplTest, AddSatW32) { |
|
tlegrand-webrtc
2016/05/20 11:07:14
AddSubSatW32? Or some other naming, telling that b
kwiberg-webrtc
2016/05/23 08:30:04
Done.
|
| + static constexpr int32_t kAddSubArgs[] = { |
| + INT32_MIN, INT32_MIN + 1, -3, -2, -1, 0, 1, -1, 2, |
| + 3, INT32_MAX - 1, INT32_MAX}; |
| + for (int32_t a : kAddSubArgs) { |
| + for (int32_t b : kAddSubArgs) { |
| + const int64_t sum = std::max<int64_t>( |
| + INT32_MIN, std::min<int64_t>(INT32_MAX, static_cast<int64_t>(a) + b)); |
| + const int64_t diff = std::max<int64_t>( |
| + INT32_MIN, std::min<int64_t>(INT32_MAX, static_cast<int64_t>(a) - b)); |
| + std::ostringstream ss; |
| + ss << a << " +/- " << b << ": sum " << sum << ", diff " << diff; |
| + SCOPED_TRACE(ss.str()); |
| + EXPECT_EQ(sum, WebRtcSpl_AddSatW32(a, b)); |
| + EXPECT_EQ(diff, WebRtcSpl_SubSatW32(a, b)); |
| + } |
| + } |
| } |
| TEST_F(SplTest, MathOperationsTest) { |