Index: media/base/audio_bus_unittest.cc |
diff --git a/media/base/audio_bus_unittest.cc b/media/base/audio_bus_unittest.cc |
index dadb8e986e7ce9eaf8692aba263d19b25e7d2105..69326231780d8febf1b26ca3acfeba0cd0e040f3 100644 |
--- a/media/base/audio_bus_unittest.cc |
+++ b/media/base/audio_bus_unittest.cc |
@@ -252,18 +252,25 @@ TEST_F(AudioBusTest, Zero) { |
// Each test vector represents two channels of data in the following arbitrary |
// layout: <min, zero, max, min, max / 2, min / 2, zero, max, zero, zero>. |
+// The max / 2 values have 0.5 added to them to round them to the nearest int. |
static const int kTestVectorSize = 10; |
static const uint8_t kTestVectorUint8[kTestVectorSize] = { |
- 0, -INT8_MIN, UINT8_MAX, |
- 0, INT8_MAX / 2 + 128, INT8_MIN / 2 + 128, |
- -INT8_MIN, UINT8_MAX, -INT8_MIN, |
+ 0, |
+ -INT8_MIN, |
+ UINT8_MAX, |
+ 0, |
+ (INT8_MAX / 2.0 + 0.5) + 128, |
+ (INT8_MIN / 2.0) + 128, |
+ -INT8_MIN, |
+ UINT8_MAX, |
+ -INT8_MIN, |
-INT8_MIN}; |
static const int16_t kTestVectorInt16[kTestVectorSize] = { |
- INT16_MIN, 0, INT16_MAX, INT16_MIN, INT16_MAX / 2, |
- INT16_MIN / 2, 0, INT16_MAX, 0, 0}; |
+ INT16_MIN, 0, INT16_MAX, INT16_MIN, INT16_MAX / 2.0 + 0.5, |
+ INT16_MIN / 2.0, 0, INT16_MAX, 0, 0}; |
static const int32_t kTestVectorInt32[kTestVectorSize] = { |
- INT32_MIN, 0, INT32_MAX, INT32_MIN, INT32_MAX / 2, |
- INT32_MIN / 2, 0, INT32_MAX, 0, 0}; |
+ INT32_MIN, 0, INT32_MAX, INT32_MIN, INT32_MAX / 2.0 + 0.5, |
+ INT32_MIN / 2.0, 0, INT32_MAX, 0, 0}; |
// Expected results. |
static const int kTestVectorFrames = kTestVectorSize / 2; |
@@ -366,12 +373,14 @@ TEST_F(AudioBusTest, ToInterleaved) { |
// let the test pass with an off by one check on the half-max. |
int32_t fixed_test_array[arraysize(kTestVectorInt32)]; |
memcpy(fixed_test_array, kTestVectorInt32, sizeof(kTestVectorInt32)); |
- ASSERT_EQ(fixed_test_array[4], std::numeric_limits<int32_t>::max() / 2); |
+ ASSERT_EQ( |
+ fixed_test_array[4], |
+ round(static_cast<double>(std::numeric_limits<int32_t>::max() / 2.0))); |
fixed_test_array[4]++; |
ASSERT_TRUE( |
- memcmp(test_array, kTestVectorInt32, sizeof(kTestVectorInt32)) == 0 || |
- memcmp(test_array, fixed_test_array, sizeof(fixed_test_array)) == 0); |
+ memcmp(test_array, kTestVectorInt32, sizeof(kTestVectorInt32)) == 0 || |
+ memcmp(test_array, fixed_test_array, sizeof(fixed_test_array)) == 0); |
} |
} |