mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-17 11:07:18 +02:00
deps: update hashstructure v2 (#1632)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
parent
3f7777f7e0
commit
652e8bb3d3
7 changed files with 51 additions and 43 deletions
|
@ -1,17 +1,22 @@
|
|||
// Package hashutil provides NON-CRYPTOGRAPHIC utility functions for hashing
|
||||
package hashutil
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestHash(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
v interface{}
|
||||
want uint64
|
||||
name string
|
||||
v interface{}
|
||||
want uint64
|
||||
wantErr bool
|
||||
}{
|
||||
{"string", "string", 6134271061086542852},
|
||||
{"num", 7, 609900476111905877},
|
||||
{"string", "string", 6134271061086542852, false},
|
||||
{"num", 7, 609900476111905877, false},
|
||||
{"compound struct", struct {
|
||||
NESCarts []string
|
||||
numberOfCarts int
|
||||
|
@ -19,17 +24,26 @@ func TestHash(t *testing.T) {
|
|||
[]string{"Battletoads", "Mega Man 1", "Clash at Demonhead"},
|
||||
12,
|
||||
},
|
||||
9061978360207659575},
|
||||
1349584765528830812, false},
|
||||
{"compound struct with embedded func (errors!)", struct {
|
||||
AnswerToEverythingFn func() int
|
||||
}{
|
||||
func() int { return 42 },
|
||||
},
|
||||
0},
|
||||
0, true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := Hash(tt.v); got != tt.want {
|
||||
if got := MustHash(tt.v); got != tt.want {
|
||||
t.Errorf("MustHash() = %v, want %v", got, tt.want)
|
||||
}
|
||||
got, err := Hash(tt.v)
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
if got != tt.want {
|
||||
t.Errorf("Hash() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue