Testing Bubble Sort Implementations in hello-algo
This test suite validates the implementation of bubble sort algorithms in Go, examining both standard and optimized flag-based variations. The tests verify correct sorting behavior and demonstrate different bubble sort implementations with practical examples.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
krahets/hello-algo
zh-hant/codes/go/chapter_sorting/bubble_sort_test.go
// File: bubble_sort_test.go
// Created Time: 2022-12-06
// Author: Slone123c ([email protected])
package chapter_sorting
import (
"fmt"
"testing"
)
func TestBubbleSort(t *testing.T) {
nums := []int{4, 1, 3, 1, 5, 2}
bubbleSort(nums)
fmt.Println("泡沫排序完成後 nums = ", nums)
nums1 := []int{4, 1, 3, 1, 5, 2}
bubbleSortWithFlag(nums1)
fmt.Println("泡沫排序完成後 nums1 = ", nums1)
}