ids: Add test for SortIDs

This commit is contained in:
Alex Willmer 2020-04-01 18:58:12 +01:00
parent a62eb9b833
commit 61b01c9273
1 changed files with 18 additions and 0 deletions

View File

@ -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")
}
}