@@ -252,6 +252,30 @@ func TestContextGetInt(t *testing.T) {
252252 assert .Equal (t , 1 , c .GetInt ("int" ))
253253}
254254
255+ func TestContextGetInt8 (t * testing.T ) {
256+ c , _ := CreateTestContext (httptest .NewRecorder ())
257+ key := "int8"
258+ value := int8 (0x7F )
259+ c .Set (key , value )
260+ assert .Equal (t , value , c .GetInt8 (key ))
261+ }
262+
263+ func TestContextGetInt16 (t * testing.T ) {
264+ c , _ := CreateTestContext (httptest .NewRecorder ())
265+ key := "int16"
266+ value := int16 (0x7FFF )
267+ c .Set (key , value )
268+ assert .Equal (t , value , c .GetInt16 (key ))
269+ }
270+
271+ func TestContextGetInt32 (t * testing.T ) {
272+ c , _ := CreateTestContext (httptest .NewRecorder ())
273+ key := "int32"
274+ value := int32 (0x7FFFFFFF )
275+ c .Set (key , value )
276+ assert .Equal (t , value , c .GetInt32 (key ))
277+ }
278+
255279func TestContextGetInt64 (t * testing.T ) {
256280 c , _ := CreateTestContext (httptest .NewRecorder ())
257281 c .Set ("int64" , int64 (42424242424242 ))
@@ -264,12 +288,44 @@ func TestContextGetUint(t *testing.T) {
264288 assert .Equal (t , uint (1 ), c .GetUint ("uint" ))
265289}
266290
291+ func TestContextGetUint8 (t * testing.T ) {
292+ c , _ := CreateTestContext (httptest .NewRecorder ())
293+ key := "uint8"
294+ value := uint8 (0xFF )
295+ c .Set (key , value )
296+ assert .Equal (t , value , c .GetUint8 (key ))
297+ }
298+
299+ func TestContextGetUint16 (t * testing.T ) {
300+ c , _ := CreateTestContext (httptest .NewRecorder ())
301+ key := "uint16"
302+ value := uint16 (0xFFFF )
303+ c .Set (key , value )
304+ assert .Equal (t , value , c .GetUint16 (key ))
305+ }
306+
307+ func TestContextGetUint32 (t * testing.T ) {
308+ c , _ := CreateTestContext (httptest .NewRecorder ())
309+ key := "uint32"
310+ value := uint32 (0xFFFFFFFF )
311+ c .Set (key , value )
312+ assert .Equal (t , value , c .GetUint32 (key ))
313+ }
314+
267315func TestContextGetUint64 (t * testing.T ) {
268316 c , _ := CreateTestContext (httptest .NewRecorder ())
269317 c .Set ("uint64" , uint64 (18446744073709551615 ))
270318 assert .Equal (t , uint64 (18446744073709551615 ), c .GetUint64 ("uint64" ))
271319}
272320
321+ func TestContextGetFloat32 (t * testing.T ) {
322+ c , _ := CreateTestContext (httptest .NewRecorder ())
323+ key := "float32"
324+ value := float32 (3.14 )
325+ c .Set (key , value )
326+ assert .Equal (t , value , c .GetFloat32 (key ))
327+ }
328+
273329func TestContextGetFloat64 (t * testing.T ) {
274330 c , _ := CreateTestContext (httptest .NewRecorder ())
275331 c .Set ("float64" , 4.2 )
@@ -289,6 +345,102 @@ func TestContextGetDuration(t *testing.T) {
289345 assert .Equal (t , time .Second , c .GetDuration ("duration" ))
290346}
291347
348+ func TestContextGetIntSlice (t * testing.T ) {
349+ c , _ := CreateTestContext (httptest .NewRecorder ())
350+ key := "int-slice"
351+ value := []int {1 , 2 }
352+ c .Set (key , value )
353+ assert .Equal (t , value , c .GetIntSlice (key ))
354+ }
355+
356+ func TestContextGetInt8Slice (t * testing.T ) {
357+ c , _ := CreateTestContext (httptest .NewRecorder ())
358+ key := "int8-slice"
359+ value := []int8 {1 , 2 }
360+ c .Set (key , value )
361+ assert .Equal (t , value , c .GetInt8Slice (key ))
362+ }
363+
364+ func TestContextGetInt16Slice (t * testing.T ) {
365+ c , _ := CreateTestContext (httptest .NewRecorder ())
366+ key := "int16-slice"
367+ value := []int16 {1 , 2 }
368+ c .Set (key , value )
369+ assert .Equal (t , value , c .GetInt16Slice (key ))
370+ }
371+
372+ func TestContextGetInt32Slice (t * testing.T ) {
373+ c , _ := CreateTestContext (httptest .NewRecorder ())
374+ key := "int32-slice"
375+ value := []int32 {1 , 2 }
376+ c .Set (key , value )
377+ assert .Equal (t , value , c .GetInt32Slice (key ))
378+ }
379+
380+ func TestContextGetInt64Slice (t * testing.T ) {
381+ c , _ := CreateTestContext (httptest .NewRecorder ())
382+ key := "int64-slice"
383+ value := []int64 {1 , 2 }
384+ c .Set (key , value )
385+ assert .Equal (t , value , c .GetInt64Slice (key ))
386+ }
387+
388+ func TestContextGetUintSlice (t * testing.T ) {
389+ c , _ := CreateTestContext (httptest .NewRecorder ())
390+ key := "uint-slice"
391+ value := []uint {1 , 2 }
392+ c .Set (key , value )
393+ assert .Equal (t , value , c .GetUintSlice (key ))
394+ }
395+
396+ func TestContextGetUint8Slice (t * testing.T ) {
397+ c , _ := CreateTestContext (httptest .NewRecorder ())
398+ key := "uint8-slice"
399+ value := []uint8 {1 , 2 }
400+ c .Set (key , value )
401+ assert .Equal (t , value , c .GetUint8Slice (key ))
402+ }
403+
404+ func TestContextGetUint16Slice (t * testing.T ) {
405+ c , _ := CreateTestContext (httptest .NewRecorder ())
406+ key := "uint16-slice"
407+ value := []uint16 {1 , 2 }
408+ c .Set (key , value )
409+ assert .Equal (t , value , c .GetUint16Slice (key ))
410+ }
411+
412+ func TestContextGetUint32Slice (t * testing.T ) {
413+ c , _ := CreateTestContext (httptest .NewRecorder ())
414+ key := "uint32-slice"
415+ value := []uint32 {1 , 2 }
416+ c .Set (key , value )
417+ assert .Equal (t , value , c .GetUint32Slice (key ))
418+ }
419+
420+ func TestContextGetUint64Slice (t * testing.T ) {
421+ c , _ := CreateTestContext (httptest .NewRecorder ())
422+ key := "uint64-slice"
423+ value := []uint64 {1 , 2 }
424+ c .Set (key , value )
425+ assert .Equal (t , value , c .GetUint64Slice (key ))
426+ }
427+
428+ func TestContextGetFloat32Slice (t * testing.T ) {
429+ c , _ := CreateTestContext (httptest .NewRecorder ())
430+ key := "float32-slice"
431+ value := []float32 {1 , 2 }
432+ c .Set (key , value )
433+ assert .Equal (t , value , c .GetFloat32Slice (key ))
434+ }
435+
436+ func TestContextGetFloat64Slice (t * testing.T ) {
437+ c , _ := CreateTestContext (httptest .NewRecorder ())
438+ key := "float64-slice"
439+ value := []float64 {1 , 2 }
440+ c .Set (key , value )
441+ assert .Equal (t , value , c .GetFloat64Slice (key ))
442+ }
443+
292444func TestContextGetStringSlice (t * testing.T ) {
293445 c , _ := CreateTestContext (httptest .NewRecorder ())
294446 c .Set ("slice" , []string {"foo" })
0 commit comments