algorithms/sorting/sort_test.go

76 lines
1.3 KiB
Go
Raw Normal View History

2021-12-06 08:01:25 +02:00
package sorting
import (
"testing"
)
2021-12-16 17:46:10 +02:00
func TestSelectionSlice(t *testing.T) {
CheckSliceSorter(Selection[int])
2021-12-06 08:01:25 +02:00
}
2021-12-14 12:35:28 +02:00
func BenchmarkSelection(b *testing.B) {
for i := 0; i < b.N; i++ {
2021-12-16 17:46:10 +02:00
BenchmarkSort(10000, Selection[int])
2021-12-14 12:35:28 +02:00
}
}
func TestInsertion(t *testing.T) {
2021-12-16 17:46:10 +02:00
CheckSliceSorter(Insertion[int])
2021-12-14 12:35:28 +02:00
}
func BenchmarkInsertion(b *testing.B) {
for i := 0; i < b.N; i++ {
2021-12-16 17:46:10 +02:00
BenchmarkSort(10000, Insertion[int])
2021-12-14 12:35:28 +02:00
}
}
2021-12-14 14:01:44 +02:00
func TestShell(t *testing.T) {
2021-12-16 17:46:10 +02:00
CheckSliceSorter(Shell[int])
2021-12-14 14:01:44 +02:00
}
func BenchmarkShell(b *testing.B) {
for i := 0; i < b.N; i++ {
2021-12-16 17:46:10 +02:00
BenchmarkSort(10000, Shell[int])
2021-12-14 14:01:44 +02:00
}
}
2021-12-16 19:37:48 +02:00
func TestMerge(t *testing.T) {
CheckSliceSorter(Merge[int])
}
func BenchmarkMerge(b *testing.B) {
for i := 0; i < b.N; i++ {
BenchmarkSort(10000, Merge[int])
}
}
2021-12-16 22:23:18 +02:00
func TestParallelMerge(t *testing.T) {
CheckSliceSorter(ParallelMerge[int])
}
func BenchmarkParallelMerge(b *testing.B) {
for i := 0; i < b.N; i++ {
BenchmarkSort(10000, ParallelMerge[int])
}
}
func TestBottomUpMerge(t *testing.T) {
CheckSliceSorter(BottomUpMerge[int])
}
func BenchmarkBottomUpMerge(b *testing.B) {
for i := 0; i < b.N; i++ {
BenchmarkSort(10000, BottomUpMerge[int])
}
}
2021-12-29 23:59:09 +02:00
func TestQuick(t *testing.T) {
CheckSliceSorter(Quick[int])
}
func BenchmarkQuick(b *testing.B) {
for i := 0; i < b.N; i++ {
BenchmarkSort(10000, Quick[int])
}
}