@@ -668,23 +668,27 @@ func IsType(t interface{}) *IsTypeArgument {
668668// FunctionalOptionsArgument is a struct that contains the type and value of an functional option argument
669669// for use when type checking.
670670type FunctionalOptionsArgument struct {
671- name string
672671 value interface {}
673672}
674673
675674// String returns the string representation of FunctionalOptionsArgument
676675func (f * FunctionalOptionsArgument ) String () string {
677- return strings .Replace (fmt .Sprintf ("%#v" , f .value ), "[]interface {}" , f .name , 1 )
676+ var name string
677+ tValue := reflect .ValueOf (f .value )
678+ if tValue .Len () > 0 {
679+ name = "[]" + reflect .TypeOf (tValue .Index (0 ).Interface ()).String ()
680+ }
681+
682+ return strings .Replace (fmt .Sprintf ("%#v" , f .value ), "[]interface {}" , name , 1 )
678683}
679684
680685// FunctionalOptions returns an FunctionalOptionsArgument object containing the functional option type
681686// and the values to check of
682687//
683688// For example:
684689// Assert(t, FunctionalOptions("[]foo.FunctionalOption", foo.Opt1(), foo.Opt2()))
685- func FunctionalOptions (name string , value ... interface {}) * FunctionalOptionsArgument {
690+ func FunctionalOptions (value ... interface {}) * FunctionalOptionsArgument {
686691 return & FunctionalOptionsArgument {
687- name : name ,
688692 value : value ,
689693 }
690694}
@@ -829,10 +833,16 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
829833 output = fmt .Sprintf ("%s\t %d: FAIL: type %s != type %s - %s\n " , output , i , reflect .TypeOf (t ).Name (), reflect .TypeOf (actual ).Name (), actualFmt )
830834 }
831835 } else if reflect .TypeOf (expected ) == reflect .TypeOf ((* FunctionalOptionsArgument )(nil )) {
832- name := expected .(* FunctionalOptionsArgument ).name
833836 t := expected .(* FunctionalOptionsArgument ).value
837+
838+ var name string
839+ tValue := reflect .ValueOf (t )
840+ if tValue .Len () > 0 {
841+ name = "[]" + reflect .TypeOf (tValue .Index (0 ).Interface ()).String ()
842+ }
843+
834844 tName := reflect .TypeOf (t ).Name ()
835- if name != reflect .TypeOf (actual ).String () {
845+ if name != reflect .TypeOf (actual ).String () && tValue . Len () != 0 {
836846 differences ++
837847 output = fmt .Sprintf ("%s\t %d: FAIL: type %s != type %s - %s\n " , output , i , tName , reflect .TypeOf (actual ).Name (), actualFmt )
838848 } else {
0 commit comments