-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchromaprintbuilder_test.go
73 lines (69 loc) · 1.61 KB
/
chromaprintbuilder_test.go
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
package chromaprint
import (
"os"
"path/filepath"
"reflect"
"runtime"
"testing"
)
func Test_builder_Build(t *testing.T) {
filename := "fpcalc"
if runtime.GOOS == "windows" {
filename = filename + ".exe"
}
path, err := os.Getwd()
if err != nil {
t.Error(err)
}
filePath := filepath.Join(path, filename)
tests := []struct {
name string
b ChromaprintBuilder
want *Chromaprint
wantErr bool
}{
{
name: "default build",
b: NewBuilder(),
want: &Chromaprint{
options: builder{
filePath: filePath,
sampleRateInHz: -1,
channels: -1,
maxFingerPrintLength: 0,
chunkSizeInSeconds: -1,
algorithm: 2,
overlap: false,
},
},
wantErr: false,
}, {
name: "full build",
b: NewBuilder().WithPathToChromaprint("test").WithSampleRate(44100).WithChannels(2).WithMaxFingerPrintLength(120).WithChunksSize(5).WithAlgorithm(1).WithOverlap(true),
want: &Chromaprint{
options: builder{
filePath: "test",
sampleRateInHz: 44100,
channels: 2,
maxFingerPrintLength: 120,
chunkSizeInSeconds: 5,
algorithm: 1,
overlap: true,
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.b.Build()
if (err != nil) != tt.wantErr {
t.Errorf("Chromaprint.CreateFingerprints() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("builder.Build() = %v, want %v", got, tt.want)
}
})
}
}