aboutsummaryrefslogtreecommitdiff
path: root/cmp/cmpopts/util_test.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2018-03-26 15:09:07 -0700
committerGitHub <noreply@github.com>2018-03-26 15:09:07 -0700
commit0627e4440b70a1645f19cd9f611320f547068b45 (patch)
tree74c4ff670296f3a24e9e2c455ffdd856702cf6f8 /cmp/cmpopts/util_test.go
parent0c93777250bd58222171888d1651979319d8b381 (diff)
downloadgo-cmp-0627e4440b70a1645f19cd9f611320f547068b45.tar.gz
Enforce tests to provide a reason (#83)
To prevent future developers from getting lazy, check that a reason is given as part of each test case. Checks are only given for cmpopts. The cmp tests lack reasons, which is future work.
Diffstat (limited to 'cmp/cmpopts/util_test.go')
-rw-r--r--cmp/cmpopts/util_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/cmp/cmpopts/util_test.go b/cmp/cmpopts/util_test.go
index f532789..02c447f 100644
--- a/cmp/cmpopts/util_test.go
+++ b/cmp/cmpopts/util_test.go
@@ -731,6 +731,8 @@ func TestOptions(t *testing.T) {
gotEqual = cmp.Equal(tt.x, tt.y, tt.opts...)
}()
switch {
+ case tt.reason == "":
+ t.Errorf("reason must be provided")
case gotPanic == "" && tt.wantPanic:
t.Errorf("expected Equal panic\nreason: %s", tt.reason)
case gotPanic != "" && !tt.wantPanic:
@@ -972,6 +974,8 @@ func TestPanic(t *testing.T) {
}()
switch {
+ case tt.reason == "":
+ t.Errorf("reason must be provided")
case tt.wantPanic == "" && gotPanic != "":
t.Errorf("unexpected panic message: %s\nreason: %s", gotPanic, tt.reason)
case tt.wantPanic != "" && !strings.Contains(gotPanic, tt.wantPanic):