8 func instanceSlice(i *Instance) (sl []int) {
9 for e := i.First(); e != nil; e = e.Next() {
10 sl = append(sl, e.Piece())
15 func sameContents(a, b []int) bool {
17 panic("y u pass different length slices")
19 sort.IntSlice(a).Sort()
20 sort.IntSlice(b).Sort()
29 func checkOrder(t *testing.T, i *Instance, ppp ...[]int) {
31 t.Fatalf("have %v, expected %v", instanceSlice(i), ppp)
34 for _, pp := range ppp {
36 for len(pp_) != len(pp) {
37 pp_ = append(pp_, e.Piece())
40 if !sameContents(pp, pp_) {
49 func TestPieceOrdering(t *testing.T) {
53 checkOrder(t, i, []int{1, 0})
55 checkOrder(t, i, []int{0, 1})
57 checkOrder(t, i, []int{0})
60 checkOrder(t, i, []int{0})
66 checkOrder(t, i, []int{3, 1, 2})
67 // Move a piece that isn't the youngest in a key.
69 checkOrder(t, i, []int{1}, []int{3, 2})