github.com/leanovate/gopter@v0.2.9/arbitrary/gen_for_kind_slice_test.go (about)

     1  package arbitrary_test
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/leanovate/gopter/arbitrary"
     8  )
     9  
    10  func TestArbitrariesSlices(t *testing.T) {
    11  	arbitraries := arbitrary.DefaultArbitraries()
    12  
    13  	gen := arbitraries.GenForType(reflect.TypeOf([]bool{}))
    14  	value, ok := gen.Sample()
    15  	if !ok {
    16  		t.Errorf("Invalid value %#v", value)
    17  	}
    18  	if _, ok = value.([]bool); !ok {
    19  		t.Errorf("Invalid value %#v", value)
    20  	}
    21  
    22  	gen = arbitraries.GenForType(reflect.TypeOf([]*int64{}))
    23  	value, ok = gen.Sample()
    24  	if !ok {
    25  		t.Errorf("Invalid value %#v", value)
    26  	}
    27  	if _, ok = value.([]*int64); !ok {
    28  		t.Errorf("Invalid value %#v", value)
    29  	}
    30  }