Skip to content

Commit

Permalink
#67 Reorder test
Browse files Browse the repository at this point in the history
  • Loading branch information
meian committed Jan 30, 2022
1 parent 1a2c424 commit 9145ef3
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ func TestSortAsc(t *testing.T) {
})
}

func ExampleSortAsc() {
itb := gcf.FromSlice([]int{3, 6, 7, 1, 5, 6, 2, 4, 5})
itb = gcf.SortAsc(itb)
fmt.Println(gcf.ToSlice(itb))
// Output:
// [1 2 3 4 5 5 6 6 7]
}

func TestSortDesc(t *testing.T) {
type args struct {
itb gcf.Iterable[int]
Expand Down Expand Up @@ -160,6 +168,14 @@ func TestSortDesc(t *testing.T) {
})
}

func ExampleSortDesc() {
itb := gcf.FromSlice([]int{3, 6, 7, 1, 5, 6, 2, 4, 5})
itb = gcf.SortDesc(itb)
fmt.Println(gcf.ToSlice(itb))
// Output:
// [7 6 6 5 5 4 3 2 1]
}

func TestSortBy(t *testing.T) {
type data struct{ v int }
type args struct {
Expand Down Expand Up @@ -253,7 +269,17 @@ func TestSortBy(t *testing.T) {
})
}

func FuzzSortAsc(f *testing.F) {
func ExampleSortBy() {
type data struct{ v int }
itbi := gcf.FromSlice([]int{3, 6, 7, 1, 5, 6, 2, 4, 5})
itb := gcf.Map(itbi, func(v int) data { return data{v} })
itb = gcf.SortBy(itb, func(x, y data) bool { return x.v < y.v })
fmt.Println(gcf.ToSlice(itb))
// Output:
// [{1} {2} {3} {4} {5} {5} {6} {6} {7}]
}

func FuzzSort(f *testing.F) {
type data struct{ v byte }
tests := [][]byte{
{1, 2, 3},
Expand Down Expand Up @@ -291,29 +317,3 @@ func FuzzSortAsc(f *testing.F) {
}
})
}

func ExampleSortAsc() {
itb := gcf.FromSlice([]int{3, 6, 7, 1, 5, 6, 2, 4, 5})
itb = gcf.SortAsc(itb)
fmt.Println(gcf.ToSlice(itb))
// Output:
// [1 2 3 4 5 5 6 6 7]
}

func ExampleSortDesc() {
itb := gcf.FromSlice([]int{3, 6, 7, 1, 5, 6, 2, 4, 5})
itb = gcf.SortDesc(itb)
fmt.Println(gcf.ToSlice(itb))
// Output:
// [7 6 6 5 5 4 3 2 1]
}

func ExampleSortBy() {
type data struct{ v int }
itbi := gcf.FromSlice([]int{3, 6, 7, 1, 5, 6, 2, 4, 5})
itb := gcf.Map(itbi, func(v int) data { return data{v} })
itb = gcf.SortBy(itb, func(x, y data) bool { return x.v < y.v })
fmt.Println(gcf.ToSlice(itb))
// Output:
// [{1} {2} {3} {4} {5} {5} {6} {6} {7}]
}

0 comments on commit 9145ef3

Please sign in to comment.