mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-29 19:39:52 -05:00
a67bb9bf7b
Define the hash.Hash type to be a 20-byte array, rather than embed one. Hash API Changes: `hash.FromSlice` -> `hash.New`, `hash.FromData` -> `hash.Of`
36 lines
643 B
Go
36 lines
643 B
Go
// Copyright 2016 Attic Labs, Inc. All rights reserved.
|
|
// Licensed under the Apache License, version 2.0:
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
package hash
|
|
|
|
import (
|
|
"sort"
|
|
"testing"
|
|
|
|
"github.com/attic-labs/testify/assert"
|
|
)
|
|
|
|
func TestHashSliceSort(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
rs := HashSlice{}
|
|
for i := 1; i <= 3; i++ {
|
|
for j := 1; j <= 3; j++ {
|
|
h := Hash{}
|
|
for k := 1; k <= j; k++ {
|
|
h[k-1] = byte(i)
|
|
}
|
|
rs = append(rs, h)
|
|
}
|
|
}
|
|
|
|
rs2 := HashSlice(make([]Hash, len(rs)))
|
|
copy(rs2, rs)
|
|
sort.Sort(sort.Reverse(rs2))
|
|
assert.False(rs.Equals(rs2))
|
|
|
|
sort.Sort(rs2)
|
|
assert.True(rs.Equals(rs2))
|
|
}
|