-
Notifications
You must be signed in to change notification settings - Fork 3
/
reporter_test.go
36 lines (27 loc) · 912 Bytes
/
reporter_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package assert
import (
"testing"
)
func TestReportErrorWrongInput(t *testing.T) {
defer Panic(t, "don't know how to handle int")
reportError(10, &failedBoolCompMsg{want: true, got: false})
}
type wrongReporter struct{}
func (r *wrongReporter) Test(test string) string {
return test
}
func TestReportErrorWrongReporterFunc(t *testing.T) {
defer Panic(t, "provided reporter function doesn't implement `func(format string, args ...interface{})`")
reporter := &wrongReporter{}
reportError(reporter.Test, &failedBoolCompMsg{want: true, got: false})
}
func TestReportErrorWrongIface(t *testing.T) {
defer Panic(t, "provided interface doesn't implement `Fatalf(format string, args ...interface{})`")
type iface interface {
Test(test string) string
}
reporter := &wrongReporter{}
func(wrongTestingT iface) {
reportError(wrongTestingT, &failedBoolCompMsg{want: true, got: false})
}(reporter)
}