Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sorting
- import (
- "testing"
- "utils"
- )
- func TestQuickSort (t *testing.T) {
- var (
- actual = []int{23, 3, 45, 1, 4, 56, 2}
- expected = []int{1, 2, 3, 4, 23, 45, 56}
- result bool
- )
- QuickSort(actual, 0, len(actual) - 1)
- result = utils.AreEqualArrays(actual, expected)
- if !result {
- t.Errorf("Expected result: %q; Actual result: %q",
- utils.ToString(expected),
- utils.ToString(actual))
- }
- }
- func BenchmarkQuickSort (b *testing.B) {
- arr := []int{23, 3, 45, 1, 4, 56, 2,-30, 43, 1, 5, 21}
- for n := 0; n < b.N; n++ {
- QuickSort(arr, 0 , len(arr) - 1)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement