mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
hugolib: Use reflect.DeepEqual in tests
This commit is contained in:
parent
17f851780c
commit
d1b89f5c7c
2 changed files with 4 additions and 16 deletions
|
@ -14,6 +14,7 @@
|
|||
package hugolib
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
@ -73,7 +74,7 @@ func TestParseTaxonomies(t *testing.T) {
|
|||
|
||||
if params, ok := param.([]string); ok {
|
||||
expected := []string{"a", "b", "c"}
|
||||
if !compareStringSlice(params, expected) {
|
||||
if !reflect.DeepEqual(params, expected) {
|
||||
t.Errorf("Expected %s: got: %s", expected, params)
|
||||
}
|
||||
} else if params, ok := param.(string); ok {
|
||||
|
@ -91,17 +92,3 @@ func TestParseTaxonomies(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func compareStringSlice(a, b []string) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, v := range a {
|
||||
if b[i] != v {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ package hugolib
|
|||
|
||||
import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
@ -43,7 +44,7 @@ func TestByCountOrderOfTaxonomies(t *testing.T) {
|
|||
st = append(st, t.Name)
|
||||
}
|
||||
|
||||
if !compareStringSlice(st, []string{"a", "b", "c"}) {
|
||||
if !reflect.DeepEqual(st, []string{"a", "b", "c"}) {
|
||||
t.Fatalf("ordered taxonomies do not match [a, b, c]. Got: %s", st)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue