diff options
author | Cyril David <cyx@cyx.is> | 2015-05-25 10:22:56 +0300 |
---|---|---|
committer | Cyril David <cyx@cyx.is> | 2015-05-25 10:22:56 +0300 |
commit | 6dca1ffb59c049519465f7d59c811cd190c124ec (patch) | |
tree | c00858fd81100c6e14cf62dd884f66695b687790 | |
parent | 8e98dd730fc43f1383f19615db6f2e702c9738e8 (diff) |
Use reflect.DeepEqual instead
Unless there's something I'm missing, probably better to
delegate this check to the reflect package.
-rw-r--r-- | securecookie_test.go | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/securecookie_test.go b/securecookie_test.go index 241ff10..83186de 100644 --- a/securecookie_test.go +++ b/securecookie_test.go @@ -9,8 +9,8 @@ import ( "crypto/hmac" "crypto/sha256" "encoding/base64" - "errors" "fmt" + "reflect" "strings" "testing" ) @@ -24,18 +24,6 @@ var testStrings = []string{"foo", "bar", "baz"} func TestSecureCookie(t *testing.T) { // TODO test too old / too new timestamps - compareMaps := func(m1, m2 map[string]interface{}) error { - if len(m1) != len(m2) { - return errors.New("different maps") - } - for k, v := range m1 { - if m2[k] != v { - return fmt.Errorf("Different value for key %v: expected %v, got %v", k, m2[k], v) - } - } - return nil - } - s1 := New([]byte("12345"), []byte("1234567890123456")) s2 := New([]byte("54321"), []byte("6543210987654321")) value := map[string]interface{}{ @@ -56,7 +44,7 @@ func TestSecureCookie(t *testing.T) { if err2 != nil { t.Fatalf("%v: %v", err2, encoded) } - if err := compareMaps(dst, value); err != nil { + if !reflect.DeepEqual(dst, value) { t.Fatalf("Expected %v, got %v.", value, dst) } dst2 := make(map[string]interface{}) |