2015-10-28 11:20:59 -07:00
|
|
|
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
|
|
|
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
|
|
|
|
|
|
package treesort_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/rand"
|
|
|
|
"sort"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gopl.io/ch4/treesort"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSort(t *testing.T) {
|
|
|
|
data := make([]int, 50)
|
|
|
|
for i := range data {
|
|
|
|
data[i] = rand.Int() % 50
|
|
|
|
}
|
|
|
|
treesort.Sort(data)
|
|
|
|
if !sort.IntsAreSorted(data) {
|
2015-12-07 09:23:42 -08:00
|
|
|
t.Errorf("not sorted: %v", data)
|
2015-10-28 11:20:59 -07:00
|
|
|
}
|
|
|
|
}
|