Created
January 15, 2017 08:37
-
-
Save cipepser/6a54ac589aa44ef606c7833703810dda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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