github.com/leanovate/gopter@v0.2.9/prop/convert_result.go (about) 1 package prop 2 3 import ( 4 "fmt" 5 6 "github.com/leanovate/gopter" 7 ) 8 9 func convertResult(result interface{}, err error) *gopter.PropResult { 10 if err != nil { 11 return &gopter.PropResult{ 12 Status: gopter.PropError, 13 Error: err, 14 } 15 } 16 switch result.(type) { 17 case bool: 18 if result.(bool) { 19 return &gopter.PropResult{Status: gopter.PropTrue} 20 } 21 return &gopter.PropResult{Status: gopter.PropFalse} 22 case string: 23 if result.(string) == "" { 24 return &gopter.PropResult{Status: gopter.PropTrue} 25 } 26 return &gopter.PropResult{ 27 Status: gopter.PropFalse, 28 Labels: []string{result.(string)}, 29 } 30 case *gopter.PropResult: 31 return result.(*gopter.PropResult) 32 } 33 return &gopter.PropResult{ 34 Status: gopter.PropError, 35 Error: fmt.Errorf("Invalid check result: %#v", result), 36 } 37 }