MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestMergeParallel

Function TestMergeParallel

sort/sorts_test.go:117–135  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

115}
116
117func TestMergeParallel(t *testing.T) {
118 testFramework(t, sort.ParallelMerge[int])
119
120 // Test parallel merge sort with a large slice
121 t.Run("ParallelMerge on large slice", func(t *testing.T) {
122 rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
123 size := 100000
124 randomLargeSlice := make([]int, size)
125 for i := range randomLargeSlice {
126 randomLargeSlice[i] = rnd.Intn(size)
127 }
128 sortedSlice := sort.ParallelMerge[int](randomLargeSlice)
129 for i := 0; i < len(sortedSlice)-1; i++ {
130 if sortedSlice[i] > sortedSlice[i+1] {
131 t.Errorf("ParallelMerge failed")
132 }
133 }
134 })
135}
136
137func TestHeap(t *testing.T) {
138 testFramework(t, sort.HeapSort[int])

Callers

nothing calls this directly

Calls 1

testFrameworkFunction · 0.85

Tested by

no test coverage detected