mirror of https://github.com/poanetwork/gecko.git
ids: Add test for SortIDs
This commit is contained in:
parent
a62eb9b833
commit
61b01c9273
|
@ -5,6 +5,7 @@ package ids
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -174,3 +175,20 @@ func TestIDString(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortIDs(t *testing.T) {
|
||||
ids := []ID{
|
||||
NewID([32]byte{'e', 'v', 'a', ' ', 'l', 'a', 'b', 's'}),
|
||||
NewID([32]byte{'W', 'a', 'l', 'l', 'e', ' ', 'l', 'a', 'b', 's'}),
|
||||
NewID([32]byte{'a', 'v', 'a', ' ', 'l', 'a', 'b', 's'}),
|
||||
}
|
||||
SortIDs(ids)
|
||||
expected := []ID{
|
||||
NewID([32]byte{'W', 'a', 'l', 'l', 'e', ' ', 'l', 'a', 'b', 's'}),
|
||||
NewID([32]byte{'a', 'v', 'a', ' ', 'l', 'a', 'b', 's'}),
|
||||
NewID([32]byte{'e', 'v', 'a', ' ', 'l', 'a', 'b', 's'}),
|
||||
}
|
||||
if !reflect.DeepEqual(ids, expected) {
|
||||
t.Fatal("[]ID was not sorted lexographically")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue