• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright  2019 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_FXLAB_DELAYLINETEST_H
18 #define ANDROID_FXLAB_DELAYLINETEST_H
19 
20 #include "../effects/utils/DelayLine.h"
21 #include <gtest/gtest.h>
22 
23 namespace {
TEST(DelayLineTest,CreateAndAdd)24 TEST(DelayLineTest, CreateAndAdd) {
25     DelayLine<float> d1{10};
26     d1.push(1.0);
27     EXPECT_EQ(d1[1], 1.0);
28 }
TEST(DelayLineTest,UnfilledAddSequence)29 TEST(DelayLineTest, UnfilledAddSequence) {
30     DelayLine<float> d1{10};
31 d1.push(1.0);
32 d1.push(2.0);
33     d1.push(3.0);
34     EXPECT_EQ(d1[1], 3.0);
35     EXPECT_EQ(d1[2], 2.0);
36     EXPECT_EQ(d1[3], 1.0);
37 }
TEST(DelayLineTest,FilledAddSequence)38 TEST(DelayLineTest, FilledAddSequence) {
39     DelayLine<float> d1{4};
40     d1.push(1.0);
41     d1.push(2.0);
42     d1.push(3.0);
43     d1.push(4.0);
44     EXPECT_EQ(d1[1], 4.0);
45     EXPECT_EQ(d1[2], 3.0);
46     EXPECT_EQ(d1[3], 2.0);
47     EXPECT_EQ(d1[4], 1.0);
48     d1.push(5.0);
49     EXPECT_EQ(d1[1], 5.0);
50     EXPECT_EQ(d1[2], 4.0);
51     EXPECT_EQ(d1[3], 3.0);
52     EXPECT_EQ(d1[4], 2.0);
53     d1.push(6.0);
54     EXPECT_EQ(d1[1], 6.0);
55     EXPECT_EQ(d1[2], 5.0);
56     EXPECT_EQ(d1[3], 4.0);
57     EXPECT_EQ(d1[4], 3.0);
58 }
59 
60 } // namespace
61 #endif //ANDROID_FXLAB_DELAYLINETEST_H
62