This repository has been archived on 2019-12-11. You can view files and clone it, but cannot push or open issues/pull-requests.
2019-12-01 11:12:48 +00:00
|
|
|
package flac
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-12-01 21:12:58 +00:00
|
|
|
"time"
|
2019-12-01 11:12:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetMetadata(t *testing.T) {
|
|
|
|
md, err := GetMetadata("test_files/audio.flac")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2019-12-01 11:15:48 +00:00
|
|
|
expected := Metadata{
|
|
|
|
SampleRate: 48000,
|
|
|
|
BPS: 16,
|
|
|
|
Channels: 2,
|
|
|
|
NumSamples: 174564,
|
2019-12-01 21:12:58 +00:00
|
|
|
MD5Sum: "c4f2c7de2f0f952354bfec3a0809c00e",
|
2019-12-01 11:15:48 +00:00
|
|
|
}
|
|
|
|
if md != expected {
|
|
|
|
t.Fatalf("%v != %v", md, expected)
|
|
|
|
}
|
2019-12-01 11:12:48 +00:00
|
|
|
}
|
2019-12-01 21:12:58 +00:00
|
|
|
|
|
|
|
func TestLoad(t *testing.T) {
|
|
|
|
l, r, err := Load("test_files/audio.flac")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := Save("test_files/out.flac", l, r); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apparently necessary.
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
|
|
|
|
md1, err := GetMetadata("test_files/audio.flac")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
md2, err := GetMetadata("test_files/out.flac")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if md1 != md2 {
|
|
|
|
t.Fatalf("%v != %v", md2, md1)
|
|
|
|
}
|
|
|
|
}
|