package main import "testing" func Sort(i *[]int) { A := *i n := len(A) for i := 0; i < n; i++ { min := i for j := i + 1; j < n; j++ { if A[j] < A[min] { min = j } } A[i], A[min] = A[min], A[i] } } func TestSelectionSort(t *testing.T) { t.Run("Worst case", func(t *testing.T) { items := []int{10, 9, 8, 7, 6, 5, 4, 3, 2, 1} Sort(&items) for i := 0; i < len(items); i++ { expected := i + 1 if items[i] != expected { t.Errorf("Expected '%d', got '%d'", expected, items[i]) } } }) }