@@ -13,34 +13,34 @@ func TestKeyBetween(t *testing.T) {
1313 exp * string
1414 err error
1515 }{
16- {nil , nil , strPtr ("a " ), nil },
17- {nil , strPtr ("a " ), strPtr ("Z~" ), nil },
18- {nil , strPtr ("Z~" ), strPtr ("Z}" ), nil },
19- {strPtr ("a " ), nil , strPtr ("a!" ), nil },
20- {strPtr ("a!" ), nil , strPtr ("a\" " ), nil },
21- {strPtr ("a0" ), strPtr ("a1" ), strPtr ("a0P" ), nil },
22- {strPtr ("a1" ), strPtr ("a2" ), strPtr ("a1P" ), nil },
23- {strPtr ("a0V" ), strPtr ("a1" ), strPtr ("a0k" ), nil },
24- {strPtr ("Z~" ), strPtr ("a " ), strPtr ("Z~P" ), nil },
25- {strPtr ("Z~" ), strPtr ("a!" ), strPtr ("a " ), nil },
26- {nil , strPtr ("Y " ), strPtr ("X~~~" ), nil },
27- {strPtr ("b~~" ), nil , strPtr ("c " ), nil },
28- {strPtr ("a0" ), strPtr ("a0V" ), strPtr ("a0;" ), nil },
29- {strPtr ("a0" ), strPtr ("a0G" ), strPtr ("a04" ), nil },
30- {strPtr ("b125" ), strPtr ("b129" ), strPtr ("b127" ), nil },
31- {strPtr ("a0" ), strPtr ("a1V" ), strPtr ("a1" ), nil },
32- {strPtr ("Z~" ), strPtr ("a 1" ), strPtr ("a " ), nil },
33- {nil , strPtr ("a0V" ), strPtr ("a0" ), nil },
34- {nil , strPtr ("b999" ), strPtr ("b99" ), nil },
35- {nil , strPtr ("A " ), nil , errors .New ("Key is too small" )},
16+ {nil , nil , new ("a "), nil },
17+ {nil , new ("a "), new ("Z ~ "), nil },
18+ {nil , new ("Z ~ "), new ("Z }"), nil },
19+ {new ("a "), nil , new ("a ! "), nil },
20+ {new ("a ! "), nil, new (" a \" "), nil },
21+ {new ("a0 "), new ("a1 "), new ("a0P "), nil },
22+ {new ("a1 "), new ("a2 "), new ("a1P "), nil },
23+ {new ("a0V "), new ("a1 "), new ("a0k "), nil },
24+ {new ("Z ~ "), new ("a "), new ("Z ~ P "), nil },
25+ {new ("Z ~ "), new ("a ! "), new (" a "), nil },
26+ {nil , new ("Y "), new ("X ~ ~ ~ "), nil },
27+ {new ("b ~ ~ "), nil , new ("c "), nil },
28+ {new ("a0 "), new ("a0V "), new ("a0 ;"), nil },
29+ {new ("a0 "), new ("a0G "), new ("a04 "), nil },
30+ {new ("b125 "), new ("b129 "), new ("b127 "), nil },
31+ {new ("a0 "), new ("a1V "), new ("a1 "), nil },
32+ {new ("Z ~ "), new ("a 1 "), new ("a "), nil },
33+ {nil , new ("a0V "), new ("a0 "), nil },
34+ {nil , new ("b999 "), new ("b99 "), nil },
35+ {nil , new ("A "), nil , errors .New ("Key is too small" )},
3636 // @TODO - fix the implementation to handle this case
3737 //{nil, strPtr("A !"), strPtr("A P"), nil},
38- {strPtr ("zzzzzzzzzzzzzzzzzzzzzzzzzzy" ), nil , strPtr ("zzzzzzzzzzzzzzzzzzzzzzzzzzz" ), nil },
39- {strPtr ("z~~~~~~~~~~~~~~~~~~~~~~~~~~" ), nil , strPtr ("z~~~~~~~~~~~~~~~~~~~~~~~~~~P" ), nil },
40- {strPtr ("a0 " ), nil , nil , errors .New ("Fractional part should not end with ' ' (space)" )},
41- {strPtr ("a0 " ), strPtr ("a1" ), nil , errors .New ("Fractional part should not end with ' ' (space)" )},
42- {strPtr ("0" ), strPtr ("1" ), nil , errors .New ("head is out of range" )},
43- {strPtr ("a1" ), strPtr ("a0" ), nil , errors .New ("key_between - a must be before b" )},
38+ {new ("zzzzzzzzzzzzzzzzzzzzzzzzzzy "), nil , new ("zzzzzzzzzzzzzzzzzzzzzzzzzzz "), nil },
39+ {new ("z ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "), nil , new ("z ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ P "), nil },
40+ {new ("a0 "), nil , nil , errors .New ("Fractional part should not end with ' ' (space)" )},
41+ {new ("a0 "), new ("a1 "), nil , errors .New ("Fractional part should not end with ' ' (space)" )},
42+ {new ("0 "), new ("1 "), nil , errors .New ("head is out of range" )},
43+ {new ("a1 "), new ("a0 "), nil , errors .New ("key_between - a must be before b" )},
4444 }
4545
4646 for _ , tt := range tests {
@@ -66,7 +66,7 @@ func TestGenerateInsertOrder(t *testing.T) {
6666
6767 var prev * string
6868 var indices []string
69- for i := 0 ; i < 5 ; i ++ {
69+ for range 5 {
7070 prev , _ = KeyBetween (prev , nil )
7171 indices = append (indices , * prev )
7272 }
@@ -90,9 +90,9 @@ func TestGenerateInsertOrder(t *testing.T) {
9090
9191 var fractIndex * string
9292 if toIndex == 0 {
93- fractIndex , _ = KeyBetween (nil , strPtr (indices [toIndex ]))
93+ fractIndex , _ = KeyBetween (nil , new (indices [toIndex ]))
9494 } else {
95- fractIndex , _ = KeyBetween (strPtr (indices [toIndex - 1 ]), strPtr (indices [toIndex ]))
95+ fractIndex , _ = KeyBetween (new (indices [toIndex - 1 ]), new (indices [toIndex ]))
9696 }
9797
9898 indices = append (indices [:toIndex ], append ([]string {* fractIndex }, indices [toIndex :]... )... )
@@ -119,7 +119,3 @@ func vecCompare(va, vb []string) bool {
119119 }
120120 return true
121121}
122-
123- func strPtr (s string ) * string {
124- return & s
125- }
0 commit comments