//New allows a test to be created from a Suite.
New allows a test to be created from a Suite.
// New allows a test to be created from a Suite .
func New(testsuite Suite) Test {
	var value = reflect.ValueOf(testsuite)
	if value.Kind() != reflect.Ptr {
		panic(fmt.Errorf("%v value must be passed by reference to test.New", value.Type()))
	}
	value = value.Elem()
	field, ok := value.Type().FieldByName("Suite")
	if ok && field.Type == reflect.TypeOf([0]Suite{}).Elem() && field.Anonymous {
		value.FieldByName("Suite").Set(reflect.ValueOf(new(suite)))
	}
	return func(t *testing.T) {
		testsuite.SetT(t)
		if _, ok := value.Addr().Type().MethodByName("SetupSuite"); ok {
			value.Addr().MethodByName("SetupSuite").Call(nil)
		}
		for i := 0; i < value.Addr().NumMethod(); i++ {
			method := value.Addr().Method(i)
			if strings.HasPrefix(value.Addr().Type().Method(i).Name, "Test") {
				method.Call(nil)
			}
		}
	}
}
func New ( testsuite Suite ) Test { var value = reflect . ValueOf ( testsuite ) if value . Kind ( ) != reflect . Ptr { panic ( fmt . Errorf ( " " , value . Type ( ) ) ) } value = value . Elem ( ) field , ok := value . Type ( ) . FieldByName ( " " ) if ok && field . Type == reflect . TypeOf ( [ 0 ] Suite { } ) . Elem ( ) && field . Anonymous { value . FieldByName ( " " ) . Set ( reflect . ValueOf ( new ( suite ) ) ) } return func ( t * testing . T ) { testsuite . SetT ( t ) if _ , ok := value . Addr ( ) . Type ( ) . MethodByName ( " " ) ; ok { value . Addr ( ) . MethodByName ( " " ) . Call ( nil ) } for i := 0 ; i < value . Addr ( ) . NumMethod ( ) ; i ++ { method := value . Addr ( ) . Method ( i ) if strings . HasPrefix ( value . Addr ( ) . Type ( ) . Method ( i ) . Name , " " ) { method . Call ( nil ) } } } }
New allows a test to be created from a Suite.
New allows a test to be created from a Suite .