Skip to content

Instantly share code, notes, and snippets.

@cipepser
Created January 15, 2017 08:37
Show Gist options
  • Save cipepser/6a54ac589aa44ef606c7833703810dda to your computer and use it in GitHub Desktop.
Save cipepser/6a54ac589aa44ef606c7833703810dda to your computer and use it in GitHub Desktop.
package MySort
import (
"testing"
"reflect"
"sort"
)
// テストパターン
var SortTests = [][]int {
{2, 1, 3, 5, 4},
{1, 2, 3, 4, 5},
{1, 3, 4, 5, 2, 1},
{1, 0, 2},
{1, 1, 1, 1, 1, 1, 1, 1},
}
func TestBubbleSort(t *testing.T) {
for _, actual := range SortTests {
expected := make([]int, len(actual))
copy(expected, actual)
sort.Ints(expected)
BubbleSort(actual)
if !reflect.DeepEqual(actual, expected) {
t.Errorf("\nexpected: %v\nactual: %v", expected, actual)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment