github.com/benz9527/toy-box/algo@v0.0.0-20240221120937-66c0c6bd5abd/sort/bubble_test.go (about)

     1  package sort
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestGenerateRandomArr(t *testing.T) {
     9  	fmt.Println(GenerateRandomArr(10, 100))
    10  }
    11  
    12  func TestCopyArr(t *testing.T) {
    13  	origArr := GenerateRandomArr(10, 100)
    14  	fmt.Printf("orig arr addr: %p\n", &origArr)
    15  
    16  	arr1 := CopyArr(origArr, len(origArr))
    17  	fmt.Printf("arr1 addr: %p\n", &arr1)
    18  
    19  	arr2 := CopyArr(origArr, len(origArr))
    20  	fmt.Printf("arr2 addr: %p\n", &arr2)
    21  
    22  }
    23  
    24  func TestBubbleSort(t *testing.T) {
    25  	arr := []int{6, 4, 8, 9, 0, 1, 3, 5, 2, 7}
    26  	BubbleSort(arr)
    27  	fmt.Println(arr)
    28  }
    29  
    30  func TestBubbleSortBenchmark(t *testing.T) {
    31  	DataComparator(BubbleSort, 1000, 20, 100, true)
    32  	DataComparator(BubbleSortAcc, 1000, 20, 100, true)
    33  }
    34  
    35  func TestBubbleSortAcc(t *testing.T) {
    36  	arr := []int{6, 4, 8, 9, 0, 1, 3, 5, 2, 7}
    37  	BubbleSortAcc(arr)
    38  	fmt.Println(arr)
    39  }