ref: d1b89f5c7cb3d1031d74014b4b2150a434bf557e
parent: 17f851780c79d0223b247dadcd8ddec0c74c4500
author: Cameron Moore <[email protected]>
date: Mon Dec 26 14:42:43 EST 2016
hugolib: Use reflect.DeepEqual in tests
--- a/hugolib/page_taxonomy_test.go
+++ b/hugolib/page_taxonomy_test.go
@@ -14,6 +14,7 @@
package hugolib
import (
+ "reflect"
"strings"
"testing"
)
@@ -73,7 +74,7 @@
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 {
@@ -90,18 +91,4 @@
t.Fatalf("Expected: d, got: %s", singleparam)
}
}
-}
-
-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
}
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -15,6 +15,7 @@
import (
"path/filepath"
+ "reflect"
"testing"
"github.com/spf13/viper"
@@ -43,7 +44,7 @@
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)
}
}