• 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_DELAYLINEEFFECTTEST_H
18 #define ANDROID_FXLAB_DELAYLINEEFFECTTEST_H
19 
20 
21 #include <gtest/gtest.h>
22 
23 #include "../effects/DelayLineEffect.h"
24 
25 
26 namespace {
TEST(DelayLineEffectTest,SingleFeedForwardTest)27     TEST(DelayLineEffectTest, SingleFeedForwardTest) {
28         DelayLineEffect<float*> e1 {0, 1, 0, 1, 0, [](){return 0;}};
29         std::array<float, 5> inputData {1, 0, 0.5, 0.25, 0};
30         for (int i = 0; i < 5; i++){
31             e1(inputData[i]);
32         }
33         EXPECT_EQ(inputData[0], 0);
34         EXPECT_EQ(inputData[1], 1);
35         EXPECT_EQ(inputData[2], 0);
36         EXPECT_EQ(inputData[3], 0.5);
37         EXPECT_EQ(inputData[4], 0.25);
38     }
TEST(DelayLineEffectTest,FFandBlendTest)39     TEST(DelayLineEffectTest, FFandBlendTest) {
40         DelayLineEffect<float*> e1 {1, 1, 0, 1, 0, [](){return 0;}};
41         std::array<float, 5> inputData {1, 0, 0.5, 0.25, 0};
42         for (int i = 0; i < 5; i++) {
43             e1(inputData[i]);
44         }
45         EXPECT_EQ(inputData[0], 1);
46         EXPECT_EQ(inputData[1], 1);
47         EXPECT_EQ(inputData[2], 0.5);
48         EXPECT_EQ(inputData[3], 0.75);
49         EXPECT_EQ(inputData[4], 0.25);
50     }
51 }
52 #endif //ANDROID_FXLAB_DELAYLINEEFFECTTEST_H
53