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 #ifndef ANDROID_FXLAB_TYPETESTS_H
17 #define ANDROID_FXLAB_TYPETESTS_H
18
19
20 #include <gtest/gtest.h>
21 #include <iostream>
22 #include <unistd.h>
23
24 #include "../effects/Effects.h"
25 #include "../FunctionList.h"
26 namespace {
TEST(TypeTests,Templating)27 TEST(TypeTests, Templating) {
28 TremoloEffect t {1, 2};
29 VibratoEffect<float*> v {1, 2};
30 float x = 5;
31 t(x);
32 auto pass = std::get<0>(EffectsTuple);
33 auto descrip = std::get<1>(EffectsTuple);
34 auto vibdes = std::get<2>(EffectsTuple);
35 auto gaindes = std::get<3>(EffectsTuple);
36 auto f = descrip.buildDefaultEffect<float*>();
37 auto g = vibdes.buildDefaultEffect<float*>();
38 auto h = vibdes.buildDefaultEffect<float*>();
39 f(&x, &x + 1); g(&x, &x + 1); h(&x, &x + 1);
40 auto j = gaindes.buildDefaultEffect<float*>();
41 auto k = gaindes.modifyEffect<float*>(j, std::array<float, 1> {10});
42 float floatArr[4] = {1,2,3, 4};
43 for (int i =0; i < 4; i++) {
44 k(floatArr + i, floatArr + i + 1);
45 }
46 auto arr = std::array<float, 1> {10};
47 auto data = std::array<int, 5> {1, 2, 3, 4, 5};
48 std::function<void(int*, int*)> fe = std::get<Effect::GainDescription>(EffectsTuple).buildEffect<int*>(arr);
49 fe(data.begin(), data.end());
50 EXPECT_EQ(data[0], 2);
51
52 }
53 }
54 #endif //ANDROID_FXLAB_TYPETESTS_H
55