@@ -332,40 +332,55 @@ func TestDecodePath(t *testing.T) {
332332
333333 var u16 uint16
334334
335- require .NoError (t , result .DecodePath (& u16 , "uint16" ))
336-
335+ found , err := result .DecodePath (& u16 , "uint16" )
336+ require .NoError (t , err )
337+ assert .True (t , found )
337338 assert .Equal (t , uint16 (100 ), u16 )
338339
339340 var u uint
340- require .NoError (t , result .DecodePath (& u , "array" , 0 ))
341+ found , err = result .DecodePath (& u , "array" , 0 )
342+ require .NoError (t , err )
343+ assert .True (t , found )
341344 assert .Equal (t , uint (1 ), u )
342345
343346 var u2 uint
344- require .NoError (t , result .DecodePath (& u2 , "array" , 2 ))
347+ found , err = result .DecodePath (& u2 , "array" , 2 )
348+ require .NoError (t , err )
349+ assert .True (t , found )
345350 assert .Equal (t , uint (3 ), u2 )
346351
347352 // This is past the end of the array
348353 var u3 uint
349- require .NoError (t , result .DecodePath (& u3 , "array" , 3 ))
354+ found , err = result .DecodePath (& u3 , "array" , 3 )
355+ require .NoError (t , err )
356+ assert .False (t , found )
350357 assert .Equal (t , uint (0 ), u3 )
351358
352359 // Negative offsets
353360
354361 var n1 uint
355- require .NoError (t , result .DecodePath (& n1 , "array" , - 1 ))
362+ found , err = result .DecodePath (& n1 , "array" , - 1 )
363+ require .NoError (t , err )
364+ assert .True (t , found )
356365 assert .Equal (t , uint (3 ), n1 )
357366
358367 var n2 uint
359- require .NoError (t , result .DecodePath (& n2 , "array" , - 3 ))
368+ found , err = result .DecodePath (& n2 , "array" , - 3 )
369+ require .NoError (t , err )
370+ assert .True (t , found )
360371 assert .Equal (t , uint (1 ), n2 )
361372
362373 var u4 uint
363- require .NoError (t , result .DecodePath (& u4 , "map" , "mapX" , "arrayX" , 1 ))
374+ found , err = result .DecodePath (& u4 , "map" , "mapX" , "arrayX" , 1 )
375+ require .NoError (t , err )
376+ assert .True (t , found )
364377 assert .Equal (t , uint (8 ), u4 )
365378
366379 // Does key not exist
367380 var ne uint
368- require .NoError (t , result .DecodePath (& ne , "does-not-exist" , 1 ))
381+ found , err = result .DecodePath (& ne , "does-not-exist" , 1 )
382+ require .NoError (t , err )
383+ assert .False (t , found )
369384 assert .Equal (t , uint (0 ), ne )
370385}
371386
@@ -1000,7 +1015,7 @@ func BenchmarkDecodePathCountryCode(b *testing.B) {
10001015 s := make (net.IP , 4 )
10011016 for range b .N {
10021017 ip := randomIPv4Address (r , s )
1003- err = db .Lookup (ip ).DecodePath (& result , path ... )
1018+ _ , err = db .Lookup (ip ).DecodePath (& result , path ... )
10041019 if err != nil {
10051020 b .Error (err )
10061021 }
0 commit comments