-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtonewheel_osc_test.c
51 lines (39 loc) · 1.03 KB
/
tonewheel_osc_test.c
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
/* Copyright (c) 2018 Peter Teichman */
#ifdef ROTO_TEST
#include "greatest.h"
#include "tonewheel_osc.h"
TEST test_tonewheel_osc_new() {
tonewheel_osc *osc = tonewheel_osc_new();
ASSERT_EQ_FMT(0, osc->phase_incrs[0], "%d");
for (int i = 0; i < 92; i++) {
ASSERT_EQ_FMT(0, osc->phases[i], "%d");
ASSERT_EQ_FMT(0, osc->volumes[i], "%d");
}
free(osc);
PASS();
}
TEST test_tonewheel_osc_fill1() {
tonewheel_osc *osc = tonewheel_osc_new();
tonewheel_osc_set_volume(osc, 46, 100);
int16_t block[10];
tonewheel_osc_fill(osc, &block[0], 10);
int16_t want[10];
want[0] = 0x0000;
want[1] = 0x0001;
want[2] = 0x0002;
want[3] = 0x0003;
want[4] = 0x0003;
want[5] = 0x0004;
want[6] = 0x0005;
want[7] = 0x0006;
want[8] = 0x0006;
want[9] = 0x0007;
ASSERT_MEM_EQ(want, block, 10 * sizeof(int16_t));
free(osc);
PASS();
}
GREATEST_SUITE(tonewheel_osc_suite) {
RUN_TEST(test_tonewheel_osc_new);
RUN_TEST(test_tonewheel_osc_fill1);
}
#endif