Skip to content

Commit

Permalink
Merge pull request #6 from josharian/josh/fix-tests
Browse files Browse the repository at this point in the history
make golden tests more robust
  • Loading branch information
dh1tw authored Jan 28, 2024
2 parents e90cbce + 42e999f commit 85e1e8e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion gosamplerate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ func TestSimple(t *testing.T) {
t.Fatal(err)
}

if !reflect.DeepEqual(output, expectedOutput) {
if !closeEnough(output, expectedOutput) {
t.Log("input", input)
t.Log("output", output)
t.Log("expectedOutput", expectedOutput)
t.Fatal("unexpected output")
}
}
Expand Down Expand Up @@ -295,3 +296,15 @@ func TestErrors(t *testing.T) {
t.Fatal(err)
}
}

func closeEnough(a, b []float32) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v-b[i] > 0.00001 {
return false
}
}
return true
}

0 comments on commit 85e1e8e

Please sign in to comment.