@@ -578,6 +578,23 @@ func AnythingOfType(t string) AnythingOfTypeArgument {
578
578
return AnythingOfTypeArgument (t )
579
579
}
580
580
581
+ // IsTypeArgument is a struct that contains the type of an argument
582
+ // for use when type checking. This is an alternative to AnythingOfType.
583
+ // Used in Diff and Assert.
584
+ type IsTypeArgument struct {
585
+ t interface {}
586
+ }
587
+
588
+ // IsType returns an IsTypeArgument object containing the type to check for.
589
+ // You can provide a zero-value of the type to check. This is an
590
+ // alternative to AnythingOfType. Used in Diff and Assert.
591
+ //
592
+ // For example:
593
+ // Assert(t, IsType(""), IsType(0))
594
+ func IsType (t interface {}) * IsTypeArgument {
595
+ return & IsTypeArgument {t : t }
596
+ }
597
+
581
598
// argumentMatcher performs custom argument matching, returning whether or
582
599
// not the argument is matched by the expectation fixture function.
583
600
type argumentMatcher struct {
@@ -711,6 +728,12 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
711
728
output = fmt .Sprintf ("%s\t %d: FAIL: type %s != type %s - %s\n " , output , i , expected , reflect .TypeOf (actual ).Name (), actualFmt )
712
729
}
713
730
731
+ } else if reflect .TypeOf (expected ) == reflect .TypeOf ((* IsTypeArgument )(nil )) {
732
+ t := expected .(* IsTypeArgument ).t
733
+ if reflect .TypeOf (t ) != reflect .TypeOf (actual ) {
734
+ differences ++
735
+ output = fmt .Sprintf ("%s\t %d: FAIL: type %s != type %s - %s\n " , output , i , reflect .TypeOf (t ).Name (), reflect .TypeOf (actual ).Name (), actualFmt )
736
+ }
714
737
} else {
715
738
716
739
// normal checking
0 commit comments