You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

27 lines
418 B

package shuffle
import (
"strings"
"testing"
)
type List []string
func (l List) Len() int {
return len(l)
}
func (l List) Swap(i, j int) {
l[i], l[j] = l[j], l[i]
}
func TestShuffle(t *testing.T) {
l := List{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
old := strings.Join(l, "")
Shuffle(l)
new := strings.Join(l, "")
if old == new {
t.Errorf("shuffle error, %s == %s", old, new)
}
t.Log(new)
}