Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: webrtc/common_audio/audio_util_unittest.cc

Issue 1227203003: Update audio code to use size_t more correctly, webrtc/common_audio/ portion. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/common_audio/audio_util.cc ('k') | webrtc/common_audio/blocker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_audio/audio_util_unittest.cc
diff --git a/webrtc/common_audio/audio_util_unittest.cc b/webrtc/common_audio/audio_util_unittest.cc
index 3ac391144598949c3dce9e735e0e1d3ee17ca87f..5583778b28d71abab407bf3e5f92014031a5c56e 100644
--- a/webrtc/common_audio/audio_util_unittest.cc
+++ b/webrtc/common_audio/audio_util_unittest.cc
@@ -18,20 +18,20 @@ namespace {
using ::testing::ElementsAreArray;
-void ExpectArraysEq(const int16_t* ref, const int16_t* test, int length) {
- for (int i = 0; i < length; ++i) {
+void ExpectArraysEq(const int16_t* ref, const int16_t* test, size_t length) {
+ for (size_t i = 0; i < length; ++i) {
EXPECT_EQ(ref[i], test[i]);
}
}
-void ExpectArraysEq(const float* ref, const float* test, int length) {
- for (int i = 0; i < length; ++i) {
+void ExpectArraysEq(const float* ref, const float* test, size_t length) {
+ for (size_t i = 0; i < length; ++i) {
EXPECT_FLOAT_EQ(ref[i], test[i]);
}
}
TEST(AudioUtilTest, FloatToS16) {
- const int kSize = 9;
+ const size_t kSize = 9;
const float kInput[kSize] = {0.f,
0.4f / 32767.f,
0.6f / 32767.f,
@@ -49,7 +49,7 @@ TEST(AudioUtilTest, FloatToS16) {
}
TEST(AudioUtilTest, S16ToFloat) {
- const int kSize = 7;
+ const size_t kSize = 7;
const int16_t kInput[kSize] = {0, 1, -1, 16384, -16384, 32767, -32768};
const float kReference[kSize] = {
0.f, 1.f / 32767.f, -1.f / 32768.f, 16384.f / 32767.f, -0.5f, 1.f, -1.f};
@@ -59,7 +59,7 @@ TEST(AudioUtilTest, S16ToFloat) {
}
TEST(AudioUtilTest, FloatS16ToS16) {
- const int kSize = 7;
+ const size_t kSize = 7;
const float kInput[kSize] = {0.f, 0.4f, 0.5f, -0.4f,
-0.5f, 32768.f, -32769.f};
const int16_t kReference[kSize] = {0, 0, 1, 0, -1, 32767, -32768};
@@ -69,7 +69,7 @@ TEST(AudioUtilTest, FloatS16ToS16) {
}
TEST(AudioUtilTest, FloatToFloatS16) {
- const int kSize = 9;
+ const size_t kSize = 9;
const float kInput[kSize] = {0.f,
0.4f / 32767.f,
0.6f / 32767.f,
@@ -87,7 +87,7 @@ TEST(AudioUtilTest, FloatToFloatS16) {
}
TEST(AudioUtilTest, FloatS16ToFloat) {
- const int kSize = 9;
+ const size_t kSize = 9;
const float kInput[kSize] = {0.f, 0.4f, 0.6f, -0.4f, -0.6f,
32767.f, -32768.f, 36043.7f, -36044.8f};
const float kReference[kSize] = {0.f,
@@ -106,9 +106,9 @@ TEST(AudioUtilTest, FloatS16ToFloat) {
TEST(AudioUtilTest, InterleavingStereo) {
const int16_t kInterleaved[] = {2, 3, 4, 9, 8, 27, 16, 81};
- const int kSamplesPerChannel = 4;
+ const size_t kSamplesPerChannel = 4;
const int kNumChannels = 2;
- const int kLength = kSamplesPerChannel * kNumChannels;
+ const size_t kLength = kSamplesPerChannel * kNumChannels;
int16_t left[kSamplesPerChannel], right[kSamplesPerChannel];
int16_t* deinterleaved[] = {left, right};
Deinterleave(kInterleaved, kSamplesPerChannel, kNumChannels, deinterleaved);
@@ -124,7 +124,7 @@ TEST(AudioUtilTest, InterleavingStereo) {
TEST(AudioUtilTest, InterleavingMonoIsIdentical) {
const int16_t kInterleaved[] = {1, 2, 3, 4, 5};
- const int kSamplesPerChannel = 5;
+ const size_t kSamplesPerChannel = 5;
const int kNumChannels = 1;
int16_t mono[kSamplesPerChannel];
int16_t* deinterleaved[] = {mono};
@@ -138,7 +138,7 @@ TEST(AudioUtilTest, InterleavingMonoIsIdentical) {
TEST(AudioUtilTest, DownmixInterleavedToMono) {
{
- const int kNumFrames = 4;
+ const size_t kNumFrames = 4;
const int kNumChannels = 1;
const int16_t interleaved[kNumChannels * kNumFrames] = {1, 2, -1, -3};
int16_t deinterleaved[kNumFrames];
@@ -149,7 +149,7 @@ TEST(AudioUtilTest, DownmixInterleavedToMono) {
EXPECT_THAT(deinterleaved, ElementsAreArray(interleaved));
}
{
- const int kNumFrames = 2;
+ const size_t kNumFrames = 2;
const int kNumChannels = 2;
const int16_t interleaved[kNumChannels * kNumFrames] = {10, 20, -10, -30};
int16_t deinterleaved[kNumFrames];
@@ -161,7 +161,7 @@ TEST(AudioUtilTest, DownmixInterleavedToMono) {
EXPECT_THAT(deinterleaved, ElementsAreArray(expected));
}
{
- const int kNumFrames = 3;
+ const size_t kNumFrames = 3;
const int kNumChannels = 3;
const int16_t interleaved[kNumChannels * kNumFrames] = {
30000, 30000, 24001, -5, -10, -20, -30000, -30999, -30000};
@@ -177,7 +177,7 @@ TEST(AudioUtilTest, DownmixInterleavedToMono) {
TEST(AudioUtilTest, DownmixToMonoTest) {
{
- const int kNumFrames = 4;
+ const size_t kNumFrames = 4;
const int kNumChannels = 1;
const float input_data[kNumChannels][kNumFrames] = {{1.f, 2.f, -1.f, -3.f}};
const float* input[kNumChannels];
@@ -192,7 +192,7 @@ TEST(AudioUtilTest, DownmixToMonoTest) {
EXPECT_THAT(downmixed, ElementsAreArray(input_data[0]));
}
{
- const int kNumFrames = 3;
+ const size_t kNumFrames = 3;
const int kNumChannels = 2;
const float input_data[kNumChannels][kNumFrames] = {{1.f, 2.f, -1.f},
{3.f, 0.f, 1.f}};
@@ -209,7 +209,7 @@ TEST(AudioUtilTest, DownmixToMonoTest) {
EXPECT_THAT(downmixed, ElementsAreArray(expected));
}
{
- const int kNumFrames = 3;
+ const size_t kNumFrames = 3;
const int kNumChannels = 3;
const int16_t input_data[kNumChannels][kNumFrames] = {
{30000, -5, -30000}, {30000, -10, -30999}, {24001, -20, -30000}};
« no previous file with comments | « webrtc/common_audio/audio_util.cc ('k') | webrtc/common_audio/blocker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698