File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ func TestSortSlice(t *testing.T) {
1616 sort .Strings (sorted )
1717
1818 a := data [0 :]
19+ SortSlice (a , func (i int ) string { return a [i ] })
1920 if ! reflect .DeepEqual (a , sorted ) {
2021 t .Errorf (" got %v" , a )
2122 t .Errorf ("want %v" , sorted )
@@ -53,6 +54,31 @@ func TestSortSlice1k(t *testing.T) {
5354 }
5455}
5556
57+ func TestSortSliceBible (t * testing.T ) {
58+ var data []string
59+ f , err := os .Open ("res/bible.txt" )
60+ if err != nil {
61+ log .Fatal (err )
62+ }
63+ for sc := bufio .NewScanner (f ); sc .Scan (); {
64+ data = append (data , sc .Text ())
65+ }
66+
67+ sorted := make ([]string , len (data ))
68+ copy (sorted , data )
69+ sort .Strings (sorted )
70+
71+ SortSlice (data , func (i int ) string { return data [i ] })
72+ if ! reflect .DeepEqual (data , sorted ) {
73+ for i , s := range data {
74+ if s != sorted [i ] {
75+ t .Errorf ("%v got: %v" , i , s )
76+ t .Errorf ("%v want: %v\n \n " , i , sorted [i ])
77+ }
78+ }
79+ }
80+ }
81+
5682func BenchmarkRadixSortSliceBible (b * testing.B ) {
5783 b .StopTimer ()
5884 var data []string
You can’t perform that action at this time.
0 commit comments