Guest User

Untitled

a guest
Jan 14th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.31 KB | None | 0 0
  1. package json
  2.  
  3. import (
  4.         "reflect"
  5.         "testing"
  6. )
  7.  
  8. func TestSetNilSlice(t *testing.T) {
  9.         var buf []byte = []byte{1, 2, 3}
  10.         v := reflect.ValueOf(buf)
  11.         v.Set(reflect.Zero(v.Type()))
  12.         if buf != nil {
  13.                 t.Fatal("Expected nil buf, was", buf)
  14.         }  
  15. }
Add Comment
Please, Sign In to add comment