46 lines
852 B
Go
46 lines
852 B
Go
package guess
|
|
|
|
import (
|
|
"git.gammaspectra.live/S.O.N.G/Kirika/audio"
|
|
"os"
|
|
"path"
|
|
"testing"
|
|
)
|
|
|
|
func DoTest(ext string, locations []string, t *testing.T) {
|
|
for _, location := range locations {
|
|
entries, err := os.ReadDir(location)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
for _, f := range entries {
|
|
if path.Ext(f.Name()) == ext {
|
|
fullPath := path.Join(location, f.Name())
|
|
t.Run(f.Name(), func(t *testing.T) {
|
|
t.Parallel()
|
|
fp, err := os.Open(fullPath)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
defer fp.Close()
|
|
decoders, err := GetDecoders(fp, fullPath)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
source, err := Open(fp, decoders)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
//Decode
|
|
audio.NewNullSink().Process(source)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|