Fix clang errors in non-GYP_DEFINES=clang=1 build
BUG=1623 R=stefan@webrtc.org, tina.legrand@webrtc.org, tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1368004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3968 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -19,9 +19,9 @@ struct WebRtcOpusDecInst;
|
||||
namespace webrtc {
|
||||
|
||||
// Number of samples in a 60 ms stereo frame, sampled at 48 kHz.
|
||||
enum { kOpusNumberOfSamples = 480 * 6 * 2 };
|
||||
const int kOpusNumberOfSamples = 480 * 6 * 2;
|
||||
// Maximum number of bytes in output bitstream.
|
||||
enum { kMaxBytes = 1000 };
|
||||
const size_t kMaxBytes = 1000;
|
||||
|
||||
class OpusTest : public ::testing::Test {
|
||||
protected:
|
||||
|
||||
@@ -27,14 +27,15 @@ namespace webrtc {
|
||||
// tests for AudioVector already covers a number of different type parameters,
|
||||
// this test focuses on testing different number of channels, and keeping the
|
||||
// value type constant.
|
||||
|
||||
class AudioMultiVectorTest : public ::testing::TestWithParam<size_t> {
|
||||
protected:
|
||||
typedef int16_t T; // Use this value type for all tests.
|
||||
|
||||
AudioMultiVectorTest()
|
||||
: num_channels_(GetParam()), // Get the test parameter.
|
||||
interleaved_length_(num_channels_ * kLength) {
|
||||
array_interleaved_ = new T[num_channels_ * kLength];
|
||||
interleaved_length_(num_channels_ * array_length()) {
|
||||
array_interleaved_ = new T[num_channels_ * array_length()];
|
||||
}
|
||||
|
||||
~AudioMultiVectorTest() {
|
||||
@@ -43,14 +44,14 @@ class AudioMultiVectorTest : public ::testing::TestWithParam<size_t> {
|
||||
|
||||
virtual void SetUp() {
|
||||
// Populate test arrays.
|
||||
for (size_t i = 0; i < kLength; ++i) {
|
||||
for (size_t i = 0; i < array_length(); ++i) {
|
||||
array_[i] = static_cast<T>(i);
|
||||
}
|
||||
T* ptr = array_interleaved_;
|
||||
// Write 100, 101, 102, ... for first channel.
|
||||
// Write 200, 201, 202, ... for second channel.
|
||||
// And so on.
|
||||
for (size_t i = 0; i < kLength; ++i) {
|
||||
for (size_t i = 0; i < array_length(); ++i) {
|
||||
for (size_t j = 1; j <= num_channels_; ++j) {
|
||||
*ptr = j * 100 + i;
|
||||
++ptr;
|
||||
@@ -58,13 +59,13 @@ class AudioMultiVectorTest : public ::testing::TestWithParam<size_t> {
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
kLength = 10
|
||||
};
|
||||
size_t array_length() const {
|
||||
return sizeof(array_) / sizeof(array_[0]);
|
||||
}
|
||||
|
||||
const size_t num_channels_;
|
||||
size_t interleaved_length_;
|
||||
T array_[kLength];
|
||||
T array_[10];
|
||||
T* array_interleaved_;
|
||||
};
|
||||
|
||||
@@ -85,9 +86,9 @@ TEST_P(AudioMultiVectorTest, CreateAndDestroy) {
|
||||
|
||||
// Test the subscript operator [] for getting and setting.
|
||||
TEST_P(AudioMultiVectorTest, SubscriptOperator) {
|
||||
AudioMultiVector<T> vec(num_channels_, kLength);
|
||||
AudioMultiVector<T> vec(num_channels_, array_length());
|
||||
for (size_t channel = 0; channel < num_channels_; ++channel) {
|
||||
for (size_t i = 0; i < kLength; ++i) {
|
||||
for (size_t i = 0; i < array_length(); ++i) {
|
||||
vec[channel][i] = static_cast<T>(i);
|
||||
// Make sure to use the const version.
|
||||
const AudioVector<T>& audio_vec = vec[channel];
|
||||
@@ -104,11 +105,11 @@ TEST_P(AudioMultiVectorTest, PushBackInterleavedAndCopy) {
|
||||
AudioMultiVector<T> vec_copy(num_channels_);
|
||||
vec.CopyFrom(&vec_copy); // Copy from |vec| to |vec_copy|.
|
||||
ASSERT_EQ(num_channels_, vec.Channels());
|
||||
ASSERT_EQ(kLength, vec.Size());
|
||||
ASSERT_EQ(array_length(), vec.Size());
|
||||
ASSERT_EQ(num_channels_, vec_copy.Channels());
|
||||
ASSERT_EQ(kLength, vec_copy.Size());
|
||||
ASSERT_EQ(array_length(), vec_copy.Size());
|
||||
for (size_t channel = 0; channel < vec.Channels(); ++channel) {
|
||||
for (size_t i = 0; i < kLength; ++i) {
|
||||
for (size_t i = 0; i < array_length(); ++i) {
|
||||
EXPECT_EQ(static_cast<T>((channel + 1) * 100 + i), vec[channel][i]);
|
||||
EXPECT_EQ(vec[channel][i], vec_copy[channel][i]);
|
||||
}
|
||||
@@ -133,22 +134,23 @@ TEST_P(AudioMultiVectorTest, CopyToNull) {
|
||||
|
||||
// Test the PushBack method with another AudioMultiVector as input argument.
|
||||
TEST_P(AudioMultiVectorTest, PushBackVector) {
|
||||
AudioMultiVector<T> vec1(num_channels_, kLength);
|
||||
AudioMultiVector<T> vec2(num_channels_, kLength);
|
||||
// Set the first vector to [0, 1, ..., kLength - 1] + 100 * channel_number.
|
||||
// Set the second vector to [kLength, kLength + 1, ..., 2 * kLength - 1] +
|
||||
// 100 * channel_number.
|
||||
AudioMultiVector<T> vec1(num_channels_, array_length());
|
||||
AudioMultiVector<T> vec2(num_channels_, array_length());
|
||||
// Set the first vector to [0, 1, ..., array_length() - 1] +
|
||||
// 100 * channel_number.
|
||||
// Set the second vector to [array_length(), array_length() + 1, ...,
|
||||
// 2 * array_length() - 1] + 100 * channel_number.
|
||||
for (size_t channel = 0; channel < num_channels_; ++channel) {
|
||||
for (size_t i = 0; i < kLength; ++i) {
|
||||
for (size_t i = 0; i < array_length(); ++i) {
|
||||
vec1[channel][i] = static_cast<T>(i + 100 * channel);
|
||||
vec2[channel][i] = static_cast<T>(i + 100 * channel + kLength);
|
||||
vec2[channel][i] = static_cast<T>(i + 100 * channel + array_length());
|
||||
}
|
||||
}
|
||||
// Append vec2 to the back of vec1.
|
||||
vec1.PushBack(vec2);
|
||||
ASSERT_EQ(2u * kLength, vec1.Size());
|
||||
ASSERT_EQ(2u * array_length(), vec1.Size());
|
||||
for (size_t channel = 0; channel < num_channels_; ++channel) {
|
||||
for (size_t i = 0; i < 2 * kLength; ++i) {
|
||||
for (size_t i = 0; i < 2 * array_length(); ++i) {
|
||||
EXPECT_EQ(static_cast<T>(i + 100 * channel), vec1[channel][i]);
|
||||
}
|
||||
}
|
||||
@@ -162,12 +164,12 @@ TEST_P(AudioMultiVectorTest, PushBackFromIndex) {
|
||||
|
||||
// Append vec1 to the back of vec2 (which is empty). Read vec1 from the second
|
||||
// last element.
|
||||
vec2.PushBackFromIndex(vec1, kLength - 2);
|
||||
vec2.PushBackFromIndex(vec1, array_length() - 2);
|
||||
ASSERT_EQ(2u, vec2.Size());
|
||||
for (size_t channel = 0; channel < num_channels_; ++channel) {
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
EXPECT_EQ(array_interleaved_[channel + num_channels_ * (kLength - 2 + i)],
|
||||
vec2[channel][i]);
|
||||
EXPECT_EQ(array_interleaved_[channel + num_channels_ *
|
||||
(array_length() - 2 + i)], vec2[channel][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,11 +178,11 @@ TEST_P(AudioMultiVectorTest, PushBackFromIndex) {
|
||||
TEST_P(AudioMultiVectorTest, Zeros) {
|
||||
AudioMultiVector<T> vec(num_channels_);
|
||||
vec.PushBackInterleaved(array_interleaved_, interleaved_length_);
|
||||
vec.Zeros(2 * kLength);
|
||||
vec.Zeros(2 * array_length());
|
||||
ASSERT_EQ(num_channels_, vec.Channels());
|
||||
ASSERT_EQ(2u * kLength, vec.Size());
|
||||
ASSERT_EQ(2u * array_length(), vec.Size());
|
||||
for (size_t channel = 0; channel < num_channels_; ++channel) {
|
||||
for (size_t i = 0; i < 2 * kLength; ++i) {
|
||||
for (size_t i = 0; i < 2 * array_length(); ++i) {
|
||||
EXPECT_EQ(0, vec[channel][i]);
|
||||
}
|
||||
}
|
||||
@@ -199,7 +201,7 @@ TEST_P(AudioMultiVectorTest, ReadInterleaved) {
|
||||
|
||||
// Read too many samples. Expect to get all samples from the vector.
|
||||
EXPECT_EQ(interleaved_length_,
|
||||
vec.ReadInterleaved(kLength + 1, output));
|
||||
vec.ReadInterleaved(array_length() + 1, output));
|
||||
EXPECT_EQ(0, memcmp(array_interleaved_, output, read_samples * sizeof(T)));
|
||||
|
||||
delete [] output;
|
||||
@@ -220,17 +222,17 @@ TEST_P(AudioMultiVectorTest, PopFront) {
|
||||
AudioMultiVector<T> vec(num_channels_);
|
||||
vec.PushBackInterleaved(array_interleaved_, interleaved_length_);
|
||||
vec.PopFront(1); // Remove one element from each channel.
|
||||
ASSERT_EQ(kLength - 1u, vec.Size());
|
||||
ASSERT_EQ(array_length() - 1u, vec.Size());
|
||||
// Let |ptr| point to the second element of the first channel in the
|
||||
// interleaved array.
|
||||
T* ptr = &array_interleaved_[num_channels_];
|
||||
for (size_t i = 0; i < kLength - 1; ++i) {
|
||||
for (size_t i = 0; i < array_length() - 1; ++i) {
|
||||
for (size_t channel = 0; channel < num_channels_; ++channel) {
|
||||
EXPECT_EQ(*ptr, vec[channel][i]);
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
vec.PopFront(kLength); // Remove more elements than vector size.
|
||||
vec.PopFront(array_length()); // Remove more elements than vector size.
|
||||
EXPECT_EQ(0u, vec.Size());
|
||||
}
|
||||
|
||||
@@ -239,36 +241,36 @@ TEST_P(AudioMultiVectorTest, PopBack) {
|
||||
AudioMultiVector<T> vec(num_channels_);
|
||||
vec.PushBackInterleaved(array_interleaved_, interleaved_length_);
|
||||
vec.PopBack(1); // Remove one element from each channel.
|
||||
ASSERT_EQ(kLength - 1u, vec.Size());
|
||||
ASSERT_EQ(array_length() - 1u, vec.Size());
|
||||
// Let |ptr| point to the first element of the first channel in the
|
||||
// interleaved array.
|
||||
T* ptr = array_interleaved_;
|
||||
for (size_t i = 0; i < kLength - 1; ++i) {
|
||||
for (size_t i = 0; i < array_length() - 1; ++i) {
|
||||
for (size_t channel = 0; channel < num_channels_; ++channel) {
|
||||
EXPECT_EQ(*ptr, vec[channel][i]);
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
vec.PopBack(kLength); // Remove more elements than vector size.
|
||||
vec.PopBack(array_length()); // Remove more elements than vector size.
|
||||
EXPECT_EQ(0u, vec.Size());
|
||||
}
|
||||
|
||||
// Test the AssertSize method.
|
||||
TEST_P(AudioMultiVectorTest, AssertSize) {
|
||||
AudioMultiVector<T> vec(num_channels_, kLength);
|
||||
EXPECT_EQ(kLength, vec.Size());
|
||||
AudioMultiVector<T> vec(num_channels_, array_length());
|
||||
EXPECT_EQ(array_length(), vec.Size());
|
||||
// Start with asserting with smaller sizes than already allocated.
|
||||
vec.AssertSize(0);
|
||||
vec.AssertSize(kLength - 1);
|
||||
vec.AssertSize(array_length() - 1);
|
||||
// Nothing should have changed.
|
||||
EXPECT_EQ(kLength, vec.Size());
|
||||
EXPECT_EQ(array_length(), vec.Size());
|
||||
// Assert with one element longer than already allocated.
|
||||
vec.AssertSize(kLength + 1);
|
||||
vec.AssertSize(array_length() + 1);
|
||||
// Expect vector to have grown.
|
||||
EXPECT_EQ(kLength + 1u, vec.Size());
|
||||
EXPECT_EQ(array_length() + 1, vec.Size());
|
||||
// Also check the individual AudioVectors.
|
||||
for (size_t channel = 0; channel < vec.Channels(); ++channel) {
|
||||
EXPECT_EQ(kLength + 1u, vec[channel].Size());
|
||||
EXPECT_EQ(array_length() + 1u, vec[channel].Size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,9 +283,10 @@ TEST_P(AudioMultiVectorTest, OverwriteAt) {
|
||||
// Overwrite vec2 at position 5.
|
||||
vec1.OverwriteAt(vec2, 3, 5);
|
||||
// Verify result.
|
||||
ASSERT_EQ(kLength, vec1.Size()); // Length remains the same.
|
||||
// Length remains the same.
|
||||
ASSERT_EQ(array_length(), vec1.Size());
|
||||
T* ptr = array_interleaved_;
|
||||
for (size_t i = 0; i < kLength - 1; ++i) {
|
||||
for (size_t i = 0; i < array_length() - 1; ++i) {
|
||||
for (size_t channel = 0; channel < num_channels_; ++channel) {
|
||||
if (i >= 5 && i <= 7) {
|
||||
// Elements 5, 6, 7 should have been replaced with zeros.
|
||||
|
||||
@@ -27,23 +27,23 @@ namespace webrtc {
|
||||
// int32_t and double in this case. Each test is then run once for each of these
|
||||
// types.
|
||||
// A few special tricks are needed. For instance, the member variable |array_|
|
||||
// in the test fixture must be accessed using this->array_ in the tests. Also,
|
||||
// the enumerator value kLength must be accessed with TestFixture::kLength.
|
||||
// in the test fixture must be accessed using this->array_ in the tests.
|
||||
|
||||
template<typename T>
|
||||
class AudioVectorTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
// Populate test array.
|
||||
for (size_t i = 0; i < kLength; ++i) {
|
||||
for (size_t i = 0; i < array_length(); ++i) {
|
||||
array_[i] = static_cast<T>(i);
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
kLength = 10
|
||||
};
|
||||
size_t array_length() const {
|
||||
return sizeof(array_) / sizeof(array_[0]);
|
||||
}
|
||||
|
||||
T array_[kLength];
|
||||
T array_[10];
|
||||
};
|
||||
|
||||
// Instantiate typed tests with int16_t, int32_t, and double.
|
||||
@@ -65,8 +65,8 @@ TYPED_TEST(AudioVectorTest, CreateAndDestroy) {
|
||||
|
||||
// Test the subscript operator [] for getting and setting.
|
||||
TYPED_TEST(AudioVectorTest, SubscriptOperator) {
|
||||
AudioVector<TypeParam> vec(TestFixture::kLength);
|
||||
for (size_t i = 0; i < TestFixture::kLength; ++i) {
|
||||
AudioVector<TypeParam> vec(this->array_length());
|
||||
for (size_t i = 0; i < this->array_length(); ++i) {
|
||||
vec[i] = static_cast<TypeParam>(i);
|
||||
const TypeParam& value = vec[i]; // Make sure to use the const version.
|
||||
EXPECT_EQ(static_cast<TypeParam>(i), value);
|
||||
@@ -78,11 +78,11 @@ TYPED_TEST(AudioVectorTest, SubscriptOperator) {
|
||||
TYPED_TEST(AudioVectorTest, PushBackAndCopy) {
|
||||
AudioVector<TypeParam> vec;
|
||||
AudioVector<TypeParam> vec_copy;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
vec.CopyFrom(&vec_copy); // Copy from |vec| to |vec_copy|.
|
||||
ASSERT_EQ(TestFixture::kLength, vec.Size());
|
||||
ASSERT_EQ(TestFixture::kLength, vec_copy.Size());
|
||||
for (size_t i = 0; i < TestFixture::kLength; ++i) {
|
||||
ASSERT_EQ(this->array_length(), vec.Size());
|
||||
ASSERT_EQ(this->array_length(), vec_copy.Size());
|
||||
for (size_t i = 0; i < this->array_length(); ++i) {
|
||||
EXPECT_EQ(this->array_[i], vec[i]);
|
||||
EXPECT_EQ(this->array_[i], vec_copy[i]);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ TYPED_TEST(AudioVectorTest, PushBackAndCopy) {
|
||||
TYPED_TEST(AudioVectorTest, CopyToNull) {
|
||||
AudioVector<TypeParam> vec;
|
||||
AudioVector<TypeParam>* vec_copy = NULL;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
vec.CopyFrom(vec_copy);
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ TYPED_TEST(AudioVectorTest, PushBackVector) {
|
||||
// Test the PushFront method.
|
||||
TYPED_TEST(AudioVectorTest, PushFront) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushFront(this->array_, TestFixture::kLength);
|
||||
ASSERT_EQ(TestFixture::kLength, vec.Size());
|
||||
for (size_t i = 0; i < TestFixture::kLength; ++i) {
|
||||
vec.PushFront(this->array_, this->array_length());
|
||||
ASSERT_EQ(this->array_length(), vec.Size());
|
||||
for (size_t i = 0; i < this->array_length(); ++i) {
|
||||
EXPECT_EQ(this->array_[i], vec[i]);
|
||||
}
|
||||
}
|
||||
@@ -155,37 +155,37 @@ TYPED_TEST(AudioVectorTest, PushFrontVector) {
|
||||
// Test the PopFront method.
|
||||
TYPED_TEST(AudioVectorTest, PopFront) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
vec.PopFront(1); // Remove one element.
|
||||
EXPECT_EQ(TestFixture::kLength - 1u, vec.Size());
|
||||
for (size_t i = 0; i < TestFixture::kLength - 1; ++i) {
|
||||
EXPECT_EQ(this->array_length() - 1u, vec.Size());
|
||||
for (size_t i = 0; i < this->array_length() - 1; ++i) {
|
||||
EXPECT_EQ(static_cast<TypeParam>(i + 1), vec[i]);
|
||||
}
|
||||
vec.PopFront(TestFixture::kLength); // Remove more elements than vector size.
|
||||
vec.PopFront(this->array_length()); // Remove more elements than vector size.
|
||||
EXPECT_EQ(0u, vec.Size());
|
||||
}
|
||||
|
||||
// Test the PopBack method.
|
||||
TYPED_TEST(AudioVectorTest, PopBack) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
vec.PopBack(1); // Remove one element.
|
||||
EXPECT_EQ(TestFixture::kLength - 1u, vec.Size());
|
||||
for (size_t i = 0; i < TestFixture::kLength - 1; ++i) {
|
||||
EXPECT_EQ(this->array_length() - 1u, vec.Size());
|
||||
for (size_t i = 0; i < this->array_length() - 1; ++i) {
|
||||
EXPECT_EQ(static_cast<TypeParam>(i), vec[i]);
|
||||
}
|
||||
vec.PopBack(TestFixture::kLength); // Remove more elements than vector size.
|
||||
vec.PopBack(this->array_length()); // Remove more elements than vector size.
|
||||
EXPECT_EQ(0u, vec.Size());
|
||||
}
|
||||
|
||||
// Test the Extend method.
|
||||
TYPED_TEST(AudioVectorTest, Extend) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
vec.Extend(5); // Extend with 5 elements, which should all be zeros.
|
||||
ASSERT_EQ(TestFixture::kLength + 5u, vec.Size());
|
||||
ASSERT_EQ(this->array_length() + 5u, vec.Size());
|
||||
// Verify that all are zero.
|
||||
for (int i = TestFixture::kLength; i < TestFixture::kLength + 5; ++i) {
|
||||
for (size_t i = this->array_length(); i < this->array_length() + 5; ++i) {
|
||||
EXPECT_EQ(0, vec[i]);
|
||||
}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ TYPED_TEST(AudioVectorTest, Extend) {
|
||||
// Test the InsertAt method with an insert position in the middle of the vector.
|
||||
TYPED_TEST(AudioVectorTest, InsertAt) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
static const int kNewLength = 5;
|
||||
TypeParam new_array[kNewLength];
|
||||
// Set array elements to {100, 101, 102, ... }.
|
||||
@@ -205,7 +205,7 @@ TYPED_TEST(AudioVectorTest, InsertAt) {
|
||||
// Verify that the vector looks as follows:
|
||||
// {0, 1, ..., |insert_position| - 1, 100, 101, ..., 100 + kNewLength - 1,
|
||||
// |insert_position|, |insert_position| + 1, ..., kLength - 1}.
|
||||
int pos = 0;
|
||||
size_t pos = 0;
|
||||
for (int i = 0; i < insert_position; ++i) {
|
||||
EXPECT_EQ(this->array_[i], vec[pos]);
|
||||
++pos;
|
||||
@@ -214,7 +214,7 @@ TYPED_TEST(AudioVectorTest, InsertAt) {
|
||||
EXPECT_EQ(new_array[i], vec[pos]);
|
||||
++pos;
|
||||
}
|
||||
for (int i = insert_position; i < TestFixture::kLength; ++i) {
|
||||
for (size_t i = insert_position; i < this->array_length(); ++i) {
|
||||
EXPECT_EQ(this->array_[i], vec[pos]);
|
||||
++pos;
|
||||
}
|
||||
@@ -225,8 +225,8 @@ TYPED_TEST(AudioVectorTest, InsertAt) {
|
||||
TYPED_TEST(AudioVectorTest, InsertZerosAt) {
|
||||
AudioVector<TypeParam> vec;
|
||||
AudioVector<TypeParam> vec_ref;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec_ref.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
vec_ref.PushBack(this->array_, this->array_length());
|
||||
static const int kNewLength = 5;
|
||||
int insert_position = 5;
|
||||
vec.InsertZerosAt(kNewLength, insert_position);
|
||||
@@ -242,7 +242,7 @@ TYPED_TEST(AudioVectorTest, InsertZerosAt) {
|
||||
// Test the InsertAt method with an insert position at the start of the vector.
|
||||
TYPED_TEST(AudioVectorTest, InsertAtBeginning) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
static const int kNewLength = 5;
|
||||
TypeParam new_array[kNewLength];
|
||||
// Set array elements to {100, 101, 102, ... }.
|
||||
@@ -254,12 +254,12 @@ TYPED_TEST(AudioVectorTest, InsertAtBeginning) {
|
||||
// Verify that the vector looks as follows:
|
||||
// {100, 101, ..., 100 + kNewLength - 1,
|
||||
// 0, 1, ..., kLength - 1}.
|
||||
int pos = 0;
|
||||
size_t pos = 0;
|
||||
for (int i = 0; i < kNewLength; ++i) {
|
||||
EXPECT_EQ(new_array[i], vec[pos]);
|
||||
++pos;
|
||||
}
|
||||
for (int i = insert_position; i < TestFixture::kLength; ++i) {
|
||||
for (size_t i = insert_position; i < this->array_length(); ++i) {
|
||||
EXPECT_EQ(this->array_[i], vec[pos]);
|
||||
++pos;
|
||||
}
|
||||
@@ -268,19 +268,19 @@ TYPED_TEST(AudioVectorTest, InsertAtBeginning) {
|
||||
// Test the InsertAt method with an insert position at the end of the vector.
|
||||
TYPED_TEST(AudioVectorTest, InsertAtEnd) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
static const int kNewLength = 5;
|
||||
TypeParam new_array[kNewLength];
|
||||
// Set array elements to {100, 101, 102, ... }.
|
||||
for (int i = 0; i < kNewLength; ++i) {
|
||||
new_array[i] = 100 + i;
|
||||
}
|
||||
int insert_position = TestFixture::kLength;
|
||||
int insert_position = this->array_length();
|
||||
vec.InsertAt(new_array, kNewLength, insert_position);
|
||||
// Verify that the vector looks as follows:
|
||||
// {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }.
|
||||
int pos = 0;
|
||||
for (int i = 0; i < TestFixture::kLength; ++i) {
|
||||
size_t pos = 0;
|
||||
for (size_t i = 0; i < this->array_length(); ++i) {
|
||||
EXPECT_EQ(this->array_[i], vec[pos]);
|
||||
++pos;
|
||||
}
|
||||
@@ -297,19 +297,19 @@ TYPED_TEST(AudioVectorTest, InsertAtEnd) {
|
||||
// allowed value.
|
||||
TYPED_TEST(AudioVectorTest, InsertBeyondEnd) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
static const int kNewLength = 5;
|
||||
TypeParam new_array[kNewLength];
|
||||
// Set array elements to {100, 101, 102, ... }.
|
||||
for (int i = 0; i < kNewLength; ++i) {
|
||||
new_array[i] = 100 + i;
|
||||
}
|
||||
int insert_position = TestFixture::kLength + 10; // Too large.
|
||||
int insert_position = this->array_length() + 10; // Too large.
|
||||
vec.InsertAt(new_array, kNewLength, insert_position);
|
||||
// Verify that the vector looks as follows:
|
||||
// {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }.
|
||||
int pos = 0;
|
||||
for (int i = 0; i < TestFixture::kLength; ++i) {
|
||||
size_t pos = 0;
|
||||
for (size_t i = 0; i < this->array_length(); ++i) {
|
||||
EXPECT_EQ(this->array_[i], vec[pos]);
|
||||
++pos;
|
||||
}
|
||||
@@ -323,19 +323,19 @@ TYPED_TEST(AudioVectorTest, InsertBeyondEnd) {
|
||||
// fit within the old vector.
|
||||
TYPED_TEST(AudioVectorTest, OverwriteAt) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
static const int kNewLength = 5;
|
||||
TypeParam new_array[kNewLength];
|
||||
// Set array elements to {100, 101, 102, ... }.
|
||||
for (int i = 0; i < kNewLength; ++i) {
|
||||
new_array[i] = 100 + i;
|
||||
}
|
||||
int insert_position = 2;
|
||||
size_t insert_position = 2;
|
||||
vec.OverwriteAt(new_array, kNewLength, insert_position);
|
||||
// Verify that the vector looks as follows:
|
||||
// {0, ..., |insert_position| - 1, 100, 101, ..., 100 + kNewLength - 1,
|
||||
// |insert_position|, |insert_position| + 1, ..., kLength - 1}.
|
||||
int pos = 0;
|
||||
size_t pos = 0;
|
||||
for (pos = 0; pos < insert_position; ++pos) {
|
||||
EXPECT_EQ(this->array_[pos], vec[pos]);
|
||||
}
|
||||
@@ -343,7 +343,7 @@ TYPED_TEST(AudioVectorTest, OverwriteAt) {
|
||||
EXPECT_EQ(new_array[i], vec[pos]);
|
||||
++pos;
|
||||
}
|
||||
for (; pos < TestFixture::kLength; ++pos) {
|
||||
for (; pos < this->array_length(); ++pos) {
|
||||
EXPECT_EQ(this->array_[pos], vec[pos]);
|
||||
}
|
||||
}
|
||||
@@ -353,16 +353,16 @@ TYPED_TEST(AudioVectorTest, OverwriteAt) {
|
||||
// expected to expand to accommodate the new values.
|
||||
TYPED_TEST(AudioVectorTest, OverwriteBeyondEnd) {
|
||||
AudioVector<TypeParam> vec;
|
||||
vec.PushBack(this->array_, TestFixture::kLength);
|
||||
vec.PushBack(this->array_, this->array_length());
|
||||
static const int kNewLength = 5;
|
||||
TypeParam new_array[kNewLength];
|
||||
// Set array elements to {100, 101, 102, ... }.
|
||||
for (int i = 0; i < kNewLength; ++i) {
|
||||
new_array[i] = 100 + i;
|
||||
}
|
||||
int insert_position = TestFixture::kLength - 2;
|
||||
int insert_position = this->array_length() - 2;
|
||||
vec.OverwriteAt(new_array, kNewLength, insert_position);
|
||||
ASSERT_EQ(TestFixture::kLength - 2u + kNewLength, vec.Size());
|
||||
ASSERT_EQ(this->array_length() - 2u + kNewLength, vec.Size());
|
||||
// Verify that the vector looks as follows:
|
||||
// {0, ..., |insert_position| - 1, 100, 101, ..., 100 + kNewLength - 1,
|
||||
// |insert_position|, |insert_position| + 1, ..., kLength - 1}.
|
||||
|
||||
Reference in New Issue
Block a user