Skip to content

Commit

Permalink
Simplify hash.TestUnmarshal
Browse files Browse the repository at this point in the history
  • Loading branch information
krhubert committed Sep 16, 2019
1 parent fc166cf commit e5996b2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions hash/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,10 @@ func TestUnmarshalJSON(t *testing.T) {
}

func TestUnmarshal(t *testing.T) {
var hashes []Hash
hashSameAddr := Int(1)
for i := 0; i < 10; i++ {
copy(hashSameAddr, Int(i))
var hash = Hash{}
assert.NoError(t, hash.Unmarshal(hashSameAddr))
assert.Equal(t, Int(i), hash)
hashes = append(hashes, hash)
}
for i := 0; i < 10; i++ {
assert.Equal(t, Int(i), hashes[i])
}
var hash Hash
data := []byte(Int(1))
hash.Unmarshal(data)
// check if unmarshal copy the data
// test if two slises do not share the same address
assert.True(t, &hash[cap(hash)-1] != &data[cap(data)-1])
}

0 comments on commit e5996b2

Please sign in to comment.