-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32a704b
commit 068a4df
Showing
8 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
bin/ | ||
*.json | ||
coverage.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
.PHONY: build | ||
build: | ||
CGO_ENABLED=0 go build -o ./bin/autoEqMac | ||
|
||
.PHONY: coverage | ||
coverage: | ||
gopherbadger -md="README.md" -png=false | ||
|
||
.PHONY: lint | ||
lint: | ||
golangci-lint run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package autoeq | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestToFixedBandEQs(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
data []byte | ||
want FixedBandEQs | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "Happy path", | ||
data: []byte("Filter 1: ON PK Fc 31 Hz Gain 5.8 dB Q 1.41\n"), | ||
want: FixedBandEQs{{Frequency: 31, Gain: 5.8, Q: 1.41}}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Sad path - Freq not int", | ||
data: []byte("Filter 1: ON PK Fc AB Hz Gain 5.8 dB Q 1.41"), | ||
want: nil, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "Sad path - Gain not float", | ||
data: []byte("Filter 1: ON PK Fc 31 Hz Gain AB dB Q 1.41"), | ||
want: nil, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "Sad path - Q not float", | ||
data: []byte("Filter 1: ON PK Fc 31 Hz Gain 5.8 dB Q AB"), | ||
want: nil, | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := ToFixedBandEQs(tt.data) | ||
require.Equal(t, tt.wantErr, err != nil) | ||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package autoeq | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
autoEQResults = `https://raw.githubusercontent.com/jaakkopasanen/AutoEq/master/results` | ||
fixedBandSuffix = `%20FixedBandEQ.txt` | ||
) | ||
|
||
func TestMetadataParser_ParseMetadata(t *testing.T) { | ||
t.Parallel() | ||
type fields struct { | ||
LinkPrefix string | ||
FixedBandEQSuffix string | ||
} | ||
type args struct { | ||
data []byte | ||
} | ||
var tests = []struct { | ||
name string | ||
fields fields | ||
args args | ||
want []EQMetadata | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "Happy path", | ||
fields: fields{ | ||
LinkPrefix: autoEQResults, | ||
FixedBandEQSuffix: fixedBandSuffix, | ||
}, | ||
args: args{ | ||
data: mustReadFixture(t, "testdata/autoeq_index_top.txt"), | ||
}, | ||
want: []EQMetadata{ | ||
{ | ||
ID: "0", | ||
Name: "1Custom SA02", | ||
Author: "Crinacle", | ||
Link: autoEQResults + "/crinacle/harman_in-ear_2019v2/1Custom%20SA02/1Custom%20SA02" + fixedBandSuffix, | ||
Global: 0, | ||
}, | ||
}, | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
p := MetadataParser{ | ||
LinkPrefix: tt.fields.LinkPrefix, | ||
FixedBandEQSuffix: tt.fields.FixedBandEQSuffix, | ||
} | ||
got, err := p.ParseMetadata(tt.args.data) | ||
require.Equal(t, tt.wantErr, err != nil) | ||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} | ||
|
||
func mustReadFixture(t *testing.T, filename string) []byte { | ||
data, err := ioutil.ReadFile(filename) | ||
if err != nil { | ||
_, _ = fmt.Fprintf(os.Stderr, "%q\n", err) | ||
t.Fail() | ||
} | ||
return data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Index | ||
This is a list of all equalization profiles. Target is in parentheses if there are results with multiple targets | ||
from the same source. | ||
|
||
- [1Custom SA02](./crinacle/harman_in-ear_2019v2/1Custom%20SA02) by Crinacle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters