assert: make *AssertionFunc type just aliases

We don't need to define "hard" types for *AssertionFunc types as we
don't attach methods to them. Also, making them just type aliases will
give more flexibility to users of our API.
So ComparisonAssertionFunc and other *AssertionFunc types are now just
type aliases.
pull/1563/head
Olivier Mengué 2024-03-04 18:52:18 +01:00
parent bb548d0473
commit f8f5e6bd38
2 changed files with 8 additions and 8 deletions

View File

@ -31,19 +31,19 @@ type TestingT interface {
// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful
// for table driven tests. // for table driven tests.
type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) bool type ComparisonAssertionFunc = func(TestingT, interface{}, interface{}, ...interface{}) bool
// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful
// for table driven tests. // for table driven tests.
type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) bool type ValueAssertionFunc = func(TestingT, interface{}, ...interface{}) bool
// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful
// for table driven tests. // for table driven tests.
type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool type BoolAssertionFunc = func(TestingT, bool, ...interface{}) bool
// ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful // ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful
// for table driven tests. // for table driven tests.
type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool type ErrorAssertionFunc = func(TestingT, error, ...interface{}) bool
// Comparison is a custom function that returns true on success and false on failure // Comparison is a custom function that returns true on success and false on failure
type Comparison func() (success bool) type Comparison func() (success bool)

View File

@ -12,18 +12,18 @@ type tHelper interface {
// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful
// for table driven tests. // for table driven tests.
type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) type ComparisonAssertionFunc = func(TestingT, interface{}, interface{}, ...interface{})
// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful
// for table driven tests. // for table driven tests.
type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) type ValueAssertionFunc = func(TestingT, interface{}, ...interface{})
// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful
// for table driven tests. // for table driven tests.
type BoolAssertionFunc func(TestingT, bool, ...interface{}) type BoolAssertionFunc = func(TestingT, bool, ...interface{})
// ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful // ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful
// for table driven tests. // for table driven tests.
type ErrorAssertionFunc func(TestingT, error, ...interface{}) type ErrorAssertionFunc = func(TestingT, error, ...interface{})
//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require.go.tmpl -include-format-funcs" //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require.go.tmpl -include-format-funcs"