@@ -281,29 +281,29 @@ func TestMapEncodeDecode(t *testing.T) {
281
281
require .Equal (t , expect , actual )
282
282
}
283
283
284
- func TestIndex (t * testing.T ) {
285
- require .Equal (t , - 1 , Index ("a" , []string {"x" , "y" , "z" }))
286
- require .Equal (t , 1 , Index ("y" , []string {"x" , "y" , "z" }))
287
- require .Equal (t , - 1 , Index (25 , []string {"x" , "y" , "z" }))
288
- require .Equal (t , - 1 , Index (25 , 26 ))
289
- require .Equal (t , 1 , Index ("y" , []string {"x" , "y" , "z" }))
290
- require .Equal (t , 1 , Index ("y" , []interface {}{"x" , "y" , "z" }))
291
- require .Equal (t , 1 , Index (1 , []interface {}{0 , 1 , 2 }))
292
- require .Equal (t , 1 , Index ("1" , []interface {}{0 , 1 , 2 }))
293
- require .Equal (t , 1 , Index (1 , []interface {}{0 , "1" , 2 }))
294
- require .Equal (t , - 1 , Index ("1" , []interface {}{0 , 1 , 2 }, true )) // strict case type must match
295
- require .Equal (t , 1 , Index ("1" , []interface {}{0 , "1" , 2 }, true )) // strict case type must match
296
- require .Equal (t , - 1 , Index (1 , []interface {}{0 , "1" , 2 }, true )) // strict case type must match
284
+ func TestIndexOf (t * testing.T ) {
285
+ require .Equal (t , - 1 , IndexOf ("a" , []string {"x" , "y" , "z" }))
286
+ require .Equal (t , 1 , IndexOf ("y" , []string {"x" , "y" , "z" }))
287
+ require .Equal (t , - 1 , IndexOf (25 , []string {"x" , "y" , "z" }))
288
+ require .Equal (t , - 1 , IndexOf (25 , 26 ))
289
+ require .Equal (t , 1 , IndexOf ("y" , []string {"x" , "y" , "z" }))
290
+ require .Equal (t , 1 , IndexOf ("y" , []interface {}{"x" , "y" , "z" }))
291
+ require .Equal (t , 1 , IndexOf (1 , []interface {}{0 , 1 , 2 }))
292
+ require .Equal (t , 1 , IndexOf ("1" , []interface {}{0 , 1 , 2 }))
293
+ require .Equal (t , 1 , IndexOf (1 , []interface {}{0 , "1" , 2 }))
294
+ require .Equal (t , - 1 , IndexOf ("1" , []interface {}{0 , 1 , 2 }, true )) // strict case type must match
295
+ require .Equal (t , 1 , IndexOf ("1" , []interface {}{0 , "1" , 2 }, true )) // strict case type must match
296
+ require .Equal (t , - 1 , IndexOf (1 , []interface {}{0 , "1" , 2 }, true )) // strict case type must match
297
297
298
298
v := "1"
299
- require .Equal (t , 1 , Index (& v , []interface {}{0 , "1" , 2 }))
300
- require .Equal (t , 1 , Index (& v , []interface {}{0 , & v , 2 }, true ))
301
- require .Equal (t , 1 , Index (& v , []interface {}{0 , & v , 2 }))
299
+ require .Equal (t , 1 , IndexOf (& v , []interface {}{0 , "1" , 2 }))
300
+ require .Equal (t , 1 , IndexOf (& v , []interface {}{0 , & v , 2 }, true ))
301
+ require .Equal (t , 1 , IndexOf (& v , []interface {}{0 , & v , 2 }))
302
302
303
303
a := "0"
304
304
c := "2"
305
- require .Equal (t , 1 , Index ("1" , []* string {& a , & v , & c }))
305
+ require .Equal (t , 1 , IndexOf ("1" , []* string {& a , & v , & c }))
306
306
307
307
// This doesn't work because the type information is gone and we have just an address
308
- require .Equal (t , - 1 , Index ("1" , []interface {}{0 , & v , 2 }))
308
+ require .Equal (t , - 1 , IndexOf ("1" , []interface {}{0 , & v , 2 }))
309
309
}
0 commit comments