-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecho_test.cpp
91 lines (68 loc) · 1.46 KB
/
echo_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include<stdio.h>
#include<stdlib.h>
#include "echo_effect.h"
void target_test(int t) //TODO: make sure values are valid at each step
{
echo_effect *ee=new echo_effect(20,2);
ee->set_target_length(t);
ee->set_read_speed(2);
for(int i=0;i<50;i++)
ee->tick(0);
float target=ee->get_delay_line_length();
if((int)target==t)
{
printf(" test passed\n");
}
else
{
printf("test failed. wanted %d got %f\n",t,target);
exit(1);
}
delete(ee);
}
void min_test() //TODO check values to see if they are valid
{
echo_effect *ee=new echo_effect(20,2);
ee->set_target_length(-1);
ee->set_read_speed(2);
for(int i=0;i<50;i++)
ee->tick(0);
float target=ee->get_delay_line_length();
if((int)target==0)
{
printf(" test passed\n");
}
else
{
printf("test failed. wanted 0 got %f\n",target);
exit(1);
}
delete(ee);
}
void max_test()
{
echo_effect *ee=new echo_effect(20,2);
ee->set_target_length(-1);
ee->set_read_speed(-2);
for(int i=0;i<50;i++)
ee->tick(0);
float target=ee->get_delay_line_length();
int goal=20*2-1;
if((int)target==goal) //TODO, should be based on parameters
{
printf(" test passed\n");
}
else
{
printf("test failed. wanted %d got %f\n",goal,target);
exit(1);
}
delete(ee);
}
int main(int argc, char *argv[])
{
//target_test(5);
//min_test();
max_test();
return 0;
}