Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. package sorting
  2.  
  3. import (
  4. "testing"
  5. "utils"
  6. )
  7.  
  8. func TestQuickSort (t *testing.T) {
  9. var (
  10. actual = []int{23, 3, 45, 1, 4, 56, 2}
  11. expected = []int{1, 2, 3, 4, 23, 45, 56}
  12. result bool
  13. )
  14.  
  15. QuickSort(actual, 0, len(actual) - 1)
  16.  
  17. result = utils.AreEqualArrays(actual, expected)
  18.  
  19. if !result {
  20. t.Errorf("Expected result: %q; Actual result: %q",
  21. utils.ToString(expected),
  22. utils.ToString(actual))
  23. }
  24. }
  25.  
  26. func BenchmarkQuickSort (b *testing.B) {
  27. arr := []int{23, 3, 45, 1, 4, 56, 2,-30, 43, 1, 5, 21}
  28.  
  29. for n := 0; n < b.N; n++ {
  30. QuickSort(arr, 0 , len(arr) - 1)
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement