-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnote_test.go
More file actions
35 lines (26 loc) · 860 Bytes
/
note_test.go
File metadata and controls
35 lines (26 loc) · 860 Bytes
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
package note_test
import (
"testing"
"github.com/heucuva/comparison"
"github.com/gotracker/playback/period"
)
// testPeriod defines a sampler period that follows the Amiga-style approach of note
// definition. Useful in calculating resampling.
type testPeriod = period.Amiga
func periodCompareTest(t *testing.T, lhs, rhs testPeriod, expected comparison.Spaceship) {
t.Helper()
if lhs.Compare(rhs) != expected {
t.Fatalf("%v <=> %v was not %v", lhs, rhs, expected)
}
}
func TestPeriodCompare(t *testing.T) {
lhs1 := testPeriod(1)
rhs1 := testPeriod(1)
periodCompareTest(t, lhs1, rhs1, comparison.SpaceshipEqual)
lhs2 := testPeriod(1)
rhs2 := testPeriod(2)
periodCompareTest(t, lhs2, rhs2, comparison.SpaceshipLeftGreater)
lhs3 := testPeriod(2)
rhs3 := testPeriod(1)
periodCompareTest(t, lhs3, rhs3, comparison.SpaceshipRightGreater)
}